Linux script start,stop,restart -


can please tell me script does?

#! /bin/sh test –f /usr/bin/sshd || exit 0 case “$1” in     start)             echo –n “starting sshd: sshd”             /usr/sbin/sshd             echo “.”             ;;    stop)            echo –n “stopping sshd: sshd”           kill `cat /var/run/sshd.pid`           echo “.”            ;;    restart)           echo –n “stopping sshd: sshd”           kill `cat /var/run/sshd.pid`           echo “.”           echo –n “starting sshd: sshd”             /usr/sbin/sshd             echo “.”             ;;         *)           echo “usage: /etc/init.d/sshd start|stop|restart”           exit 1           ;;     esac 

i want know part:

#! /bin/sh test –f /usr/bin/sshd || exit 0 case “$1” in     start)             echo –n “starting sshd: sshd”             /usr/sbin/sshd             echo “.”             ;; 

does because other part same! please ;)

which other part same? way script works checks value of $1, first parameter script supplied on command-line. if it's 'start', part after start) executed. if it's 'stop', part after stop) executed. if it's 'restart', part after restart) executed.

line line first part:

#! /bin/sh 

hey, it's shell script! specifically, execute script using sh shell.

test –f /usr/bin/sshd || exit 0 

is there file called /usr/bin/sshd? if not, exit 0 return status.

case “$1” in 

check value of $1, first command-line option.

    start) 

if $1 'start'...

            echo –n “starting sshd: sshd” 

print "starting sshd: sshd".

            /usr/sbin/sshd 

execute /usr/sbin/sshd.

            echo “.” 

print ".".

            ;; 

exit case statement.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -