Magellan Linux

Diff of /trunk/include/mtools.minc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/magellan-next/include/mtools.minc revision 32 by niro, Tue Dec 13 17:33:23 2011 UTC trunk/include/mtools.minc revision 63 by niro, Wed Oct 9 12:23:06 2013 UTC
# Line 14  mstartservice() Line 14  mstartservice()
14   return   return
15   fi   fi
16    
17     # don't run if feature !autosvc was set
18     if mqueryfeature "!autosvc"
19     then
20     echo "!autosvc detected; auto management of services disabled."
21     return
22     fi
23    
24   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"
25    
26   # add service to default runlevels   # add service to default runlevels
# Line 49  mstopservice() Line 56  mstopservice()
56   return   return
57   fi   fi
58    
59   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"   # don't run if feature !autosvc was set
60     if mqueryfeature "!autosvc"
61     then
62     echo "!autosvc detected; auto management of services disabled."
63     return
64     fi
65    
66     if [[ -z ${service_exec} ]]
67     then
68     service_exec="$(which ${service})"
69     elif [[ x$(basename ${service_exec}) = x${service_exec} ]]
70     then
71     # expand full path
72     service_exec="$(which ${service_exec})"
73     fi
74    
75   # only stop the service if ${service_exec} does not exist   # only stop the service if ${service_exec} does not exist
76   [[ -f ${MROOT}/${service_exec} ]] && return   [[ -x ${MROOT}/${service_exec} ]] && return
77    
78   # del services from runlevel regardless if they exist or not   # del services from runlevel regardless if they exist or not
79   echo -e " ${COLBLUE}[${COLRED}-${COLBLUE}]${COLDEFAULT} removing ${service} from default runlevels ..."   echo -e " ${COLBLUE}[${COLRED}-${COLBLUE}]${COLDEFAULT} removing ${service} from default runlevels ..."
# Line 85  mreloadservice() Line 106  mreloadservice()
106   return   return
107   fi   fi
108    
109     # don't run if feature !autosvc was set
110     if mqueryfeature "!autosvc"
111     then
112     echo "!autosvc detected; auto management of services disabled."
113     return
114     fi
115    
116   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"
117    
118   # do not stop services on bootstrap or MROOT!=/   # do not stop services on bootstrap or MROOT!=/
# Line 105  mstartunit() Line 133  mstartunit()
133   local service="$1"   local service="$1"
134   local service_exec="$2"   local service_exec="$2"
135   local opts   local opts
136     local chroot
137    
138   # only run if systemd was found   # only run if systemd was found
139   if [[ ! -x /bin/systemctl ]]   if [[ ! -x /bin/systemctl ]] && [[ ! -x /usr/bin/systemctl ]]
140   then   then
141   echo "systemd not found, not adding unit ${service} to runlevels!"   echo "systemd not found, not adding unit ${service} to runlevels!"
142   return   return
143   fi   fi
144    
145     # don't run if feature !autosvc was set
146     if mqueryfeature "!autosvc"
147     then
148     echo "!autosvc detected; auto management of services disabled."
149     return
150     fi
151    
152   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]
153   then   then
154   opts="--root ${MROOT}"   # symlinks root path too, not exactly what we want
155     #opts="--root ${MROOT}"
156     if [ -x $(type -P systemd-nspawn) ]
157     then
158     chroot="$(type -P systemd-nspawn)"
159     else
160     chroot="chroot"
161     fi
162   fi   fi
163    
164   if [[ -z ${service_exec} ]]   if [[ -z ${service_exec} ]]
# Line 132  mstartunit() Line 175  mstartunit()
175   # add service to default runlevels   # add service to default runlevels
176   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding unit ${service} to default runlevels ..."   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding unit ${service} to default runlevels ..."
177   # reload daemon to honor changed unit files   # reload daemon to honor changed unit files
178   systemctl ${opts} daemon-reload   if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
179   systemctl ${opts} enable ${service}   then
180     systemctl ${opts} daemon-reload
181     fi
182     ${chroot} systemctl ${opts} enable ${service}
183    
184   # do not start services on bootstrap or MROOT!=/   # do not start services on bootstrap or MROOT!=/
185   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
# Line 154  mstopunit() Line 200  mstopunit()
200   local opts   local opts
201    
202   # only run if systemd was found   # only run if systemd was found
203   if [[ ! -x /bin/systemctl ]]   if [[ ! -x /bin/systemctl ]] && [[ ! -x /usr/bin/systemctl ]]
204   then   then
205   echo "systemd not found, not removing unit ${service} from runlevels!"   echo "systemd not found, not removing unit ${service} from runlevels!"
206   return   return
207   fi   fi
208    
209     # don't run if feature !autosvc was set
210     if mqueryfeature "!autosvc"
211     then
212     echo "!autosvc detected; auto management of services disabled."
213     return
214     fi
215    
216   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]
217   then   then
218   opts="--root ${MROOT}"   opts="--root ${MROOT}"
# Line 174  mstopunit() Line 227  mstopunit()
227   *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;   *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;
228   *) service_exec="$(which ${service} 2> /dev/null)" ;;   *) service_exec="$(which ${service} 2> /dev/null)" ;;
229   esac   esac
230     elif [[ x$(basename ${service_exec}) = x${service_exec} ]]
231     then
232     # expand full path
233     service_exec="$(which ${service_exec})"
234   fi   fi
235    
236   # only stop the service if ${service_exec} does not exist   # only stop the service if ${service_exec} does not exist
237   [[ -f ${MROOT}/${service_exec} ]] && return   [[ -x ${MROOT}/${service_exec} ]] && return
238    
239   # del services from runlevel regardless if they exist or not   # del services from runlevel regardless if they exist or not
240   echo -e " ${COLBLUE}[${COLRED}-${COLBLUE}]${COLDEFAULT} removing unit ${service} from default runlevels ..."   echo -e " ${COLBLUE}[${COLRED}-${COLBLUE}]${COLDEFAULT} removing unit ${service} from default runlevels ..."
# Line 209  mreloadunit() Line 266  mreloadunit()
266   local opts   local opts
267    
268   # only run if systemd was found   # only run if systemd was found
269   if [[ ! -x /bin/systemctl ]]   if [[ ! -x /bin/systemctl ]] && [[ ! -x /usr/bin/systemctl ]]
270   then   then
271   echo "systemd not found, not removing unit ${service} from runlevels!"   echo "systemd not found, not removing unit ${service} from runlevels!"
272   return   return
273   fi   fi
274    
275     # don't run if feature !autosvc was set
276     if mqueryfeature "!autosvc"
277     then
278     echo "!autosvc detected; auto management of services disabled."
279     return
280     fi
281    
282   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]   if [[ ${MROOT} != / ]] && [[ ! -z ${MROOT} ]]
283   then   then
284   opts="--root ${MROOT}"   opts="--root ${MROOT}"

Legend:
Removed from v.32  
changed lines
  Added in v.63