#!/bin/sh # # /etc/init.d/pci-nopaste # ### BEGIN INIT INFO # Provides: pci-nopaste # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: An obsolete implementation of no-paste, based on POE::Component::IRC # Description: See http://git.cielonegro.org/gitweb.cgi?p=pci-nopaste.git;a=summary ### END INIT INFO pidfile="@localstatedir@/pci-nopaste/pci-nopaste.pid" command="@DAEMON@ -cf -p $pidfile -- @bindir@/pci-nopaste" command_args="--config=@sysconfdir@/pci-nopaste.conf" pci_nopaste_user="no-paste" success() { RES_COL=60 echo -en "\\033[${RES_COL}G" echo -n "[" echo -en "\\033[1;32m" echo -n " OK " echo -en "\\033[0;39m" echo "]" } failure() { RES_COL=60 echo -en "\\033[${RES_COL}G" echo -n "[" echo -en "\\033[1;31m" echo -n "FAILED" echo -en "\\033[0;39m" echo "]" } status() { if [ -s "$pidfile" ]; then read _pid < "$pidfile" if [ -n "$_pid" -a -d "/proc/$_pid" ]; then echo "pci-nopaste (pid $_pid) is running..." return 0 else echo "pci-nopaste is not running." return 1 fi else echo "pci-nopaste is not running." return 1 fi } start() { if status >/dev/null 2>&1; then echo "pci-nopaste is already running." return 0 fi echo -n "Starting pci-nopaste.." /bin/su -s /bin/sh "$pci_nopaste_user" \ -c "$command $command_args" RETVAL=$? if [ $RETVAL -eq 0 ]; then success else failure fi return $RETVAL } stop() { if ! status >/dev/null 2>&1; then echo "pci-nopaste not running? (check $pidfile)." 1>&2 exit 1 fi echo -n "Stopping pci-nopaste: " /bin/su -s /bin/sh "$pci_nopaste_user" \ -c "kill -TERM $_pid" RETVAL=$? if [ $? -eq 0 ]; then success else failure fi return $RETVAL } restart() { stop start } RETVAL=0 case "$1" in start) start RETVAL=$? ;; stop) stop RETVAL=$? ;; restart|reload|force-reload) restart RETVAL=$? ;; status) status RETVAL=$? ;; *) echo "Usage: $0 {start|stop|status|restart|reload|force-reload}" RETVAL=1 esac exit $RETVAL