2017-12-18 22:16:21 +01:00
|
|
|
#!/bin/sh
|
2018-07-15 21:55:35 +02:00
|
|
|
set -e
|
2017-06-23 10:17:08 +02:00
|
|
|
|
2017-12-04 17:48:37 +01:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/basic
|
2017-06-25 20:49:10 +02:00
|
|
|
|
2017-12-18 22:16:21 +01:00
|
|
|
# Install packages
|
2018-09-04 21:42:26 +02:00
|
|
|
apk --no-cache add curl bridge e2fsprogs-extra gettext iptables kbd-misc libressl lxc python3 py3-bcrypt py3-cffi py3-dnspython py3-jinja2 py3-requests py3-six py3-werkzeug nginx util-linux
|
2018-09-02 20:59:48 +02:00
|
|
|
if [ ${DEBUG:-0} -eq 1 ]; then
|
|
|
|
# Install some utilities for DEBUG mode
|
|
|
|
apk --no-cache add git file htop less openssh-server openssh-sftp-server
|
|
|
|
fi
|
2017-06-23 11:01:08 +02:00
|
|
|
|
2018-09-02 20:59:48 +02:00
|
|
|
# Copy root profile files and settings for DEBUG mode
|
|
|
|
if [ ${DEBUG:-0} -eq 1 ]; then
|
|
|
|
mkdir -p /root/.config/htop /root/.ssh
|
|
|
|
cp ${SOURCE_DIR}/root/.profile /root/.profile
|
|
|
|
cp ${SOURCE_DIR}/root/.ssh/authorized_keys /root/.ssh/authorized_keys
|
|
|
|
cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc
|
|
|
|
fi
|
2017-06-23 11:01:08 +02:00
|
|
|
|
2017-12-18 22:16:21 +01:00
|
|
|
# Copy boot configuration
|
|
|
|
cp ${SOURCE_DIR}/boot/extlinux.conf /boot/extlinux.conf
|
2018-09-03 16:06:56 +02:00
|
|
|
cp ${SOURCE_DIR}/boot/vm.txt /boot/vm.txt
|
2017-12-18 22:16:21 +01:00
|
|
|
cp ${SOURCE_DIR}/etc/inittab /etc/inittab
|
2018-09-01 15:16:22 +02:00
|
|
|
cp ${SOURCE_DIR}/sbin/extend-disk /sbin/extend-disk
|
2018-09-03 17:24:48 +02:00
|
|
|
cp ${SOURCE_DIR}/sbin/vmtty /sbin/vmtty
|
2018-03-25 22:47:19 +02:00
|
|
|
>/etc/motd
|
2017-06-25 20:49:10 +02:00
|
|
|
|
2017-12-18 22:16:21 +01:00
|
|
|
# Enable support for Czech characters
|
|
|
|
cp ${SOURCE_DIR}/etc/rc.conf /etc/rc.conf
|
|
|
|
cp ${SOURCE_DIR}/etc/conf.d/consolefont /etc/conf.d/consolefont
|
2017-09-18 23:04:16 +02:00
|
|
|
|
2018-02-06 16:59:00 +01:00
|
|
|
# Configure NTP client
|
|
|
|
cp ${SOURCE_DIR}/etc/conf.d/ntpd /etc/conf.d/ntpd
|
|
|
|
|
2018-09-04 21:42:26 +02:00
|
|
|
# Configure networking
|
|
|
|
cp ${SOURCE_DIR}/etc/conf.d/iptables /etc/conf.d/iptables
|
|
|
|
cp ${SOURCE_DIR}/etc/iptables/rules-save /etc/iptables/rules-save
|
|
|
|
cp ${SOURCE_DIR}/etc/network/interfaces /etc/network/interfaces
|
|
|
|
service networking restart
|
|
|
|
service iptables restart
|
|
|
|
echo -e "172.17.0.1 host\n172.17.0.1 postfix" >>/etc/hosts
|
|
|
|
|
2018-04-29 20:48:57 +02:00
|
|
|
# Download and configure acme.sh
|
|
|
|
mkdir /etc/acme.sh.d
|
|
|
|
wget https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh -O /usr/bin/acme.sh
|
|
|
|
sed -i 's|$HOME/.$PROJECT_NAME|/etc/acme.sh.d|' /usr/bin/acme.sh
|
2018-08-30 20:09:18 +02:00
|
|
|
chmod +x /usr/bin/acme.sh
|
2018-04-29 20:48:57 +02:00
|
|
|
|
2018-09-04 21:42:26 +02:00
|
|
|
# Copy VMMgr resources
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/vmmgr /etc/init.d/vmmgr
|
2018-08-23 10:44:45 +02:00
|
|
|
rc-update -u
|
2018-09-03 17:24:48 +02:00
|
|
|
cp -r ${SOURCE_DIR}/srv/vm /srv/vm
|
2018-09-04 21:42:26 +02:00
|
|
|
ln -s /srv/vm/cli.py /usr/bin/vmmgr
|
2017-12-04 21:51:48 +01:00
|
|
|
|
2018-09-03 15:57:47 +02:00
|
|
|
# Create a self-signed certificate
|
2018-09-04 21:42:26 +02:00
|
|
|
vmmgr create-selfsigned
|
2018-09-03 15:57:47 +02:00
|
|
|
|
|
|
|
# Configure nginx
|
|
|
|
cp ${SOURCE_DIR}/etc/nginx/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
|
2017-12-18 22:16:21 +01:00
|
|
|
# Configure services
|
2018-09-04 22:13:08 +02:00
|
|
|
for SERVICE in consolefont crond nginx ntpd lxc sshd swap vmmgr; do
|
2017-12-18 22:16:21 +01:00
|
|
|
rc-update add ${SERVICE} boot
|
|
|
|
service ${SERVICE} start
|
|
|
|
done
|
2018-03-24 14:51:13 +01:00
|
|
|
|
2018-08-02 10:41:40 +02:00
|
|
|
# Set dummy host and generate related files
|
2018-09-04 21:42:26 +02:00
|
|
|
vmmgr update-host spotter.vm 443
|