Last active
March 22, 2019 19:45
-
-
Save vhajdari/f1a4bbfc30e1096ed285ffb2772f8f2f to your computer and use it in GitHub Desktop.
lxdui installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# LXDUI Installer | |
GITREPO=https://github.com/AdaptiveScale/lxdui.git | |
APP=lxdui | |
# Check if the OS is ubuntu 14, 16, or 18. | |
# Exit with an error message if not! | |
prerequisites(){ | |
ver=`lsb_release -r -s` | |
lts="$(echo $ver | cut -d'.' -f 1)" | |
case "$lts" in | |
# 14) | |
# lts="trusty" | |
# echo "OS = Ubuntu Trusty $ver" | |
# checkForPreviousLXD | |
# installDependenciesTrusty | |
# ;; | |
16) | |
lts="xenial" | |
echo "OS = Ubuntu Xenial $ver" | |
checkForPreviousLXD | |
installDependencies | |
;; | |
18) | |
lts="bionic" | |
echo "OS = Ubuntu Bionic $ver" | |
checkForPreviousLXD | |
installDependencies | |
;; | |
*) | |
echo "Sorry! This install script doesn't support your Linux distribution." | |
exit | |
;; | |
esac | |
} | |
# Update package manager and install all prerequisites | |
installDependenciesTrusty(){ | |
sudo apt-add-repository --yes ppa:zfs-native/stable | |
sudo apt update | |
sudo apt install -y snapd git libssl-dev build-essential python3-dev python3-pip ubuntu-zfs bridge-utils #&> /dev/null | |
} | |
installDependencies(){ | |
sudo apt update #&> /dev/null | |
sudo apt install -y snapd git libssl-dev build-essential python3-dev python3-pip zfsutils-linux bridge-utils criu #&> /dev/null | |
} | |
checkForPreviousLXD(){ | |
if `command -v lxd > /dev/null 2>&1`; then | |
echo "Found LXD version `lxd --version`" | |
echo "" | |
echo "Warning...This script will attemp to remove the LXD instance" | |
echo "on the host and install the latest LXD snap package." | |
echo "This is a destructive process. If you already have containers created" | |
echo "please back them up along with the lxd configuration before continuing." | |
echo "" | |
echo "LXD will be automatically initialized with preset values." | |
read -r -p "Continue? [y/N] " choice | |
confirm | |
fi | |
} | |
installLXD(){ | |
sudo apt purge lxd lxd-client -y | |
sudo snap install lxd | |
lxd init | |
} | |
confirm(){ | |
case "$choice" in | |
[yY][eE][sS]|[yY]) | |
sudo rm -rf $APP | |
;; | |
*) | |
echo "Installation terminated." | |
exit | |
;; | |
esac | |
} | |
installAppFromGit(){ | |
#if the directory already exists warn the user and decide if ths scipt should proceed | |
if [ -d "$APP" ]; then | |
echo "" | |
echo "The '$APP' directory already exists." | |
echo "If you continue the previous installation will be deleted." | |
echo "" | |
read -r -p "Continue with replacing $APP? [y/N] " choice | |
confirm | |
fi | |
git clone $GITREPO | |
cd $APP | |
sudo pip3 install pip --upgrade | |
#python3 setup.py install --user | |
pip install . --user #&> /dev/null | |
} | |
banner(){ | |
cat<<EOF | |
██╗ ██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ | |
██║ ╚██╗██╔╝ ██╔══██╗ ██║ ██║ ██║ | |
██║ ╚███╔╝ ██║ ██║ ██║ ██║ ██║ | |
██║ ██╔██╗ ██║ ██║ ██║ ██║ ██║ | |
███████╗ ██╔╝ ██╗ ██████╔╝ ╚██████╔╝ ██║ | |
╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ | |
LXDUI Installer | |
EOF | |
} | |
banner | |
prerequisites | |
installLXD | |
installAppFromGit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment