summaryrefslogblamecommitdiffstats
path: root/satellit_installer/satellit_installer
blob: 47d4663feb4725da2e815b0d019c817563bc495d (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                             
                                                                               

                                                                           
 


                                                                              
 









                                                                                                   
                                                                                                           












                                                                                                                         
                                    











                                                                                                                                    
                                                                                                   
 


                                            
 
                                                   

                                     
 
 

                         
 
                                          
                          
                                            




                            





                                            

                                                                        
                        
 

                                                                            
 

                             

                                                                           








                                                               
 

                                                     

                                                                                   


                                            

                                                                                         
                  
 
                     
                                                                                                                
 

                

          
                                 
 
                                
 
                                 
 

                               
                                             
                                                                             
                                                                       
 

                                                             


                           
                      
 
                                                    
 

                         
 
                                 
                                                                                     
 


                                         


                                           


                       
                              
                                                
 

                                    
 


                      
                                               
             
 

                                                                            
                      
 

                                                                              
                                                                                                                             
                                                                                                                     
 





                                                                                     
    
            
 
      
#!/bin/bash

# set -x

# This script tries to install a bwLehrpool satellite server in a (hopefully)
# automatic fashion. It is only verified to work on the current Debian release.
# While it may work on any recent Debian-derived distribution using systemd
# this is not guaranteed in any way.
#
# This installer is destructive and not idempotent. Only run on a clean Debian
# install. Take a snapshot/backup before applying this, so you can start
# over in case of failure.

[ -z "$1" ] && exec $(readlink -f "$0 --help")

while [ -n "$1" ]; do
	case "$1" in
		"-h" | "--help")
			echo "#"
			echo "# bwSuite Server and environment autoinstaller"
			echo "#"
			echo "# Options: -h or --help      for (this) help,"
			echo "#          -V or --version   followed by a mandatory version string."
			echo "#          -n or --nodelete  to _not_ delete source code after installation."
			echo "#"
			echo "# Note: A version string must be given!"
			echo "#"
			echo "# If you need to change any predefined values, take a look into includes/00-variables.inc."
			echo "# and set them there."
			echo "#"
			exit
			;;
		"-V" | "--version")
			shift
			export VERSION="$1"
			shift
			;;
		"-n" | "--nodelete")
			NODELETE_SOURCE="true"
			shift
			;;
		*)	echo "# Restarting with --help ..."
			exec $(readlink -f "$0 --help")
			exit 0								# Never reached, but one for the aesthetics!
			;;
	esac
done

# Some version string sanity checks:
[ -z "$VERSION" ] && { echo "No version string has been given - exit."; exit 1; }
[ "${VERSION:0:1}" = '-' ] && { echo "Possibly no version string has been given - exit."; exit 1; }

# Set and save some environmental variables:
OLDUMASK=$(umask)
OLD_DEBIAN_FRONTEND="$DEBIAN_FRONTEND"

# For other variables see includes/00-variables.inc
export SELF="$(readlink -f "$0")"
export BASEDIR="$(dirname "${SELF}")"

#
#	TRAPPING hierhin!
#

# First, to include includes include them:
echo "# Sourcing includes"
for INCLUDE in "$BASEDIR"/includes/*.inc; do
	source "$INCLUDE"
done

####### Main program #######

# No harm done even if not necessary
system_upgrade

# Packages needed for script
install_packages NOREC "$PACKAGELIST_SCRIPT"

# Then, let's download the needed helper files to static_files, as there
# is no sense in commencing if one of these files is missing.
get_files_http || exit 1

# until pump is available again:
# setup_dhcp					# dhcp: no dhclient but pump

uninstall_packages mpt-status

prerequisites					# config directory, locales

# Packages needed for server installable without
# recommended packages, so option NOREC is set.
install_packages NOREC "$PACKAGELIST_SERVER"
# Packages where installation of recommended
# packages is necessary, so opt. RECOM is set.
install_packages RECOM "$PACKAGELIST_WITH_RECOMMENDS"

# We only want this running once the user logged in via ssh/tty
systemctl disable lighttpd.service

kill_existing_users    # delete all users uid >= 1000

add_users_groups				# Adding necessary users and groups

install_ipxe "$IPXEDIR"
compile_ipxe "$IPXEDIR" &>/tmp/ipxesuccess &

add_mysql_dbs_users				# mysql stuff; adding databases and users

write_tftpd_config

patch_lighttpd_config
patch_php_config				# This takes a lot of time, so any background stuff before this.

patch_ldapsearch

patch_java

install_bwSuite_server "$DMSDDIR"

install_dnbd3-server "$DNBD3DIR"

install_taskmanager "$TASKMANDIR"

install_jawol "/usr/local/sbin"

# $1: tar.gz-file, $2: unpacking to directory
unpack_tar_gz "$BASEDIR/static_files/slx-admin.tar.gz" "-C $WWWDIR/slx-admin"
unpack_tar_gz "$BASEDIR/static_files/openslx_tftp.tar.gz" "-C $TFTPDIR"

install_ldadp "$LDADPDIR" || perror "Could not install ldadp"

# NFS server configuration:
config_nfs

install_system_scripts

install_timesync # cheap HTTP based timesync on boot

# enable required modules
enable_slxadmin_modules

# Check dir and file permissions:
set_directory_permissions || perror "Setting up general directory permissions failed"

# And set some symbolic links thereafter:
set_links

# Create tables, fill with predefined stuff
install_slxadmin_db

# color prompt, aliases
patch_bashrc

# Empty tar file for slx-admin
tar -z -c -T /dev/null -f /opt/openslx/empty.tgz

# Mark vmstore as not mounted
touch "/srv/openslx/nfs/.notmounted"

# Write version string
write_versionstring

# cleaning log files, authorized hosts, sources
clean_install

# This part drops a script and anchors it's execution within root's .profile
# Do this at the end so it's not there if something failed
enable_firstrun_script

finalize		# Cleaning script; finalize script will delete itself.

[ "$NODELETE_SOURCE" != "true" ] && { echo "#"; echo "# Deleting source directory..."; rm -rf "$BASEDIR"; echo "# done."; } \
				 || { echo "#"; echo "# Not deleting source directory; nodelete option was given."; }

echo "Power down the VM and the server is ready for distribution."
echo "Do not login again or reboot the VM, as this will already trigger some scripts"
echo "that are supposed to run at the customer's site."
echo ""
echo "Waiting for background processes (ipxe, ...)"
echo "iPXE log will be written to /tmp/ipxesuccess."
wait
echo "Done."

exit 0