summaryrefslogblamecommitdiffstats
path: root/satellit_installer/includes/10-configurations.inc
blob: 5b2b3ab9d5f4872c508310de61fe83559c93f6f4 (plain) (tree)
1
2
3
4
5
6
7
8
9
                       
                                                                                
                                                                                           

                                                               
                                                     


                                                                                                                                                     
                                                                                                                     
                                                                 







                                                                                    
            

                                                 

 


                                                                                                          
                                                                                                      
                                                                                                             
                                                                                                   

 
                         
                             
                                                      

                                                                                                              
                                                                   
                  
                                                                               

                                                                                   

                                                                                            
                                                      
 
 

                                                  













                                                                                                           
            

                                                                                                                                                 
          

 








                                                                                                               
                                          

                                  

                    

                                                                                                                                  

 
patch_atftpd_config() {
	echo -n "# Stopping atftpd server in case it's not managed by inetd... "
	[ "$SYSTEMD" ] && systemctl stop atftpd || /etc/init.d/atftpd stop 2>/dev/null 1>&2
	echo "ok."
	# No sense in patching, we will drop this little entry.
	echo -n "# Patching atftpd configuration... "
	echo "USE_INETD=false"	> /etc/default/atftpd
	echo 'OPTIONS="--retry-timeout 1 --maxthread 100 --verbose=5 --no-multicast --bind-address 0.0.0.0 /srv/openslx/tftp"' >> /etc/default/atftpd
	echo "ok."
	# 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_atftpd_service() {
	echo -n "# Copying atftpd service file... "
	cp -p "$BASEDIR/static_files/atftpd.service" /etc/systemd/system && echo "ok." || perror "failed."
	echo -n "# Linking atftpd service file into (/etc/systemd/system/)multi-user.target.wants... "
	ln -s /etc/systemd/system/atftpd.service /etc/systemd/system/multi-user.target.wants/atftpd.service \
		&& echo "ok." || perror "Could not link atftpd service file into multiuser target!"
}

patch_lighttpd_config() {
	service lighttpd stop
	echo -n "# Patching lighttpd configuration..."
	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."
	chmod +x /usr/share/lighttpd/auto-ssl.sh || perror "failed"
	echo "ok."
	cd /etc/lighttpd/conf-enabled || perror "Could not cd to conf-enabled."
	[ ! -h 10-fastcgi.conf ] && ln -s ../conf-available/10-fastcgi.conf
	[ ! -h 15-fastcgi-php.conf ] && ln -s ../conf-available/15-fastcgi-php.conf
	# Increase php threads
	sed -i 's/"PHP_FCGI_CHILDREN.*$/"PHP_FCGI_CHILDREN" => "32",/' "15-fastcgi-php.conf"
	mkdir -p "$1" || perror "Could not create $1."
}

patch_php_config() {
	echo -n "# Patching php configuration... "
	local PHPINIFILE=/etc/php5/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
		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."
}