Lines 2-7
Link Here
|
2 |
# Copyright 1999-2020 Gentoo Authors |
2 |
# Copyright 1999-2020 Gentoo Authors |
3 |
# Distributed under the terms of the GNU General Public License, v2 |
3 |
# Distributed under the terms of the GNU General Public License, v2 |
4 |
|
4 |
|
|
|
5 |
retry="TERM/5/TERM/5" |
5 |
# This is here to serve as a note to myself, and future developers. |
6 |
# This is here to serve as a note to myself, and future developers. |
6 |
# |
7 |
# |
7 |
# Any Display manager (gdm,kdm,xdm) has the following problem: if |
8 |
# Any Display manager (gdm,kdm,xdm) has the following problem: if |
Lines 59-141
setup_dm() {
Link Here
|
59 |
local MY_XDM |
60 |
local MY_XDM |
60 |
|
61 |
|
61 |
MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]') |
62 |
MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]') |
62 |
|
|
|
63 |
NAME= |
64 |
case "${MY_XDM}" in |
63 |
case "${MY_XDM}" in |
65 |
kdm|kde) |
64 |
kdm|kde) |
66 |
# Load our root path from profile.env |
65 |
command=/usr/bin/kdm |
67 |
# Needed for kdm |
66 |
pidfile=/run/kdm.pid |
68 |
PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}") |
|
|
69 |
EXE=/usr/bin/kdm |
70 |
PIDFILE=/run/kdm.pid |
71 |
;; |
67 |
;; |
72 |
entrance*) |
68 |
entrance*) |
73 |
EXE=/usr/sbin/entrance |
69 |
command=/usr/sbin/entrance |
74 |
PIDFILE=/run/entrance.pid |
70 |
pidfile=/run/entrance.pid |
75 |
;; |
71 |
;; |
76 |
gdm|gnome) |
72 |
gdm|gnome) |
77 |
# gdm-3 and above has different paths |
73 |
# gdm-3 and above has different paths |
78 |
if [ -f /usr/sbin/gdm ]; then |
74 |
if [ -f /usr/sbin/gdm ]; then |
79 |
EXE=/usr/sbin/gdm |
75 |
command=/usr/sbin/gdm |
80 |
PIDFILE=/run/gdm/gdm.pid |
76 |
pidfile=/run/gdm/gdm.pid |
81 |
START_STOP_ARGS="--background" |
77 |
start_stop_daemon_args="--background" |
82 |
AUTOCLEAN_CGROUP="yes" |
|
|
83 |
else |
78 |
else |
84 |
EXE=/usr/bin/gdm |
79 |
command=/usr/bin/gdm |
85 |
PIDFILE=/run/gdm.pid |
80 |
pidfile=/run/gdm.pid |
86 |
fi |
81 |
fi |
87 |
[ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary |
82 |
[ "${RC_UNAME}" != "Linux" ] && name=gdm-binary |
88 |
;; |
83 |
;; |
89 |
greetd) |
84 |
greetd) |
90 |
EXE=/usr/bin/greetd |
85 |
command=/usr/bin/greetd |
91 |
PIDFILE=/run/greetd.pid |
86 |
command_background=yes |
92 |
START_STOP_ARGS="-m --background" |
87 |
pidfile=/run/greetd.pid |
93 |
;; |
88 |
;; |
94 |
wdm) |
89 |
wdm) |
95 |
EXE=/usr/bin/wdm |
90 |
command=/usr/bin/wdm |
96 |
PIDFILE= |
|
|
97 |
;; |
91 |
;; |
98 |
gpe) |
92 |
gpe) |
99 |
EXE=/usr/bin/gpe-dm |
93 |
command=/usr/bin/gpe-dm |
100 |
PIDFILE=/run/gpe-dm.pid |
94 |
pidfile=/run/gpe-dm.pid |
101 |
;; |
95 |
;; |
102 |
lxdm) |
96 |
lxdm) |
103 |
EXE=/usr/sbin/lxdm-binary |
97 |
command=/usr/sbin/lxdm-binary |
104 |
PIDFILE=/run/lxdm.pid |
98 |
pidfile=/run/lxdm.pid |
105 |
START_STOP_ARGS="--background" |
99 |
start_stop_daemon_args="--background" |
106 |
;; |
100 |
;; |
107 |
lightdm) |
101 |
lightdm) |
108 |
EXE=/usr/sbin/lightdm |
102 |
command=/usr/sbin/lightdm |
109 |
PIDFILE=/run/lightdm.pid |
103 |
pidfile=/run/lightdm.pid |
110 |
START_STOP_ARGS="--background" |
104 |
start_stop_daemon_args="--background" |
111 |
;; |
105 |
;; |
112 |
sddm) |
106 |
sddm) |
113 |
EXE="/usr/bin/sddm" |
107 |
command="/usr/bin/sddm" |
114 |
START_STOP_ARGS="-m --background" |
108 |
command_background=yes |
115 |
PIDFILE=/run/sddm.pid |
109 |
pidfile=/run/sddm.pid |
116 |
;; |
110 |
;; |
117 |
*) |
111 |
*) |
118 |
# first find out if there is such executable |
112 |
# first find out if there is such executable |
119 |
EXE="$(command -v ${MY_XDM} 2>/dev/null)" |
113 |
command="$(command -v ${MY_XDM} 2>/dev/null)" |
120 |
PIDFILE="/run/${MY_XDM}.pid" |
114 |
pidfile="/run/${MY_XDM}.pid" |
121 |
|
115 |
|
122 |
# warn user that they are doing sick things if the exe was not found |
116 |
# warn user that they are doing sick things if the exe was not found |
123 |
if [ -z "${EXE}" ]; then |
117 |
if [ -z "${EXE}" ]; then |
124 |
echo "ERROR: Your XDM value is invalid." |
118 |
eerror "ERROR: Your XDM value is invalid." |
125 |
echo " No ${MY_XDM} executable could be found on your system." |
119 |
eerror " No ${MY_XDM} executable could be found on your system." |
126 |
fi |
120 |
fi |
127 |
;; |
121 |
;; |
128 |
esac |
122 |
esac |
129 |
|
123 |
|
130 |
if ! [ -x "${EXE}" ]; then |
124 |
if ! [ -x "${command}" ]; then |
131 |
EXE=/usr/bin/xdm |
125 |
command=/usr/bin/xdm |
132 |
PIDFILE=/run/xdm.pid |
126 |
pidfile=/run/xdm.pid |
133 |
if ! [ -x "/usr/bin/xdm" ]; then |
127 |
if ! [ -x "/usr/bin/xdm" ]; then |
134 |
echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm," |
128 |
eerror "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm," |
135 |
echo " or install x11-apps/xdm package" |
129 |
eerror " or install the x11-apps/xdm package" |
136 |
eend 255 |
130 |
return 1 |
137 |
fi |
131 |
fi |
138 |
fi |
132 |
fi |
|
|
133 |
return 0 |
139 |
} |
134 |
} |
140 |
|
135 |
|
141 |
# Check to see if something is defined on our VT |
136 |
# Check to see if something is defined on our VT |
Lines 147-194
vtstatic() {
Link Here
|
147 |
else |
142 |
else |
148 |
return 1 |
143 |
return 1 |
149 |
fi |
144 |
fi |
|
|
145 |
return |
150 |
} |
146 |
} |
151 |
|
147 |
|
152 |
start() { |
148 |
start_pre() { |
153 |
local EXE NAME PIDFILE AUTOCLEAN_CGROUP |
149 |
setup_dm || return |
154 |
setup_dm |
|
|
155 |
|
150 |
|
156 |
if [ -f /run/.nogui ]; then |
151 |
if [ -f /run/.nogui ]; then |
157 |
einfo "Skipping ${EXE##*/}, /run/.nogui found or 'nogui' bootparam passed." |
152 |
einfo "Skipping ${command##*/}, /run/.nogui found or 'nogui' bootparam passed." |
158 |
rm /run/.nogui |
153 |
rm /run/.nogui |
159 |
return 0 |
154 |
return 1 |
160 |
fi |
155 |
fi |
161 |
|
156 |
|
162 |
ebegin "Setting up ${EXE##*/}" |
157 |
if vtstatic "${CHECKVT:-7}" ; then |
163 |
|
158 |
if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then |
164 |
# save the prefered DM |
159 |
ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later" |
165 |
save_options "service" "${EXE}" |
160 |
telinit a >/dev/null 2>&1 |
166 |
save_options "name" "${NAME}" |
161 |
return 0 |
167 |
save_options "pidfile" "${PIDFILE}" |
162 |
else |
168 |
save_options "start_stop_args" "${START_STOP_ARGS}" |
163 |
eerror "Something is already defined on VT ${CHECKVT:-7}, not starting" |
169 |
save_options "autoclean_cgroup" "${AUTOCLEAN_CGROUP:-no}" |
164 |
return 1 |
170 |
|
|
|
171 |
if [ -n "${CHECKVT-y}" ] ; then |
172 |
if vtstatic "${CHECKVT:-7}" ; then |
173 |
if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then |
174 |
ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later" |
175 |
telinit a >/dev/null 2>&1 |
176 |
return 0 |
177 |
else |
178 |
eerror "Something is already defined on VT ${CHECKVT:-7}, not starting" |
179 |
return 1 |
180 |
fi |
181 |
fi |
165 |
fi |
182 |
fi |
166 |
fi |
183 |
|
167 |
|
184 |
/usr/bin/startDM |
168 |
return 0 |
185 |
eend 0 |
|
|
186 |
} |
169 |
} |
187 |
|
170 |
|
188 |
stop() { |
171 |
stop_pre() { |
189 |
local curvt retval |
|
|
190 |
|
191 |
retval=0 |
192 |
if [ -t 0 ]; then |
172 |
if [ -t 0 ]; then |
193 |
if type fgconsole >/dev/null 2>&1; then |
173 |
if type fgconsole >/dev/null 2>&1; then |
194 |
curvt=$(fgconsole 2>/dev/null) |
174 |
curvt=$(fgconsole 2>/dev/null) |
Lines 200-223
stop() {
Link Here
|
200 |
esac |
180 |
esac |
201 |
fi |
181 |
fi |
202 |
fi |
182 |
fi |
203 |
local myexe myname mypidfile myservice |
183 |
return |
204 |
myexe=$(get_options "service") |
184 |
} |
205 |
myname=$(get_options "name") |
|
|
206 |
mypidfile=$(get_options "pidfile") |
207 |
myservice=${myexe##*/} |
208 |
yesno "${rc_cgroup_cleanup:-no}" || rc_cgroup_cleanup=$(get_options "autoclean_cgroup") |
209 |
|
210 |
[ -z "${myexe}" ] && return 0 |
211 |
|
212 |
ebegin "Stopping ${myservice}" |
213 |
|
214 |
if start-stop-daemon --quiet --test --stop --exec "${myexe}" 2>/dev/null; then |
215 |
start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \ |
216 |
"${mypidfile:+--pidfile}" "${mypidfile}" \ |
217 |
"${myname:+--name}" "${myname}" |
218 |
retval=${?} |
219 |
fi |
220 |
|
185 |
|
|
|
186 |
stop_post() { |
221 |
# switch back to original vt |
187 |
# switch back to original vt |
222 |
if [ -n "${curvt}" ]; then |
188 |
if [ -n "${curvt}" ]; then |
223 |
if type chvt >/dev/null 2>&1; then |
189 |
if type chvt >/dev/null 2>&1; then |
Lines 226-234
stop() {
Link Here
|
226 |
vidcontrol -s "$((curvt + 1))" |
192 |
vidcontrol -s "$((curvt + 1))" |
227 |
fi |
193 |
fi |
228 |
fi |
194 |
fi |
229 |
|
195 |
return |
230 |
eend ${retval} "Error stopping ${myservice}" |
|
|
231 |
return ${retval} |
232 |
} |
196 |
} |
233 |
|
197 |
|
234 |
# vim: set ts=4 : |
198 |
# vim: set ts=4 : |