1 |
# $Header: /magellan-cvs/mage/include/mtools.minc,v 1.3 2008/02/10 12:13:56 niro Exp $ |
# $Id$ |
2 |
|
|
3 |
# adds services to runlevels and starts them |
# adds services to runlevels and starts them |
4 |
# mstartservice service {/path/to/service_exec} |
# mstartservice service {/path/to/service_exec} |
7 |
local service="$1" |
local service="$1" |
8 |
local service_exec="$2" |
local service_exec="$2" |
9 |
|
|
10 |
[[ -z ${service_exec} ]] && service_exec="$(which ${service})" |
# only run if sysV init was found |
11 |
|
if [[ ! -f /etc/rc.d/init.d/functions ]] |
12 |
|
then |
13 |
|
echo "sysV init not found, not adding service ${service} to runlevels!" |
14 |
|
return |
15 |
|
fi |
16 |
|
|
17 |
|
if [[ -z ${service_exec} ]] |
18 |
|
then |
19 |
|
case ${service} in |
20 |
|
*.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;; |
21 |
|
*.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;; |
22 |
|
*.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;; |
23 |
|
*.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;; |
24 |
|
*) service_exec="$(which ${service} 2> /dev/null)" ;; |
25 |
|
esac |
26 |
|
fi |
27 |
|
|
28 |
# add service to default runlevels |
# add service to default runlevels |
29 |
echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding ${service} to default runlevels ..." |
echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding ${service} to default runlevels ..." |
51 |
local service="$1" |
local service="$1" |
52 |
local service_exec="$2" |
local service_exec="$2" |
53 |
|
|
54 |
[[ -z ${service_exec} ]] && service_exec="$(which ${service} 2> /dev/null)" |
# only run if sysV init was found |
55 |
|
if [[ ! -f /etc/rc.d/init.d/functions ]] |
56 |
|
then |
57 |
|
echo "sysV init not found, not adding service ${service} to runlevels!" |
58 |
|
return |
59 |
|
fi |
60 |
|
|
61 |
|
if [[ -z ${service_exec} ]] |
62 |
|
then |
63 |
|
case ${service} in |
64 |
|
*.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;; |
65 |
|
*.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;; |
66 |
|
*.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;; |
67 |
|
*.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;; |
68 |
|
*) service_exec="$(which ${service} 2> /dev/null)" ;; |
69 |
|
esac |
70 |
|
fi |
71 |
|
|
72 |
# only stop the service if ${service_exec} does not exist |
# only stop the service if ${service_exec} does not exist |
73 |
[[ -f ${MROOT}/${service_exec} ]] && return |
[[ -f ${MROOT}/${service_exec} ]] && return |
96 |
local service="$1" |
local service="$1" |
97 |
local service_exec="$2" |
local service_exec="$2" |
98 |
|
|
99 |
[[ -z ${service_exec} ]] && service_exec="$(which ${service} 2> /dev/null)" |
# only run if sysV init was found |
100 |
|
if [[ ! -f /etc/rc.d/init.d/functions ]] |
101 |
|
then |
102 |
|
echo "sysV init not found, not adding service ${service} to runlevels!" |
103 |
|
return |
104 |
|
fi |
105 |
|
|
106 |
|
if [[ -z ${service_exec} ]] |
107 |
|
then |
108 |
|
case ${service} in |
109 |
|
*.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;; |
110 |
|
*.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;; |
111 |
|
*.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;; |
112 |
|
*.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;; |
113 |
|
*) service_exec="$(which ${service} 2> /dev/null)" ;; |
114 |
|
esac |
115 |
|
fi |
116 |
|
|
117 |
# do not stop services on bootstrap or MROOT!=/ |
# do not stop services on bootstrap or MROOT!=/ |
118 |
if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
141 |
fi |
fi |
142 |
|
|
143 |
# we do not support $MROOT atm |
# we do not support $MROOT atm |
144 |
if [[ ${MROOT} != / ]] || [[ ! -z ${MROOT} ]] |
if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]] |
145 |
then |
then |
146 |
echo "\$MROOT is set, doing nothing!" |
echo "\$MROOT is set, doing nothing!" |
147 |
echo "Please add unit ${service} manually to the runlevels!" |
echo "Please add unit ${service} manually to the runlevels!" |
180 |
fi |
fi |
181 |
|
|
182 |
# we do not support $MROOT atm |
# we do not support $MROOT atm |
183 |
if [[ ${MROOT} != / ]] || [[ ! -z ${MROOT} ]] |
if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]] |
184 |
then |
then |
185 |
echo "\$MROOT is set, doing nothing!" |
echo "\$MROOT is set, doing nothing!" |
186 |
echo "Please remove unit ${service} manually from the runlevels!" |
echo "Please remove unit ${service} manually from the runlevels!" |
228 |
fi |
fi |
229 |
|
|
230 |
# we do not support $MROOT atm |
# we do not support $MROOT atm |
231 |
if [[ ${MROOT} != / ]] || [[ ! -z ${MROOT} ]] |
if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]] |
232 |
then |
then |
233 |
echo "\$MROOT is set, doing nothing!" |
echo "\$MROOT is set, doing nothing!" |
234 |
echo "Please remove unit ${service} manually from the runlevels!" |
echo "Please remove unit ${service} manually from the runlevels!" |