blob: 664bbccb817a78c2850f036950a5a0b4929cfda6 (
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
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
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: x-display-manager tdm
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: console-screen kbd acpid hal krb5-kdc ypbind
# Should-Stop: console-screen kbd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: X display manager for Trinity
# Description: TDM manages a collection of X servers, which may be on the local host or remote machines.
### END INIT INFO
# /etc/init.d/tdm: start or stop the X display manager
# Script originally stolen from the xdm package
#
# description: Trinity Display Manager
#
. /lib/lsb/init-functions
set -e
# To start tdm even if it is not the default display manager, change
# HEED_DEFAULT_DISPLAY_MANAGER to "false."
HEED_DEFAULT_DISPLAY_MANAGER=true
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
TDEDIRS=/opt/trinity/
PATH=/opt/trinity/bin:/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/opt/trinity/bin/tdm
PIDFILE=/var/run/tdm.pid
UPGRADEFILE=/var/run/tdm.upgrade
# parameters to support tdm customization
TDMRC=/etc/trinity/tdm/tdmrc
BACKGROUNDRC=/etc/trinity/tdm/backgroundrc
#if configuration is changed by tdmtheme or other tools, don't do magick
if grep -q "Theme=@@@ToBeReplacedByDesktopBase@@@" ${TDMRC} && grep -q "Wallpaper=default_blue.jpg" ${BACKGROUNDRC}
then
TDMOVERRIDEDIR=/etc/default/tdm-trinity.d
TDMCFGDIR=/var/run/tdm-trinity
TDMCFG=$TDMCFGDIR/tdmrc
BACKGROUNDCFG=$TDMCFGDIR/backgroundrc
test -x $DAEMON || exit 0
# uncomment, if you want auto-logon to be runlevel-dependant
#test "$runlevel" || { runlevel=`runlevel`; runlevel=${runlevel#* }; }
#test "$runlevel" = 4 && ARG=-autolog || ARG=-noautolog
# uncomment, if you want tons of debug info in your syslog
#ARG="$ARG -debug 255"
# we use an alternative tdm master configuration file
ARG="$ARG -config $TDMCFG"
# we source overrides. run-parts sorts the list in a predictable order
if [ -d "$TDMOVERRIDEDIR" ]; then
for part in $(run-parts --list "$TDMOVERRIDEDIR" 2>/dev/null || true); do
. "$part"
done
fi
# we generate tdm configuration files
gentdmconf --in $TDMCFGDIR 1> /dev/null
# we update tdm configuration files (only overridden values)
[ -n "$USEBACKGROUND" ] && sed -i "s|^#\?UseBackground=.*|UseBackground=$USEBACKGROUND|" $TDMCFG
[ -n "$BACKGROUNDCFG" ] && sed -i "s|^#\?BackgroundCfg=.*|BackgroundCfg=$BACKGROUNDCFG|" $TDMCFG
[ -n "$USETHEME" ] && sed -i "s|^#\?UseTheme=.*|UseTheme=$USETHEME|" $TDMCFG
[ -n "$THEME" ] && sed -i "s|^#\?Theme=.*|Theme=$THEME|" $TDMCFG
[ -n "$COMPOSITOR" ] && sed -i "s|^#\?Compositor=.*|Compositor=$COMPOSITOR|" $TDMCFG
[ -n "$WALLPAPER" ] && sed -i "s|^#\?Wallpaper=.*|Wallpaper=`readlink -f $WALLPAPER`|" $BACKGROUNDCFG
fi
# autologin overrides are useful for live debian environment
if [ -n "$AUTOLOGINUSER" ]; then
sed -i "s|^#\?AutoLoginEnable=.*|AutoLoginEnable=true|" $TDMCFG
sed -i "s|^#\?AutoLoginUser=.*|AutoLoginUser=$AUTOLOGINUSER|" $TDMCFG
fi
[ -n "$AUTOLOGINDELAY" ] && sed -i "s|^#\?AutoLoginDelay=.*|AutoLoginDelay=$AUTOLOGINDELAY|" $TDMCFG
[ -n "$AUTOLOGINAGAIN" ] && sed -i "s|^#\?AutoLoginAgain=.*|AutoLoginAgain=$AUTOLOGINAGAIN|" $TDMCFG
[ -n "$AUTOLOGINLOCKED" ] && sed -i "s|^#\?AutoLoginLocked=.*|AutoLoginLocked=$AUTOLOGINLOCKED|" $TDMCFG
# If we upgraded the daemon, we can't use the --exec argument to
# start-stop-daemon since the inode will have changed. The risk here is that
# in a situation where the daemon died, its pidfile was not cleaned up, and
# some other process is now running under that pid, start-stop-daemon will send
# signals to an innocent process. However, this seems like a corner case.
# C'est la vie!
if [ -e $UPGRADEFILE ]; then
SSD_ARGS="--pidfile $PIDFILE --startas $DAEMON"
else
SSD_ARGS="--pidfile $PIDFILE --exec $DAEMON"
fi
stillrunning () {
if expr "$(cat /proc/$DAEMONPID/cmdline 2> /dev/null)" : "$DAEMON" > /dev/null 2>&1; then
true
else
# if the daemon does not remove its own pidfile, we will
rm -f $PIDFILE $UPGRADEFILE
false
fi;
}
case "$1" in
start)
if [ -e $DEFAULT_DISPLAY_MANAGER_FILE ] &&
[ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] &&
[ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "$DAEMON" ]; then
log_warning_msg "Not starting Trinity Display Manager (tdm); it is not the default display manager."
log_action_end_msg 0
else
log_action_begin_msg "Starting Trinity Display Manager: tdm"
if start-stop-daemon --start --quiet $SSD_ARGS -- $ARG; then
log_action_end_msg 0
else
log_action_end_msg 0
log_warning_msg "Trinity Display Manager (tdm) already running"
fi
fi
;;
restart)
/etc/init.d/tdm stop
if [ -f $PIDFILE ]; then
if stillrunning; then
exit 1
fi
fi
/etc/init.d/tdm start
;;
reload)
log_action_begin_msg "Reloading Trinity Display Manager configuration..."
if start-stop-daemon --stop --signal 1 --quiet $SSD_ARGS; then
log_action_end_msg 0
else
log_action_end_msg 1
log_failure_msg "tdm not running."
fi
;;
force-reload)
/etc/init.d/tdm reload
;;
stop)
log_action_begin_msg "Stopping Trinity Display Manager: tdm"
if [ ! -f $PIDFILE ]; then
log_action_end_msg 0
log_failure_msg "Trinity Display Manager (tdm) not running ($PIDFILE not found)."
exit 0
else
DAEMONPID=$(cat $PIDFILE | tr -d '[:blank:]')
KILLCOUNT=1
if [ ! -e $UPGRADEFILE ]; then
if start-stop-daemon --stop --quiet $SSD_ARGS; then
# give tdm's signal handler a second to catch its breath
sleep 1
else
log_action_end_msg 0
log_failure_msg "Trinity Display Manager (tdm) not running"
fi
fi
while [ $KILLCOUNT -le 5 ]; do
if stillrunning; then
kill $DAEMONPID
else
break
fi
sleep 1
KILLCOUNT=$(( $KILLCOUNT + 1 ))
done
if stillrunning; then
log_action_end_msg 1
log_failure_msg "Trinity Display Manager (tdm) not responding to TERM signal (pid $DAEMONPID)"
else
rm -f $UPGRADEFILE
fi
fi
log_action_end_msg 0
# Launches usplash on shutdown
if ( `grep -q '\( \|^\)splash\( \|$\)' /proc/cmdline` && `which usplash_down >/dev/null` ) ; then
usplash_down
fi
;;
*)
echo "Usage: /etc/init.d/tdm {start|stop|restart|reload|force-reload}"
exit 1
;;
esac
exit 0
|