blob: ea2d9fa3a7dbb234078935ce280b1e6559abaa94 (
plain) (
blame)
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
|
patch_tftpd-hpa_config() {
echo -n "# Stopping tftpd-hpa server in case it's not managed by inetd... "
[ "$SYSTEMD" ] && systemctl stop tftpd-hpa || /etc/init.d/tftpd-hpa stop 2>/dev/null 1>&2
echo "ok."
# No sense in patching, we will drop this little entry.
echo "# Patching tftpd-hpa configuration... "
cp -p "$BASEDIR/static_files/tftpd/tftpd-hpa" "/etc/default/tftpd-hpa" || perror "failed"
# sometimes a tftp stating line remains in /etc/inetd.conf. Let's have a look and kill this interesting line:
echo -n "# Checking /etc/inetd.conf for a tftp entry... "
if [ -f /etc/inetd.conf ]; then
if [ "$(grep -c "^tftp.*dgram.*udp4" /etc/inetd.conf)" -gt 0 ]; then
echo -n " found. Deleting... "
sed -i '/^tftp.*dgram.*udp4/d' /etc/inetd.conf
echo " ok."
else
echo " no entry found."
fi
else
echo " no /etc/inetd.conf found."
fi
}
copy_tftpd-hpa_service() {
echo "# Copying tftpd-hpa service file... "
cp -p "$BASEDIR/static_files/tftpd/tftpd-hpa.service" "/etc/systemd/system/tftpd-hpa.service" || perror "failed"
echo -n "# Linking tftpd-hpa service file into (/etc/systemd/system/)multi-user.target.wants... "
ln -s ../tftpd-hpa.service /etc/systemd/system/multi-user.target.wants/tftpd-hpa.service \
&& echo "ok." || perror "Could not link tftpd-hpa service file into multiuser target!"
}
patch_lighttpd_config() {
local mod file
service lighttpd stop
echo "# Customizing lighttpd config"
cp -p "$BASEDIR/static_files/lighttpd.conf" /etc/lighttpd/lighttpd.conf || perror "failed."
cp -p "$BASEDIR/static_files/lighttpd-auto-ssl.sh" /usr/share/lighttpd/auto-ssl.sh || perror "failed."
cp -p "$BASEDIR/static_files/lighttpd-include-conf-d.sh" /usr/share/lighttpd/include-conf-d.sh || perror "failed."
cp -a "$BASEDIR/static_files/patch_lighttpd_phpchildren" /usr/local/sbin/patch_lighttpd_phpchildren || perror "failed."
chmod +x /usr/share/lighttpd/auto-ssl.sh || perror "failed"
chmod +x /usr/share/lighttpd/include-conf-d.sh || perror "failed"
chmod +x /usr/local/sbin/patch_lighttpd_phpchildren || perror "failed"
for mod in fastcgi fastcgi-php; do
file=$(echo /etc/lighttpd/conf-available/??-${mod}.conf) # expand ??
[ -f "$file" ] || perror "Could not find path for $mod"
file=$(basename "$file")
ln -sf "../conf-available/$file" "/etc/lighttpd/conf-enabled/$file" || perror "Could not enable module $mod"
done
# Increase php threads (set dynamically)
mkdir -p /etc/systemd/system/lighttpd.service.d || perror "Could not create /etc/systemd/system/lighttpd.service.d"
cat > "/etc/systemd/system/lighttpd.service.d/10-dynamic_php_children.conf" <<-HDOC
[Service]
ExecStartPre=/usr/local/sbin/patch_lighttpd_phpchildren
HDOC
mkdir -p "$WWWDIR" || perror "Could not create www-dir ($WWWDIR)"
}
patch_php_config() {
echo -n "# Patching php configuration... "
local PHPINIFILE=/etc/php/7.0/cgi/php.ini
if [ -f "$PHPINIFILE" ]; then
grep -E "^\s*upload_max_filesize" "$PHPINIFILE" # 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
echo -n "upload_max_filesize entry found; patching to 100M... "
sed -i.sik -e '/^\s*upload_max_filesize/c\upload_max_filesize = 100M' "$PHPINIFILE"
else
echo -n "no upload_max_filesize entry found; appending 100M entry... "
echo "upload_max_filesize = 100M" >> "$PHPINIFILE"
fi
if grep -q -E '^\s*post_max_size' "$PHPINIFILE"; then
sed -i -e '/^\s*post_max_size/c\post_max_size = 100M' "$PHPINIFILE" || pwarning "Could not increase PHP upload limit"
else
echo "post_max_size = 100M" >> "$PHPINIFILE" || pwarning "Could not increase PHP upload limit"
fi
echo "ok."
service lighttpd reload
else
echo "php ini file (${PHPINIFILE}) not found."
pwarning "Could not patch php ini file. Please check manually and make sure upload_max_filesize is appropriately set (50-100MB)."
fi
}
config_nfs() {
echo -n "# Patching /etc/exports for NFS... "
if [ $(grep -c "/srv/openslx/nfs" /etc/exports) -gt 0 ]; then
echo -n "NFS entry already there; doing nothing."
else
echo '/srv/openslx/nfs *(ro,async,insecure,no_root_squash,no_subtree_check)' >> /etc/exports
echo "ok."
fi
mkdir -p /srv/openslx/nfs 2>/dev/null
chown dmsd:images /srv/openslx/nfs
chmod 775 /srv/openslx/nfs
}
write_apt_config() {
echo -n "# Configuring apt unattended/periodic updates... "
cp "$BASEDIR/static_files/system/apt-upgrade-conf" "/etc/apt/apt.conf.d/02periodic" && echo " done." || pwarning "failed."
}
|