LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 09-06-2004, 11:43 PM   #1
arobinson74
Member
 
Registered: Nov 2002
Location: Lone Tree, CO
Distribution: Xubuntu Gutsy
Posts: 174

Rep: Reputation: 30
Simple "service" script for dealing with rc files


For those that got used to using the service script in RedHat (or another distribution) here is a very simple script. It will not run scripts without execute permissions (change the last line if you want to change this behavior).

Code:
#!/bin/sh
# Helper script for managin rc scripts

USAGE="Usage: `basename $0` service [start|stop|restart|status]"
VERSION="`basename $0` Version 0.1"
DIR=/etc/rc.d
PREFIX=rc.

if [ $# -eq 0 ]; then
        echo "$USAGE" >$2
        exit 1
fi

case "$1" in
        --help | -h | --h*)
                echo "$USAGE" >&2
                exit 0
                ;;
        --version | -v | -V)
                echo "$VERSION" >&2
                exit 0
                ;;
        0 | 4 | 6 | K | M | S | rc.0 | rc.4 | rc.6 | rc.K | rc.M | rc.S)
                echo "Invalid service" >&2
                echo "$USAGE" >&2
                exit 1
                ;;
esac

case "$2" in
        status|start|restart|stop)
                ;;
        *)
                echo "$USAGE" >&2
                exit 1
esac

if [ -f $DIR/$1 ]; then
        SERVICE=$DIR/$1
elif [ -f $DIR/${PREFIX}${1} ]; then
        SERVICE=$DIR/${PREFIX}${1}
else
        echo "Service '$1' could not be found" >&2
        echo "$USAGE" >&2
        exit 1
fi

$SERVICE $2
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 10:35 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
Priority: script to run on boot vs. "service iptables save" iheardrain Linux - General 5 09-30-2004 09:53 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM
After 5 months I quit dealing with Winliux "lifetime support" R2RO Linux - Software 2 01-24-2002 07:14 PM


All times are GMT -5. The time now is 05:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration