summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-configurations.inc
blob: 19052dcf7896de91484d0d8420b67e9b88635de9 (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
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 -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
		fi
	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"
	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
	mkdir -p "$WWWDIR" || perror "Could not create www-dir ($WWWDIR)"
	install_files "lighttpd"
}

patch_php_config() {
	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 "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 POST limit"
		else
			echo "post_max_size = 100M" >> "$PHPINIFILE" || pwarning "Could not increase PHP POST limit"
		fi
	done
}

config_nfs() {
	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
	fi
	mkdir -p /srv/openslx/nfs 2>/dev/null
	chown dmsd:images /srv/openslx/nfs || perror "Setting owner of /srv/openslx/nfs failed"
	chmod 775 /srv/openslx/nfs
}