blob: e3a45ecf984d6da87104da8b60ca1a52c11f2c78 (
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
|
#!/bin/ash
# This script gets called by ExecStartPre from the services
# systemd-halt, systemd-poweroff, systemd-reboot. Pre-shutdown actions as
# unmounting nfs shares etc. should go here.
PATH=/bin:/usr/bin:/opt/openslx/bin
# kill leftover processes
umount_nfs_shares() {
for i in "$(mount | grep 'type nfs')"; do
share=$(echo "$i"|cut -f 3 -d " ")
echo "Unmounte nfs-Share $share ...."
umount "$share"
ERROR=$?
if [ $ERROR -eq 0 ]; then
echo "nfs-Share $share unmounted."
else
echo "Could not umount nfs share $share!"
ERRORLEVEL=1
fi
done
}
umount_samba_shares() {
for i in "$(mount | grep 'type cifs')"; do
share=$(echo $i|cut -f 3 -d " ")
echo "Unmounte cifs-Share $share ...."
umount "$share"
ERROR=$?
if [ $ERROR -eq 0 ]; then
echo "cifs-Share $share unmounted."
else
echo "Could not umount cifs share $share!"
ERRORLEVEL=1
fi
done
}
backup_users(){
# create patch files to backup the users created by the openslx, so we can restore then in the next session.
for file in passwd shadow group; do
diff -u /home/openslx/.$file.backup /etc/$file > /home/openslx/.$file.patch
done
echo "Patch of /etc/{passwd,shadow,group} generated at /home/openslx/.{passwd,shadow,group}.patch"
}
# Searching for nfs-shares in mtab:
if [ $(echo /etc/mtab | cut -d " " -f 3 | grep -q nfs) ]; then
umount_nfs_shares
fi
# Searching for samba-shares:
if [ $(echo /etc/mtab|cut -d " " -f 3 | grep -q cifs) ]; then
umount_samba_shares
fi
if [ -d /home/openslx ]; then
backup_users
fi
exit $ERRORLEVEL
|