summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-configurations.inc
diff options
context:
space:
mode:
authorSimon Rettberg2020-12-17 15:08:14 +0100
committerSimon Rettberg2020-12-17 15:08:14 +0100
commitb5c3eb9e01b09367935f558a57633b68a65a1a21 (patch)
treeb6c322f3089192124779b9d7a29c8365eb39533f /satellit_installer/includes/10-configurations.inc
parent[SSPS] slx-cert: Put hostname in SAN too, chromium requires this (diff)
downloadsetup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.tar.gz
setup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.tar.xz
setup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.zip
[SSPS] Refactor static_files: Submodules with tree
Add submodules (aka directories) to static_files, named according to what component they are for. Add function "install_files" to copy the contents of one of those modules to the root directory. This should make the resulting setup more obvious and require less manual copying of files everywhere.
Diffstat (limited to 'satellit_installer/includes/10-configurations.inc')
-rw-r--r--satellit_installer/includes/10-configurations.inc108
1 files changed, 29 insertions, 79 deletions
diff --git a/satellit_installer/includes/10-configurations.inc b/satellit_installer/includes/10-configurations.inc
index 5f9312a..19052dc 100644
--- a/satellit_installer/includes/10-configurations.inc
+++ b/satellit_installer/includes/10-configurations.inc
@@ -1,112 +1,62 @@
-patch_tftpd-hpa_config() {
- echo "# Stopping tftpd-hpa server in case it's not managed by inetd... "
- systemctl stop tftpd-hpa || perror "Failed"
- # No sense in patching, we will drop this little entry.
- echo "# Copying tftpd-hpa configuration... "
- cp -p "$BASEDIR/static_files/tftpd/tftpd-hpa" "/etc/default/tftpd-hpa" || perror "failed"
- echo "# Copying remap file... "
- mkdir -p "/opt/openslx"
- cp -p "$BASEDIR/static_files/tftpd/tftpd-remap" "/opt/openslx/tftpd-remap" || 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... "
+write_tftpd_config() {
+ install_files "tftpd"
+ echo "# Removing any tftpd config from (x)inetd... "
+ # sometimes a tftp stating line remains in /etc/inetd.conf
if [ -f /etc/inetd.conf ]; then
- if [ "$(grep -c "^tftp.*dgram.*udp4" /etc/inetd.conf)" -gt 0 ]; then
- echo -n " found. Deleting... "
+ if grep -q "^tftp.*dgram.*udp4" /etc/inetd.conf; then
+ echo "Deleting /etc/inetd.conf entry for tftpd"
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!"
+ fi
+ for i in /etc/xinetd.d/*; do
+ [ -f "$i" ] || continue
+ grep -q 'service.*tftp' "$i" || continue
+ echo "Deleting $i"
+ rm -f -- "$i"
+ done
}
patch_lighttpd_config() {
local mod file
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."
- mkdir -p /opt/openslx
- cp -a "$BASEDIR/static_files/slx-cert" /opt/openslx/slx-cert || 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)"
+ install_files "lighttpd"
}
patch_php_config() {
- echo -n "# Patching php configuration... "
-
- if [ $(ls -d /etc/php/*/|wc -l) -eq 1 ]; then
- local PHPINIFILE="$(ls -d /etc/php/*/)/cgi/php.ini"
- else
- pwarning "No php ini file dir found - or more than one."
- fi
-
- 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"
+ local PHPINIFILE
+ echo "# Patching php configuration... "
+ # TODO Throw snippet into conf.d/ instead
+ for PHPINIFILE in /etc/php*/cgi/php.ini /etc/php/*/cgi/php.ini; do
+ [ -f "$PHPINIFILE" ] || continue
+ if grep -q -E "^\s*upload_max_filesize" "$PHPINIFILE"; then
+ sed -i -e '/^\s*upload_max_filesize/c\upload_max_filesize = 100M' "$PHPINIFILE" || pwarning "Could not increase PHP upload limit"
else
- echo -n "no upload_max_filesize entry found; appending 100M entry... "
- echo "upload_max_filesize = 100M" >> "$PHPINIFILE"
+ echo "upload_max_filesize = 100M" >> "$PHPINIFILE" || pwarning "Could not increase PHP upload limit"
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"
+ sed -i -e '/^\s*post_max_size/c\post_max_size = 100M' "$PHPINIFILE" || pwarning "Could not increase PHP POST limit"
else
- echo "post_max_size = 100M" >> "$PHPINIFILE" || pwarning "Could not increase PHP upload limit"
+ echo "post_max_size = 100M" >> "$PHPINIFILE" || pwarning "Could not increase PHP POST 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
+ done
}
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."
+ echo "# Patching /etc/exports for NFS and creating directories... "
+ if grep -q "/srv/openslx/nfs" /etc/exports; then
+ echo "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
+ chown dmsd:images /srv/openslx/nfs || perror "Setting owner of /srv/openslx/nfs failed"
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."
-}
-