Skip to content

Instantly share code, notes, and snippets.

@Pandry
Last active October 23, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pandry/a24b1b681ea5524157799cb013c1b387 to your computer and use it in GitHub Desktop.
Save Pandry/a24b1b681ea5524157799cb013c1b387 to your computer and use it in GitHub Desktop.
#!/bin/bash
##
## fast-run: curl -o install-cloudinit.sh https://gist.githubusercontent.com/Pandry/a24b1b681ea5524157799cb013c1b387/raw/7895d24277abce440fcfd010d7380067b255728e/installCloudinit.sh && chmod +x install-cloudinit.sh && ./install-cloudinit.sh
##
## Author: Pandry (github.com/Pandry)
## Date: 23/10/2018
## Script: CloudInit installer for RHosting.it
## Version: 0.1
##
if [ $(which dnf) ]; then
OS="Fedora"
elif [ $(which yum) ]; then
OS="RHEL"
elif [ $(which apt) ]; then
OS="Debian"
elif [ $(which apt-get) ]; then
OS="DebianOld"
#Debian is old, warning message
read -p "The current Ubuntu/Debian is quite old and could not work, are you sure you want to continue? " -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Nn]$ ]] # If user says no, return, otherwise continue
then
return
fi
else
echo "OS not supported"
return
fi
#Installs the required packages
if [ "$OS" == "Fedora" ]; then
dnf install git-core python36 yum-utils groupinstall development curl git-core sudo -y
elif [ "$OS" == "RHEL" ]; then
yum install git-core python36 yum-utils groupinstall development curl git-core sudo -y
elif [ "$OS" == "Debian" ]; then
apt install python3-dev python3-pip libacl1-dev sudo curl git-core sudo -y
elif [ "$OS" == "DebianOld" ]; then
apt-get install python3-dev python3-pip libacl1-dev sudo curl git-core sudo -y
fi
# Downloads CURL
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
if [ "$OS" == "RHEL" ] || [ "$OS" == "Fedora" ]; then
python36 get-pip.py
elif [ "$OS" == "Debian" ] || [ "$OS" == "DebianOld" ]; then
python3 get-pip.py
else
echo "OS not supported"
return
fi
# Downloads the last cloudinit version from github
git clone https://github.com/cloud-init/cloud-init.git
# Browse
cd cloud-init
# Installs the needed python requirements
pip3 install -r requirements.txt
# Installs cloudinit with the necessary python version (changes from debian to RHEL-based distros)
if [ "$OS" == "RHEL" ] || [ "$OS" == "Fedora" ]; then
python36 setup.py build
python36 setup.py install --init-system systemd
elif [ "$OS" == "Debian" ] || [ "$OS" == "DebianOld" ]; then
python3 setup.py build
python3 setup.py install --init-system systemd
else
echo "OS not supported"
return
fi
sudo ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init
#Enables all the things cloudinit wants
# https://cloudinit.readthedocs.io/en/latest/topics/boot.html
for svc in cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service; do
sudo systemctl enable $svc
sudo systemctl start $svc
done
# Check the status - need to be manually checked.
cloud-init init --local
cloud-init status
rm get-pip.py
rm -rf cloud-init/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment