summaryrefslogblamecommitdiffstats
path: root/satellit_installer/satellit_installer
blob: 1f62a8dd203a0baba08ca6b5308b930c67dc84d0 (plain) (tree)

























                                                                                


                        




                                                                                         












                                                                                                                            
 


                                            
 
                                                   

                                     
 
 

                         
 
                                          
                               
                                            
                   

                         
          


                            
                                                                                    
 
                                                                            





                                                                        
                                                                            
 

                             





                                                                                                

                                                                                            
                                                                                       




                                                                                                        


                                                                                                      

                                                                                   

          


                                                                                         
                                                                                          
 
                   
 

                                                                

                
                
 
                                 
 
                                 
 
                                                                                                                             
                                                                             


                                                                       
 

                                                             


                           
                                     

                                               
 


                                           

                                                                                      

                 



                                                                                       



                       
 

             


                                                                             
              
                                                                           
 

                         


                                   

                                                


                                    


                                                                                      

                                      
           
 

                                                                     
      
#!/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 a Debian 7.x distribution.
# While it may work on any recent Debian-derived distribution this is not
# guaranteed in any way.
#
# If there were any errors in running this script do the following steps to
# re-install:
# 1. Un-outcomment the call to purge_install near the end of this script.
# 2. re-run the script; ignore any errors like "ERROR 1045 (28000): Access
#    denied for user 'root'@'localhost'". This is caused by mysql root password
#    mismatch; it will vanish on the second run. purge_install will uninstall
#    the packages given in PACKAGELIST_SERVER _and_ purge their configuration.
# 3. re-run the script again; then the mysql root password will be set to the
#    queried password entry. Then the mysql databases and users will be deleted.
# 4. Out-comment the call to purge_install and run the script again for a clean
#    install.
# This cumbersome way will be remedied in the future.

echo "#"
echo "# bwSuite Server and environment autoinstaller"
echo "#"

case "$1" in
	"-h" | "--help")
		echo "#"
		echo "# Options: -h or --help    for (this) help,"
		echo "#          -V or --version followed by a mandatory version string."
		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."
		exit
		;;
	"-V" | "--version")
		[ -z "$2" ] && { echo "No version string has been given - exit."; exit 1; }
		export VERSION="$2"
		;;
	*)	echo "# Restarting with --help ..."
		exec $(readlink -f "$0 --help")
		exit 0								# Never reached, but one for the aesthetics!
		;;
esac

# 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 -n "# Sourcing includes: "
for INCLUDE in "$BASEDIR"/includes/*.inc; do
	echo -n "."
	source "$INCLUDE"
done
echo " ok"

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

system_upgrade					# No harm done even if not necessary

install_packages "$PACKAGELIST_SCRIPT"		# Packages needed for 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
[ "${ERR}" -ne 0 ] && exit 1

setup_dhcp					# dhcp: no dhclient but pump

uninstall_packages mpt-status

prerequisites					# config directory, locales

# query_passwords
set_passwords					# only to be used within certain circumstances -
						# see includes/query_user.

set_version_string				# Writing version string for rc.local-script

preset_mysql_root				# so mysqld keeps quiet when installing

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

check_users					# Meet interesting users with uid>=1000 and kill them.
						# user 65534/sync will be ignored.
add_users_groups				# Adding necessary users and groups

import_gpg

sudo_config					# Adding sudo config for user taskmanager

add_mysql_dbs_users				# mysql stuff; adding databases and users
patch_mysql_config				# adding utf8 entries to /etc/mysql/my.cnf

patch_atftpd_config

patch_lighttpd_config "$WWWDIR"		# $1: lighttpd http root

patch_ldapsearch

write_apt_config

install_bwSuite_server "$DMSDDIR"

install_taskmanager "$TASKMANDIR"

unpack_tar_gz "$BASEDIR/static_files/openslx.tar.gz" "-C $OPENSLXDIR"		# $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"
unpack_tar_gz "$BASEDIR/static_files/syslinux4.tar.gz" "-C $TFTPDIR/v4"
unpack_tar_gz "$BASEDIR/static_files/syslinux6.tar.gz" "-C $TFTPDIR/v6"

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

# NFS server configuration:
config_nfs

# Samba configuration: User and share
# This is out-commented, as not needed recently
# setup_samba

# Copying a script to configure a static IP
install_config_static_ip

# Set a cronjob to cron.daily which cleans bwlp-* stuff from /tmp if older than 2 days
# and images from /srv/openslx/nfs/temp
install_tmpdelete

# Sometimes a low device timeout has lead to problems. So we set a rule to increase the
# block device timeout (sd*) from 30 to 180 using an udev rule.
set_vmware_device_timeout

# color prompt, aliases
patch_bashrc
# vim config
patch_vim

setup_logging

# This part drops a script and anchors it's execution within root's .profile:
drop_firstrun_script

install_slxlog
install_finalize	# Script for cleaning some stuff after installation

set_directory_permissions

# Remove translation from menu etc.
patch_slxadmin

tar -z -c -T /dev/null -f /opt/openslx/empty.tgz

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

# Activate 'purge_install' here - but be careful! This is for debugging purposes only!
# purge_install

# cleaning log files, authorized hosts
clean_install
end_message

finalize		# Cleaning script; script will delete itself.

exit 0