Skip to content

Instantly share code, notes, and snippets.

@tuklusan
Last active September 29, 2016 16:01
Show Gist options
  • Save tuklusan/7431f723f1104d052aa7545eb08fe8ae to your computer and use it in GitHub Desktop.
Save tuklusan/7431f723f1104d052aa7545eb08fe8ae to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# cowsayd Start/Stop the cowsayd daemon.
#
# chkconfig: 2345 90 60
# description: cowsayd is a minimal telnet server to return a fortune+cowsay cookie and exit
# Supratim Sanyal - supratim at riseup dot net
# Copy this to /etc/init.d, chmod +x and chkconfig --add.
#
# Source function library.
. /etc/init.d/functions
PIDFILE=/var/run/cowsayd.pid
start() {
echo -n "Starting cowsayd"
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
echo already running: $PID
exit 2;
else
#daemon --user=root --pidfile=$PIDFILE exec /usr/local/bin/cowsayd>/dev/null 2>&1 &
daemon --check cowsayd --user=root --pidfile=$PIDFILE /usr/local/bin/cowsayd>/dev/null 2>&1 &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/cowsayd
return $RETVAL
fi
}
stop() {
echo -n "Shutting down cowsayd"
echo
killproc cowsayd
echo
rm -f /var/lock/subsys/cowsayd
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status cowsayd
;;
restart)
stop
start
;;
*)
echo "Usage: {start|stop|status|restart}"
exit 1
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment