ucloud-setup/init.sh

87 lines
1.9 KiB
Bash
Raw Normal View History

2019-09-07 08:10:28 +00:00
get_distro() {
2019-09-08 15:50:45 +00:00
OS=$(cat /etc/*release | grep "^ID=" | head -1 | cut -c 4-)
2019-09-07 08:10:28 +00:00
echo $OS
}
2019-08-31 10:00:01 +00:00
2019-09-13 16:34:48 +00:00
# Directory where user saves his/her files/images
mkdir /var/www
2019-09-10 12:35:34 +00:00
# These directories would be need if user chooses
# to setup ucloud without CEPH
mkdir /var/vm
mkdir /var/image
2019-09-07 08:21:54 +00:00
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
2019-09-07 09:09:12 +00:00
source ~/.bashrc
2019-09-07 08:22:11 +00:00
fi
2019-09-07 08:21:54 +00:00
2019-09-10 12:35:34 +00:00
if ! grep -q "alias etcdctl='ETCDCTL_API=3 etcdctl'" ~/.bashrc; then
echo "alias etcdctl='ETCDCTL_API=3 etcdctl'" >> ~/.bashrc
source ~/.bashrc
fi
2019-09-07 08:10:28 +00:00
case $(get_distro) in
"alpine")
# Install QEMU
2019-09-14 13:11:33 +00:00
git clone https://github.com/ahmedbilal/qemu-with-rbd-alpine.git
2019-08-31 10:00:01 +00:00
2019-09-07 08:10:28 +00:00
# Enable Alpine (3.10 + Edge) Repos
cat > /etc/apk/repositories << EOF
2019-08-28 08:07:21 +00:00
http://dl-cdn.alpinelinux.org/alpine/v3.10/main
http://dl-cdn.alpinelinux.org/alpine/v3.10/community
2019-08-28 07:13:05 +00:00
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing
2019-08-28 08:12:50 +00:00
EOF
2019-08-27 08:48:07 +00:00
2019-09-07 08:10:28 +00:00
# Update Package List and Upgrade System
apk update
apk upgrade
# Install system packages
2019-09-14 18:53:02 +00:00
apk add python3 ceph py2-pip py3-pip etcd-ctl openntpd
2019-09-07 08:10:28 +00:00
# Some python package dependencies
apk add libffi-dev openssl-dev make alpine-sdk gcc g++ python3-dev
2019-08-28 07:13:05 +00:00
2019-09-07 08:10:28 +00:00
apk add py3-grpcio py3-protobuf py3-tempita
2019-09-14 13:11:33 +00:00
(cd qemu-with-rbd-alpine && apk add *.apk --allow-untrusted)
2019-09-14 18:53:02 +00:00
cat > /etc/ntpd.conf << EOF
servers pool.ntp.org
EOF
rc-update add openntpd
service openntpd start
2019-09-16 09:52:45 +00:00
ntpd -s
2019-09-14 18:53:02 +00:00
2019-09-07 08:10:28 +00:00
;;
2019-09-08 15:53:35 +00:00
"devuan"|"debian")
2019-09-07 08:17:48 +00:00
# Update Package List and Upgrade System
2019-09-07 08:10:28 +00:00
apt update
2019-09-07 08:13:01 +00:00
apt upgrade --yes
2019-08-28 18:43:51 +00:00
2019-09-07 08:17:48 +00:00
# Install QEMU
2019-09-10 12:35:34 +00:00
apt install qemu qemu-system python3 ceph python-pip python3-pip etcd-client --yes
2019-09-08 15:53:35 +00:00
;;
*)
2019-09-08 15:55:00 +00:00
echo "Unsupported OS/Distribution"
2019-09-08 15:53:35 +00:00
exit 1
2019-09-07 08:10:28 +00:00
esac
2019-08-30 17:21:56 +00:00
2019-08-27 08:43:30 +00:00
pip3 install --upgrade pip
2019-08-29 10:53:07 +00:00
pip2 install --upgrade pip
# For CEPH
pip2 install prettytable
2019-08-29 18:14:51 +00:00
pip3 install pipenv
2019-08-29 17:52:09 +00:00
2019-08-31 10:57:53 +00:00
pipenv install