LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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



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 7 12-19-2015 01:03 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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration