summaryrefslogtreecommitdiffstats
path: root/data/install_server.sh
blob: 2ad13574f0ff65f5b7267b2818bb677150917f0f (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
#!/bin/sh

if [ $# -lt 1 ]; then
	echo "Usage: $0 <this server's ip>"
	exit 1
fi
SERVER_IP="$1"

TOOLS="git squashfs-tools rsync lighttpd tftpd gcc binutils make nasm"

for tool in $TOOLS; do
	echo " ###### Installiere $tool ##########"
	apt-get install -y $tool
done

# lighttpd konfigurieren
# konfig: www-root = /srv/openslx/www

# damit es keinen Ärger wg. noch nicht vorhandenem docroot gibt
echo "Konfiguriere lighttpd ..."
echo "Stoppe installierten lighttpd ..."
/etc/init.d/lighttpd stop
ERR=$?
if [ "$ERR" -gt 0 ]; then
	echo "Konnte lighttpd nicht anhalten - Abbruch!"
	exit 1
fi

# lighttpd-Konfiguration patchen

echo "Passe lighttpd-Konfiguration an ..."
cp -p /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte alte lighttpd-Konfiguration nicht sichern - Abbruch!"
        exit 1
fi

cat /etc/lighttpd/lighttpd.conf|sed 's/\/var\/www/\/srv\/openslx\/www/g'>/etc/lighttpd/lighttpd.conf.tmp
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte lighttpd-Konfiguration nicht patchen - Abbruch!"
        exit 1
fi

mv  /etc/lighttpd/lighttpd.conf.tmp  /etc/lighttpd/lighttpd.conf
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte neue lighttpd-Konfiguration nicht speichern - Abbruch!"
        exit 1
fi

# neues docroot (/srv/openslx/www) prüfen und ggf. erzeugen - ggf. altes docroot löschen?
echo "Prüfe docroot für lighttpd (/srv/openslx/www) ..."
if [ ! -d /srv/openslx/www ] ; then
	echo "Erzeuge neues docroot für lighttpd (/srv/openslx/www) ..."
	mkdir -p  /srv/openslx/www
	ERR=$?
	if [ "$ERR" -gt 0 ]; then
        	echo "Konnte kein lighttpd-docroot-Verzeichnis erstellen - Abbruch!"
	        exit 1
	fi
fi

# ... und lighttpd wieder hochziehen:
echo "Starte installierten lighttpd ..."
/etc/init.d/lighttpd start
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte lighttpd nicht starten - Abbruch!"
        exit 1
fi

# tftpd konfigurieren
# tftp root = /srv/openslx/tftp

echo "Konfiguriere tftpd ..."
# neues docroot (/srv/openslx/tftp) prüfen und ggf. erzeugen - ggf. altes docroot löschen?
echo "Prüfe docroot für tftpd (/srv/openslx/tftp) ..."
if [ ! -d /srv/openslx/tftp ] ; then
        echo "Erzeuge neues docroot für tftpf (/srv/openslx/tftp) ..."
        mkdir -p  /srv/openslx/tftp
        ERR=$?
        if [ "$ERR" -gt 0 ]; then
                echo "Konnte kein tftpd-docroot-Verzeichnis erstellen - Abbruch!"
                exit 1
        fi
fi

echo "Halte xinetd an ..."
# Erstmal xinetd (kam mit tftpd) anhalten
/etc/init.d/xinetd stop		# besser wäre zB service xinetd stop, aber wg. Kompatibilität
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte xinetd nicht anhalten - Abbruch!"
        exit 1
fi

# tftpd-Konfiguration einschreiben
cat>/etc/xinetd.d/tftp<<HEREEND		# 
service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /srv/openslx/tftp
disable         = no
}
HEREEND

echo "starte xinetd ..."
/etc/init.d/xinetd start
ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Konnte xinetd nicht starten - Abbruch!"
        exit 1
fi

echo " ##### Klone das mltk repository ########"

mkdir -p /opt/openslx
cd /opt/openslx

git clone git://git.openslx.org/openslx-ng/tm-scripts

echo " ##### Setup iPXE #######"

mkdir -p /opt/ipxe
cd /opt/ipxe
git clone git://git.ipxe.org/ipxe.git

cd ipxe

# iPXE-Konfiguration einschreiben
cat > ipxelinux.ipxe << HEREEND
#!ipxe
set use-cached 1
dhcp net0
set net0.dhcp/next-server $SERVER_IP
set net0.dhcp/filename ipxelinux.0
imgload pxelinux.0
boot pxelinux.0
HEREEND

cd src
make bin/undionly.kkkpxe EMBED=../ipxelinux.ipxe,/opt/openslx/tm-scripts/data/pxelinux.0

ERR=$?
if [ "$ERR" -gt 0 ]; then
        echo "Fehler beim kompilieren von ipxelinux.0 - Abbruch!"
        exit 1
fi

cp "ipxelinux.0" "/srv/openslx/tftp/"

echo "....Fertig"
echo "mltk liegt nun im Verzeichnis /opt/openslx/tm-scripts"
echo "Extrahieren und Erstellen der Basissystemdaten:"
echo "./mltk remote stage31 -b"
echo "./mltk remote stage32 -b"
echo "Verpacken der Daten als initramfs:"
echo "./mltk server local stage31 -e stage31"
echo "./mltk server local stage32 -e stage32"
echo "."