Magellan Linux

Diff of /trunk/include/mtools.minc

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

revision 19 by niro, Thu Jun 2 21:21:16 2011 UTC revision 29 by niro, Fri Aug 26 22:19:37 2011 UTC
# Line 14  mstartservice() Line 14  mstartservice()
14   return   return
15   fi   fi
16    
17   if [[ -z ${service_exec} ]]   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"
  then  
  case ${service} in  
  *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;  
  *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;  
  *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;  
  *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;  
  *) service_exec="$(which ${service} 2> /dev/null)" ;;  
  esac  
  fi  
18    
19   # add service to default runlevels   # add service to default runlevels
20   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding ${service} to default runlevels ..."   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding ${service} to default runlevels ..."
# Line 58  mstopservice() Line 49  mstopservice()
49   return   return
50   fi   fi
51    
52   if [[ -z ${service_exec} ]]   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"
  then  
  case ${service} in  
  *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;  
  *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;  
  *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;  
  *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;  
  *) service_exec="$(which ${service} 2> /dev/null)" ;;  
  esac  
  fi  
53    
54   # only stop the service if ${service_exec} does not exist   # only stop the service if ${service_exec} does not exist
55   [[ -f ${MROOT}/${service_exec} ]] && return   [[ -f ${MROOT}/${service_exec} ]] && return
# Line 103  mreloadservice() Line 85  mreloadservice()
85   return   return
86   fi   fi
87    
88   if [[ -z ${service_exec} ]]   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"
  then  
  case ${service} in  
  *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;  
  *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;  
  *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;  
  *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;  
  *) service_exec="$(which ${service} 2> /dev/null)" ;;  
  esac  
  fi  
89    
90   # do not stop services on bootstrap or MROOT!=/   # do not stop services on bootstrap or MROOT!=/
91   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
# Line 125  mreloadservice() Line 98  mreloadservice()
98   fi   fi
99  }  }
100    
   
101  # adds systemd units to runlevels and starts them  # adds systemd units to runlevels and starts them
102  # mstartunit service {/path/to/service_exec}  # mstartunit service {/path/to/service_exec}
103  mstartunit()  mstartunit()
# Line 149  mstartunit() Line 121  mstartunit()
121   return   return
122   fi   fi
123    
124   [[ -z ${service_exec} ]] && service_exec="$(which ${service})"   if [[ -z ${service_exec} ]]
125     then
126     case ${service} in
127     *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;
128     *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;
129     *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;
130     *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;
131     *) service_exec="$(which ${service} 2> /dev/null)" ;;
132     esac
133     fi
134    
135   # add service to default runlevels   # add service to default runlevels
136   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding unit ${service} to default runlevels ..."   echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} adding unit ${service} to default runlevels ..."
# Line 160  mstartunit() Line 141  mstartunit()
141   # do not start services on bootstrap or MROOT!=/   # do not start services on bootstrap or MROOT!=/
142   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
143   then   then
144     echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} starting unit ${service} ..."
145   # start or restart the service   # start or restart the service
146   systemctl try-restart ${service}   # dont use try-restart, works only with active services!
147     systemctl restart ${service}
148   fi   fi
149  }  }
150    
# Line 188  mstopunit() Line 171  mstopunit()
171   return   return
172   fi   fi
173    
174   [[ -z ${service_exec} ]] && service_exec="$(which ${service} 2> /dev/null)"   if [[ -z ${service_exec} ]]
175     then
176     case ${service} in
177     *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;
178     *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;
179     *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;
180     *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;
181     *) service_exec="$(which ${service} 2> /dev/null)" ;;
182     esac
183     fi
184    
185   # only stop the service if ${service_exec} does not exist   # only stop the service if ${service_exec} does not exist
186   [[ -f ${MROOT}/${service_exec} ]] && return   [[ -f ${MROOT}/${service_exec} ]] && return
# Line 202  mstopunit() Line 194  mstopunit()
194   # do not stop services on bootstrap or MROOT!=/   # do not stop services on bootstrap or MROOT!=/
195   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
196   then   then
197     echo -e " ${COLBLUE}[${COLGREEN}+${COLBLUE}]${COLDEFAULT} stopping unit ${service} ..."
198   systemctl stop ${service}   systemctl stop ${service}
199   # try harder   # try harder
200   if [[ -n $(pidof ${service_exec}) ]]   if [[ -n $(pidof ${service_exec}) ]]
# Line 236  mreloadunit() Line 229  mreloadunit()
229   return   return
230   fi   fi
231    
232   [[ -z ${service_exec} ]] && service_exec="$(which ${service} 2> /dev/null)"   if [[ -z ${service_exec} ]]
233     then
234     case ${service} in
235     *.service) service_exec="$(which ${service%%.service} 2> /dev/null)" ;;
236     *.socket) service_exec="$(which ${service%%.socket} 2> /dev/null)" ;;
237     *.mount) service_exec="$(which ${service%%.mount} 2> /dev/null)" ;;
238     *.target) service_exec="$(which ${service%%.target} 2> /dev/null)" ;;
239     *) service_exec="$(which ${service} 2> /dev/null)" ;;
240     esac
241     fi
242    
243     # reload daemon to honor changed unit files
244     systemctl daemon-reload
245    
246   # do not stop services on bootstrap or MROOT!=/   # do not stop services on bootstrap or MROOT!=/
247   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]   if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]

Legend:
Removed from v.19  
changed lines
  Added in v.29