Spotter-VM/basic.sh

73 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/sh
set -e
2017-06-23 10:17:08 +02:00
SOURCE_DIR=$(realpath $(dirname "${0}"))/basic
# Install packages
apk --no-cache add curl docker e2fsprogs-extra gettext kbd-misc libressl python3 py3-bcrypt py3-cffi py3-dnspython py3-jinja2 py3-requests py3-six py3-werkzeug nginx util-linux
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
# 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
# Copy boot configuration
cp ${SOURCE_DIR}/boot/extlinux.conf /boot/extlinux.conf
2018-01-28 10:29:14 +01:00
cp ${SOURCE_DIR}/boot/spotter.txt /boot/spotter.txt
cp ${SOURCE_DIR}/etc/inittab /etc/inittab
cp ${SOURCE_DIR}/sbin/extend-disk /sbin/extend-disk
cp ${SOURCE_DIR}/sbin/spotty /sbin/spotty
>/etc/motd
# 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
# Configure NTP client
cp ${SOURCE_DIR}/etc/conf.d/ntpd /etc/conf.d/ntpd
# Create a self-signed certificate
mkdir /etc/ssl/private
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 7305 -subj "/CN=spotter.vm"
chmod 640 /etc/ssl/private/services.key
# Configure nginx
2017-12-19 10:09:33 +01:00
cp ${SOURCE_DIR}/etc/nginx/nginx.conf /etc/nginx/nginx.conf
2017-09-20 14:15: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
# Copy Spotter AppMgr resources
cp ${SOURCE_DIR}/etc/init.d/spotter-appmgr /etc/init.d/spotter-appmgr
rc-update -u
2018-08-02 10:41:40 +02:00
cp -r ${SOURCE_DIR}/srv/spotter /srv/spotter
ln -s /srv/spotter/cli.py /usr/bin/spotter-appmgr
# Configure services
for SERVICE in consolefont crond nginx ntpd sshd spotter-appmgr swap; do
rc-update add ${SERVICE} boot
service ${SERVICE} start
done
# Configure Docker service
cp ${SOURCE_DIR}/etc/init.d/docker /etc/init.d/docker
rc-update -u
2018-03-24 10:24:18 +01:00
rc-update add docker
service docker start
# Create basic images
docker build -t alpine ${SOURCE_DIR}
2018-08-02 10:41:40 +02:00
# Set dummy host and generate related files
spotter-appmgr update-host spotter.vm 443