setup.sh: enhance waiting, error detection and correct initial packages
This commit is contained in:
parent
a581682538
commit
456d5bf593
33
setup.sh
33
setup.sh
|
@ -28,33 +28,42 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting vm..."
|
echo "Starting vm..."
|
||||||
virsh start ${vm}
|
virsh start ${vm} || (echo -e "\e[1m\e[31mFail to start...(perhaps already done?)\e[0m")
|
||||||
|
sleep 5
|
||||||
|
|
||||||
echo "Waiting for ${vm} to boot..."
|
echo "Waiting for ${vm} to boot..."
|
||||||
sudo -u admin666 ssh -o ConnectTimeout=60 ${vm} "echo Connected!"
|
sudo -u admin666 ssh -4 -o ConnectTimeout=60 ${vm} "echo Connected!" || (echo -e "\e[1m\e[31mFail to wait...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Setting up hostname..."
|
echo "Setting up hostname..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo hostnamectl set-hostname ${vm}"
|
sudo -u admin666 ssh -4 ${vm} "sudo hostnamectl set-hostname ${vm}" || (echo -e "\e[1m\e[31mFail to set up...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Reloading postfix configuration..."
|
echo "Reloading postfix configuration..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo postmap /etc/postfix/virtual"
|
sudo -u admin666 ssh -4 ${vm} "sudo postmap /etc/postfix/virtual" || (echo -e "\e[1m\e[31mFail to reload...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Reloading postfix..."
|
#echo "Reloading postfix..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo postfix reload"
|
#sudo -u admin666 ssh -4 ${vm} "sudo postfix reload" || (echo -e "\e[1m\e[31mFail to reload ($?)...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Rebooting..."
|
echo "Rebooting..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo reboot"
|
sudo -u admin666 ssh -4 ${vm} "sudo reboot" || echo "(rebooted quickly)"
|
||||||
|
sleep 5
|
||||||
|
|
||||||
echo "Waiting for ${vm} to boot..."
|
echo "Waiting for ${vm} to boot..."
|
||||||
sudo -u admin666 ssh -o ConnectTimeout=60 ${vm} "echo Connected!"
|
sudo -u admin666 ssh -4 -o ConnectTimeout=60 ${vm} "echo Connected!" || (echo -e "\e[1m\e[31mFail to wait...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Updating packages..."
|
echo "Updating packages..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo apt-get update"
|
sudo -u admin666 ssh -4 ${vm} "sudo apt-get update" || (echo -e "\e[1m\e[31mFail to update...\e[0m" ; exit 1)
|
||||||
sudo -u admin666 ssh -4 ${vm} 'sudo apt-get full-upgrade -y -o Dpkg::Options::="--force-confdef"'
|
sudo -u admin666 ssh -4 ${vm} 'sudo DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y -o Dpkg::Options::="--force-confdef"' || (echo -e "\e[1m\e[31mFail to upgrade...\e[0m" ; exit 1)
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo apt-get autoremove -y"
|
sudo -u admin666 ssh -4 ${vm} "sudo apt-get autoremove -y" || (echo -e "\e[1m\e[31mFail to remove...\e[0m" ; exit 1)
|
||||||
|
|
||||||
|
echo "Rebooting..."
|
||||||
|
sudo -u admin666 ssh -4 ${vm} "sudo reboot" || echo "(rebooted quickly)"
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
echo "Waiting for ${vm} to boot..."
|
||||||
|
sudo -u admin666 ssh -4 -o ConnectTimeout=60 ${vm} "echo Connected!" || (echo -e "\e[1m\e[31mFail to wait...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo "Installing base packages..."
|
echo "Installing base packages..."
|
||||||
sudo -u admin666 ssh -4 ${vm} "sudo apt-get install -y etckeeper molly-guard tig lm-sensors fancontrol screen emacs-nox vrms needrestart iotop htop curl ncdu iptraf tig unzip"
|
sudo -u admin666 ssh -4 ${vm} "sudo apt-get install -y etckeeper molly-guard tig lm-sensors fancontrol screen emacs-nox needrestart iotop htop curl ncdu iptraf tig unzip" || (echo -e "\e[1m\e[31mFail to install...\e[0m" ; exit 1)
|
||||||
|
|
||||||
echo -e "\e[36m${vm} successfully set up\e[0m"
|
echo -e "\e[36m${vm} successfully set up\e[0m"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue