Jump to content

chkconfig script for debian


Leon

Recommended Posts

  • Administrators

This script works like chkconfig, but uses update-rc.d in the background for adding and removing system services on a Debian system. I hope some users like this! :)

 

 

 

#!/bin/sh 
# Description: This script works like chkconfig, but uses update-rc.d in 
# the background for adding and removing system services on a Debian system. 
# 
# Examples: 
# chkconfig --add name_of_the_service 
# chkconfig --del name_of_the_service 
# 
# Not working: chkconfig 2345 80 20 
# For using this on your own system add a file called 'chkconfig' with 
# this content in the /sbin/ folder on your harddrive and 
# run once this command: chmod +x /sbin/chkconfig 
# Variables

SERVICE=$2

# Functions
add() {
       if [[ `ls -a /etc/init.d/ | grep -e "^$SERVICE$"` ]]
       then
               echo -n "Adding service: $SERVICE"
               echo
               /usr/sbin/update-rc.d $SERVICE defaults
       else
               echo -n "File /etc/init.d/$SERVICE not found."
               echo
       fi
}

delete() {
       if [[ `ls -a /etc/init.d/ | grep -e "^$SERVICE$"` ]]
       then
               echo -n "Removing service: $SERVICE"
               echo
               /usr/sbin/update-rc.d -f $SERVICE remove
       else
               echo -n "Error removing: service does not exist."
               echo
       fi
}

# Exactly two parameters required
if [[ $# != 2 ]]
then
       echo -n "Usage: $0 {--add|--del} name_of_the_service"
       echo
       exit 1
fi

# Check the command line for actions
case "$1" in
       "--add")
               add
               ;;
       "--del")
               delete
               ;;
       *)
               echo -n "Usage: $0 {--add|--del} name_of_the_service"
               echo
               exit 1
esac

exit 0

esac exit 0 

 

 

Should make life easier for some hardworking debian admins out there... enjoy! :)

 

//Leon

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...