summaryrefslogtreecommitdiffstats
path: root/satellit_installer/satellit_installer
blob: c113680b25d81c3c3c5ea27acedfe94aef314a7a (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/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 -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

# until pump is available again:
# 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

add_repos					# Adding repos: backports

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

sudo_config					# Adding sudo config for user taskmanager

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

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

patch_tftpd-hpa_config
copy_tftpd-hpa_service

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

write_tmate_config			# here or elsewhere...

patch_ldapsearch

patch_java

write_apt_config

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

# 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_timesync # cheap HTTP based timesync on boot
install_finalize	# Script for cleaning some stuff after installation

# Remove translation from menu etc., enable required modules
patch_slxadmin_dir

# Check dir and file permissions:
set_directory_permissions

# And set some symbolic links thereafter:
set_links

# Create tables, fill with predefined stuff
install_slxadmin_db

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
end_message

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 "Warte vor Beendigung auf eventuelle Hintergrundprozesse."
echo "iPXE-Kompilationslog wurde nach /tmp/ipxesuccess geschrieben."
wait

exit 0