-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize
executable file
·135 lines (103 loc) · 3.7 KB
/
customize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/bash
#
# Put customizations to your image in this file.
KUMQUAT_VERSION='0.1.43'
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# Munin plugins
MUNIN_PLUGINS="
apache_accesses
apache_processes
apache_volume
proftpd
proftpd_bytes
proftpd_count
mysql_queries
mysql_bytes
"
# Exit if any commands fail
set -o errexit
echo "* Use default python 3.5"
pkg_alternatives manual python35
echo "* Configuring image specific packages."
mkdir -p /opt/kumquat
echo "* Download and extract kumquat to /opt/kumquat"
curl -L "https://github.com/jfqd/kumquat/archive/v${KUMQUAT_VERSION}.tar.gz" | gtar xz -C /opt/kumquat --strip-components=1
echo "* Add kumquat user"
groupadd kumquat
useradd -d /opt/kumquat -c "kumquat user" -s /usr/bin/false -g kumquat kumquat
echo "* Setup permissions for kumquat folder"
chown -R kumquat:www /opt/kumquat
echo "* Install missing dependencies via pip"
pip3.5 install Django==1.10.4 django-annoying==0.10.3 django-bootstrap3==7.1.0 django-messagegroups==0.4.5 django-settings-export==1.2.1 free-tls-certificates==0.1.6 passlib==1.7.0
pip3.5 install --no-deps zerorpc==0.6.0
echo "* Create extra ssl folder for kumquat"
mkdir -p /opt/local/etc/kumquat/ssl
echo "* Setup gunicorn"
mkdir -p /opt/local/etc/gunicorn
svccfg import /tmp/gunicorn.xml
echo "* Copy jetty fix for kumquat"
cp /tmp/update_vhosts.py /opt/local/share/httpd/htdocs/index.html
cp /tmp/vhost.conf /opt/kumquat/web/templates/web/vhost.conf
rm /tmp/update_vhosts.py
rm /tmp/vhost.conf
echo "* Setup kumquat backend service"
svccfg import /tmp/kumquat.xml
echo "* Remove unused httpd config files"
HTTPD_CONF_RM="httpd-autoindex.conf
httpd-dav.conf
httpd-default.conf
httpd-info.conf
httpd-languages.conf
httpd-manual.conf
httpd-mpm.conf
httpd-multilang-errordoc.conf
httpd-ssl.conf
httpd-userdir.conf
httpd-vhosts.conf"
for CONF_RM in ${HTTPD_CONF_RM}; do
rm -f /opt/local/etc/httpd/${CONF_RM}
done
echo "* Change www user to /var/www for cronjobs"
usermod -d /var/www www
echo "* Remove unused mysql stuff from base"
rm -rf /var/mysql/*
echo "* Create ssl folder for httpd"
mkdir /opt/local/etc/httpd/ssl
echo "* Remove phpMyAdmin setup folder"
rm -rf /opt/local/share/phpmyadmin/setup
echo "* Copy default index.html"
cp /tmp/default-index.html /opt/local/share/httpd/htdocs/index.html
rm /tmp/default-index.html
echo "* Copy default (basic) kumquat settings"
cp /tmp/kumquat-settings.py /opt/kumquat/kumquat_web/settings.py
rm /tmp/kumquat-settings.py
echo "* Copy default proftpd configuration"
cp /tmp/proftpd.conf /opt/local/etc/proftpd.conf
rm /tmp/proftpd.conf
echo "* Create extra logfile folder for proftpd"
mkdir /var/log/proftpd
echo "* Create extra Let's Encrypt user for user account security"
useradd -c "Lets Encrypt SSL certificate service" -b /var -g kumquat -m letsencrypt
echo "* Create Let's Encrypt folders"
mkdir -p /opt/local/etc/letsencrypt/
mkdir -p /var/letsencrypt/state/
mkdir -p /var/letsencrypt/acme/.well-known/acme-challenge/
touch /var/letsencrypt/acme/.well-known/acme-challenge/.keep
echo "* update Let's Encrypt HOME permissions"
chmod -R 700 /var/letsencrypt/state/
chown -R letsencrypt:kumquat /var/letsencrypt/
echo "* Activate munin plugins"
/opt/qutic/bin/munin-node-plugins ${MUNIN_PLUGINS}
echo "* Setup jetty home"
groupadd -g 1101 jetty
useradd -m -s /usr/bin/bash -d /home/jetty -u 1101 -g jetty jetty
passwd -N jetty
passwd -d jetty
curl -L https://download.qutic.com/src/jetty/jetty-distribution-9.4.11.v20180605.tar.gz > /home/jetty/jetty-distribution-9.4.11.v20180605.tar.gz
cp /tmp/jetty.xml /home/jetty/jetty.xml
rm /tmp/jetty.xml
echo "* Cleanup home/admin because of delegate dataset usage"
rm -rf /home/admin/.[^.]*
echo "* Cleaning up"
rm -rf /root/*
sm-prepare-image -y