1
0
mirror of https://github.com/gryf/vmstrap.git synced 2025-12-18 12:00:31 +01:00

Added option to not install any packages.

This commit is contained in:
2021-10-07 22:16:12 +02:00
parent e86dd6fb12
commit 2c22d2fd9f

View File

@@ -60,7 +60,7 @@ COMMON_DEB=(exuberant-ctags
silversearcher-ag) silversearcher-ag)
rpm_based() { function rpm_based {
if [[ $DISTRO_ID == 'fedora' ]]; then if [[ $DISTRO_ID == 'fedora' ]]; then
PGS=(ptpython3 PGS=(ptpython3
python3-apsw python3-apsw
@@ -86,58 +86,60 @@ rpm_based() {
rxvt-unicode-256color) rxvt-unicode-256color)
fi fi
# 1. update if [ "${DONT_INSTALL_PKGS}" != "1" ]; then
if [[ $DISTRO_ID == 'centos' ]]; then # 1. update
# install epel repository for centos if [[ $DISTRO_ID == 'centos' ]]; then
sudo yum -y install epel-release # install epel repository for centos
sudo yum -y install epel-release
fi
sudo yum -y update
# 2. install tools
sudo yum install -y "${COMMON_PGS[@]}" "${COMMON_RPM[@]}" "${PGS[@]}"
# 3. cleanup
sudo yum -y clean all
# 4. install tools from pypi
if [[ $DISTRO_ID == 'fedora' ]]; then
sudo pip install -U pip setuptools
installed_pkgs=$(pip list)
pkgs_to_install=
for pkg in remote_pdb pdbpp rainbow; do
if echo "${installed_pkgs}" | grep -qv "${pkg}"; then
pkgs_to_install="${pkgs_to_install} ${pkg}"
fi
done
if [ -n "${pkgs_to_install}" ]; then
sudo pip install ${pkgs_to_install}
fi
elif [[ $DISTRO_ID == 'centos' ]]; then
sudo pip3 install -U pip setuptools
installed_pkgs=$(pip list)
if echo "${installed_pkgs}" | grep -qv "rainbow"; then
sudo pip install rainbow
sudo pip3 install rainbow
fi
installed_pkgs=$(pip3 list)
for pkg in remote_pdb pdbpp; do
if echo "${installed_pkgs}" | grep -qv "${pkg}"; then
sudo pip3 install ${pkg}
fi
done
fi
fi fi
sudo yum -y update
# 2. install tools # 5. set default editor
sudo yum install -y "${COMMON_PGS[@]}" "${COMMON_RPM[@]}" "${PGS[@]}"
# 3. cleanup
sudo yum -y clean all
# 4. set default editor
echo 'export VISUAL="vim"' | sudo tee /etc/profile.d/vim.sh echo 'export VISUAL="vim"' | sudo tee /etc/profile.d/vim.sh
echo 'export EDITOR="vim"' | sudo tee -a /etc/profile.d/vim.sh echo 'export EDITOR="vim"' | sudo tee -a /etc/profile.d/vim.sh
# 5. install tools from pypi
if [[ $DISTRO_ID == 'fedora' ]]; then
sudo pip install -U pip setuptools
installed_pkgs=$(pip list)
pkgs_to_install=
for pkg in remote_pdb pdbpp rainbow; do
if echo "${installed_pkgs}" | grep -qv "${pkg}"; then
pkgs_to_install="${pkgs_to_install} ${pkg}"
fi
done
if [ -n "${pkgs_to_install}" ]; then
sudo pip install ${pkgs_to_install}
fi
elif [[ $DISTRO_ID == 'centos' ]]; then
sudo pip3 install -U pip setuptools
installed_pkgs=$(pip list)
if echo "${installed_pkgs}" | grep -qv "rainbow"; then
sudo pip install rainbow
sudo pip3 install rainbow
fi
installed_pkgs=$(pip3 list)
for pkg in remote_pdb pdbpp; do
if echo "${installed_pkgs}" | grep -qv "${pkg}"; then
sudo pip3 install ${pkg}
fi
done
fi
# 6. copy configuration for bash, git, tmux # 6. copy configuration for bash, git, tmux
common_conf common_conf
} }
ubuntu() { function ubuntu {
case $DISTRO_R in case $DISTRO_R in
'16.04') '16.04')
PGS=(ipython PGS=(ipython
@@ -172,49 +174,55 @@ ubuntu() {
# linux-image-virtual linux-virtual cryptsetup-initramfs \ # linux-image-virtual linux-virtual cryptsetup-initramfs \
# busybox-initramfs cloud-init initramfs-tools # busybox-initramfs cloud-init initramfs-tools
# 1. update if [ "${DONT_INSTALL_PKGS}" != "1" ]; then
sudo apt update && sudo apt -y upgrade
# 2. install tools # 1. update
sudo apt install -y "${COMMON_PGS[@]}" "${COMMON_DEB[@]}" "${PGS[@]}" sudo apt update && sudo apt -y upgrade
# 3. cleanup # 2. install tools
sudo apt-get autoremove -y && sudo apt-get autoclean -y sudo apt install -y "${COMMON_PGS[@]}" "${COMMON_DEB[@]}" "${PGS[@]}"
# 4. change alternatives # 3. cleanup
sudo apt-get autoremove -y && sudo apt-get autoclean -y
# 4.
case $DISTRO_R in
'16.04')
sudo pip install pip --upgrade
sudo pip install remote_pdb rainbow pdbpp
;;
'18.04')
sudo update-alternatives \
--install /usr/bin/python python /usr/bin/python3.6 10
sudo update-alternatives \
--install /usr/bin/pip pip /usr/bin/pip3 10
# 5.
sudo pip3 install pip --upgrade
sudo pip3 install remote_pdb rainbow pdbpp
;;
'20.04')
sudo update-alternatives \
--install /usr/bin/python python /usr/bin/python3.8 10
sudo update-alternatives \
--install /usr/bin/pip pip /usr/bin/pip3 10
# 5.
sudo pip3 install remote_pdb rainbow pdbpp
;;
esac
fi
# 5. change alternatives
sudo update-alternatives --set editor /usr/bin/vim.basic sudo update-alternatives --set editor /usr/bin/vim.basic
# 5.
case $DISTRO_R in
'16.04')
sudo pip install pip --upgrade
sudo pip install remote_pdb rainbow pdbpp
;;
'18.04')
sudo update-alternatives \
--install /usr/bin/python python /usr/bin/python3.6 10
sudo update-alternatives \
--install /usr/bin/pip pip /usr/bin/pip3 10
# 5.
sudo pip3 install pip --upgrade
sudo pip3 install remote_pdb rainbow pdbpp
;;
'20.04')
sudo update-alternatives \
--install /usr/bin/python python /usr/bin/python3.8 10
sudo update-alternatives \
--install /usr/bin/pip pip /usr/bin/pip3 10
# 5.
sudo pip3 install remote_pdb rainbow pdbpp
;;
esac
# 6. copy configuration for bash, git, tmux # 6. copy configuration for bash, git, tmux
common_conf common_conf
} }
tmux_conf() { function tmux_conf {
tmux_ver=$(tmux -V|cut -f 2 -d ' ') tmux_ver=$(tmux -V|cut -f 2 -d ' ')
if [ -z "${tmux_ver}" ]; then
return
fi
major=${tmux_ver%.*} major=${tmux_ver%.*}
minor=${tmux_ver#*.} minor=${tmux_ver#*.}
@@ -269,9 +277,10 @@ tmux_conf() {
fi fi
} }
common_conf() { function common_conf {
cp "${DIR}/.bash_prompt" ~/ cp "${DIR}/.bash_prompt" ~/
cp "${DIR}/.tmux.conf" ~/ cp "${DIR}/.tmux.conf" ~/
tmux_conf tmux_conf
cp "${DIR}/.gitconfig" ~/ cp "${DIR}/.gitconfig" ~/
@@ -299,10 +308,6 @@ common_conf() {
popd popd
fi fi
# clone devstack
git clone https://opendev.org/openstack/devstack ~/devstack
cp "${DIR}/kuryr.conf" ~/devstack/local.conf
# get k9s # get k9s
wget "https://github.com/derailed/k9s/releases/download/"` wget "https://github.com/derailed/k9s/releases/download/"`
`"v0.24.7/k9s_Linux_x86_64.tar.gz" `"v0.24.7/k9s_Linux_x86_64.tar.gz"
@@ -310,17 +315,49 @@ common_conf() {
rm k9s_Linux_x86_64.tar.gz rm k9s_Linux_x86_64.tar.gz
} }
case $DISTRO_ID in function _showusage {
"ubuntu") echo "Usage: $(basename $1) [OPTIONS]"
ubuntu echo "Configure system and optionally install a set of packages."
;; echo
"centos") echo Where OPTIONS are:
rpm_based echo " -h This help."
;; echo " -c Do the config only, don't install anything"
"fedora") # Fedora 31 }
rpm_based
;; function main {
*) case $DISTRO_ID in
echo "Distribution ${DISTRO_ID} not supported" "ubuntu")
;; ubuntu
esac ;;
"centos")
rpm_based
;;
"fedora") # Fedora 31
rpm_based
;;
*)
echo "Distribution ${DISTRO_ID} not supported"
;;
esac
}
# react on -h or --help
while getopts ":heicbdgvxsauzr" optchar; do
case "${optchar}" in
h)
_showusage "$0"
exit 0
;;
c)
DONT_INSTALL_PKGS=1
;;
*)
echo Invalid argument "$1"
_showusage "$0"
exit 1
;;
esac
done
main