ucloud-setup/init.sh
2019-09-17 18:31:36 +05:00

87 lines
No EOL
2 KiB
Bash

get_distro() {
OS=$(cat /etc/*release | grep "^ID=" | head -1 | cut -c 4-)
echo $OS
}
# Directory where user saves his/her files/images
mkdir /var/www
# These directories would be need if user chooses
# to setup ucloud without CEPH
mkdir /var/vm
mkdir /var/image
if ! grep -q "export LC_ALL=C.UTF-8" ~/.bashrc; then
echo 'export LC_ALL=C.UTF-8' >> ~/.bashrc
echo 'export LANG=C.UTF-8' >> ~/.bashrc
source ~/.bashrc
fi
if ! grep -q "alias etcdctl='ETCDCTL_API=3 etcdctl'" ~/.bashrc; then
echo "alias etcdctl='ETCDCTL_API=3 etcdctl'" >> ~/.bashrc
source ~/.bashrc
fi
case $(get_distro) in
"alpine")
# Install QEMU
git clone https://github.com/ahmedbilal/qemu-with-rbd-alpine.git
# Enable Alpine (3.10 + Edge) Repos
cat > /etc/apk/repositories << EOF
http://dl-cdn.alpinelinux.org/alpine/v3.10/main
http://dl-cdn.alpinelinux.org/alpine/v3.10/community
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing
EOF
# Update Package List and Upgrade System
apk update
apk upgrade
# Install system packages
apk add python3 ceph py2-pip py3-pip etcd-ctl openntpd
# Some python package dependencies
apk add libffi-dev openssl-dev make alpine-sdk gcc g++ python3-dev
apk add py3-grpcio py3-protobuf py3-tempita
(cd qemu-with-rbd-alpine && apk add *.apk --allow-untrusted)
cat > /etc/ntpd.conf << EOF
servers pool.ntp.org
EOF
rc-update add openntpd
service openntpd start
ntpd -s
;;
"devuan"|"debian")
# Update Package List and Upgrade System
apt update
apt upgrade --yes
# Install QEMU
apt install qemu qemu-system python3 ceph python-pip python3-pip python3-dev etcd-client --yes
;;
*)
echo "Unsupported OS/Distribution"
exit 1
esac
pip3 install --upgrade pip
pip2 install --upgrade pip
# For CEPH
pip2 install prettytable
pip3 install pipenv
pipenv install