Jump to content

chkconfig script for debian


Leon
 Share

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...