summaryrefslogtreecommitdiff
path: root/bin/diskless-workstation-shell
blob: 296ab27c9df54a0af41f8013ea72a2f14396c140 (plain)
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
#!/bin/bash

# Copyright (C) 2011 by Mike Gabriel <mike.gabriel@it-zukunft-schule.de>

# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

set -e

VERSION=0.1
DLW_SHELL="bash"
CHROOT="/srv/ltsp/i386/"

test -e "$CHROOT" || { 
    echo "ERROR: Diskless workstation chroot does not exist at $CHROOT."
    exit -1
}

[ "x$USER" == "xroot" ] || { 
    echo "ERROR: Diskless workstation management has to be performed as root." 
    exit -2
}

cat > "$CHROOT/dlw_shell.sh" <<EOF
#!/bin/bash
mount -tproc proc /proc &> /dev/null
mount /dev/pts &> /dev/null
export HOME=/root
export LTSP_HANDLE_DAEMONS="false"

# export the proxy server (if any) to the shell.
export http_proxy=http://webcache.intern:3128
export https_proxy=http://webcache.intern:3128
export ftp_proxy=http://webcache.intern:3128

echo 'This shell has been started in your Diskless Workstation chroot environment.'
echo 'All changes performed here will take effect on your Diskless Workstations'
echo 'after their next (re)boot. So be careful!!!'
echo
echo "To return from this chroot shell hit STRG+D or type ,,exit'' on the"
echo 'command line...'
echo
echo 'Note: Service restarts have been disabled in Diskless Workstation chroot'
echo 'during maintenance work.'
echo

# disable service restarts
#test -e /sbin/start-stop-daemon.keep || mv /sbin/start-stop-daemon /sbin/start-stop-daemon.keep
#echo '#!/bin/sh' > /sbin/start-stop-daemon
#echo 'exit 0' >> /sbin/start-stop-daemon
#chmod +x /sbin/start-stop-daemon

/bin/$DLW_SHELL

# restore start-stop-daemon
#[ \$(stat --format '%s' /sbin/start-stop-daemon) -lt 200 ] && mv /sbin/start-stop-daemon.keep /sbin/start-stop-daemon

umount -l /proc &> /dev/null
umount -l /dev/pts &> /dev/null

echo
echo "Diskless Workstation Shell has exited."
echo
EOF
chmod u+x "$CHROOT/dlw_shell.sh"
chroot "$CHROOT" /dlw_shell.sh