blob: 323ed0a4a71910235f9503437fcb0ab15e801788 (
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
|
#!/bin/bash
PS=$(which ps)
GREP=$(which grep)
LOGGER=$(which logger)
MKDIR=$(which mkdir)
MOUNT=$(which mount)
MOUNTDIR=/mnt/diskmount/
SERVICEMOUNT=openslx-mount.service
SERVICEUMOUNT=openslx-umount.service
SERVICERESOLUTION=openslx-resolution.service
# systemd erkennen
case $(${PS} --pid 1 -o comm h) in
systemd) echo "openslx praeinstaller: systemd detected."
if [ -d /etc/systemd/system ]; then
SERVICEDIR=/etc/systemd/system/
else
SERVICEDIR=/usr/lib/systemd/system/
fi
echo "openslx praeinstaller: installing systemd service (mounter) to ${SERVICEDIR}/${SERVICEMOUNT}."
cat <<-HEREDOC > "$SERVICEDIR"/"$SERVICEMOUNT"
[Unit]
Description=openSLX share mounter
After=basic.target
[Service]
Type=oneshot
ExecStartPre=${MKDIR} -p /mnt/diskmount
ExecStartPre=-${MOUNT} /dev/fd1 /mnt/diskmount
ExecStart=${LOGGER} "openslx service file: mounter started."
ExecStart=${MOUNTDIR}/linux/mnt_shares
ExecStart=${LOGGER} "openslx service file: done."
RemainAfterExit=yes
HEREDOC
echo "openslx praeinstaller: installing systemd service (umounter) to ${SERVICEDIR}/${SERVICEUMOUNT}."
cat <<-THEREDOC > "$SERVICEDIR"/"${SERVICEUMOUNT}"
[Unit]
Description=openSLX resolution utility
Before=shutdown.target
[Service]
Type=oneshot
ExecStartPre=${MKDIR} -p /mnt/diskmount
ExecStartPre=-${MOUNT} /dev/fd1 /mnt/diskmount
ExecStart=${LOGGER} "openslx service file: umounter started."
ExecStart=${MOUNTDIR}/linux/umount
ExecStart=${LOGGER} "openslx service file: done."
RemainAfterExit=no
THEREDOC
echo "openslx praeinstaller: installing systemd service (resolution utility) to ${SERVICEDIR}/${SERVICERESOLUTION}."
cat <<-THEREDOC > "$SERVICEDIR"/"${SERVICERESOLUTION}"
[Unit]
Description=openSLX resolution utility
After=display-manager.service
[Service]
Type=oneshot
ExecStartPre=${MKDIR} -p /mnt/diskmount
ExecStartPre=-${MOUNT} /dev/fd1 /mnt/diskmount
ExecStart=${LOGGER} "openslx service file: resolution utility started."
ExecStart=${MOUNTDIR}/linux/resolution
ExecStart=${LOGGER} "openslx service file: done."
RemainAfterExit=yes
THEREDOC
[ ! -d /etc/systemd/system/graphical.target.wants ] && mkdir /etc/systemd/system/graphical.target.wants 2>/dev/null
[ ! -d /etc/systemd/system/basic.target.wants ] && mkdir /etc/systemd/system/basic.target.wants 2>/dev/null
[ ! -d /etc/systemd/system/shutdown.target.wants ] && mkdir /etc/systemd/system/shutdown.target.wants 2>/dev/null
ln -s "${SERVICEDIR}"/"${SERVICEMOUNT}" /etc/systemd/system/graphical.target.wants/"${SERVICEMOUNT}"
ln -s "${SERVICEDIR}"/"${SERVICEUMOUNT}" /etc/systemd/system/shutdown.target.wants/"${SERVICEUMOUNT}"
ln -s "${SERVICEDIR}"/"${SERVICERESOLUTION}" /etc/systemd/system/basic.target.wants/"${SERVICERESOLUTION}"
echo "openslx praeinstaller: doing systemd reload."
systemctl daemon-reload
;;
init) echo "openslx praeinstaller: init(V) detected."
SERVICEDIR=/etc/init.d/
[ ! -d "${SERVICEDIR}" ] && { echo "openslx praeinstaller: No init directory $SERVICEDIR found, exiting."; exit 1; }
SERVICEFILE=openslx-scriptinstall
echo "openslx praeinstaller: installing init service file to ${SERVICEDIR}/${SERVICEFILE}."
cat <<-THEREDOC > "${SERVICEDIR}"/"${SERVICEFILE}"
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: openSLX_scriptinstaller
# Required-Start: 2 3 4 5
# Required-Stop: 0 1 6
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: openSLX script package starter.
### END INIT INFO
#
# Starts via Xsetup patching the openSLX script package
# to correct screen resolution and mount network shares
# when Xsetup is started.
case "\$1" in
start) ${LOGGER} "openslx init file: started."
${MKDIR} -p /mnt/diskmount
${MOUNT} | ${GREP} -q /mnt/diskmount || ${MOUNT} /dev/fd1 /mnt/diskmount
${MOUNTDIR}/linux/vm_runtime
${LOGGER} "openslx init file: done."
;;
stop|restart|force-reload) exit 0 ;;
*) echo "Usage: $0 {start}" >&2; exit 1 ;;
esac
THEREDOC
chmod +x "${SERVICEDIR}"/"${SERVICEFILE}"
echo "openslx praeinstaller: enabling ${SERVICEFILE}."
update-rc.d "${SERVICEFILE}" defaults
;;
*) echo "openslx praeinstaller: Could not determine mother-of-all-processes (not systemd, not init)."
echo "openslx praeinstaller: Giving up, exiting."
exit 1
esac
exit 0
|