Magellan Linux

Diff of /mage/branches/alx07x-unstable/include/mtools.minc

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

revision 2799 by niro, Mon Aug 29 20:14:35 2011 UTC revision 5212 by niro, Mon Dec 16 10:16:23 2013 UTC
# Line 1  Line 1 
1  # $Header: /alx-cvs/mage-eglibc/include/mtools.minc,v 1.1.1.1 2008/03/05 15:10:52 niro Exp $  # dummy include for transitional purposes only
2    #
3    # Will be removed in the near future, please use sysvinit.minc
4    # or systemd.minc directly for new packages.
5    #
6    
 # adds services to runlevels and starts them  
 # mstartservice service {/path/to/service_exec}  
 mstartservice()  
 {  
  local service="$1"  
  local service_exec="$2"  
   
  [[ -z ${service_exec} ]] && service_exec="$(which ${service})"  
   
  # add service to default runlevels  
  echo "Adding ${service} to default runlevels ..."  
  [[ -x ${MROOT}/etc/rc.d/init.d/${service} ]] && rc-config add ${service} &> /dev/null  
   
  # do not start services on bootstrap or MROOT!=/  
  if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]  
  then  
  # start service  
  if [[ -n $(pidof ${service_exec}) ]]  
  then  
  # restart service  
  /etc/init.d/${service} restart  
  else  
  # start service  
  /etc/init.d/${service} start  
  fi  
  fi  
 }  
   
 # removes services from runlevels and stops them  
 # mstopservice service {/path/to/service_exec}  
 mstopservice()  
 {  
  local service="$1"  
  local service_exec="$2"  
   
  [[ -z ${service_exec} ]] && service_exec="$(which ${service})"  
   
  # only stop the service if ${service_exec} does not exist  
  [[ -f ${MROOT}/${service_exec} ]] && return  
   
  # del services from runlevel regardless if they exist or not  
  echo "Removing ${service} from default runlevels ..."  
  rc-config del ${service} &> /dev/null  
   
  # do not stop services on bootstrap or MROOT!=/  
  if [[ ${MAGE_BOOTSTRAP} != true ]] && [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]  
  then  
  # stop service if running  
  if [[ -n $(pidof ${service_exec}) ]]  
  then  
  killall -15 ${service_exec} &> /dev/null  
  sleep 1  
  killall -9 ${service_exec} &> /dev/null  
  fi  
  fi  
 }  
7    minclude sysvinit
8    minclude systemd

Legend:
Removed from v.2799  
changed lines
  Added in v.5212