DESC="cpkg configuration service" NAME=cpkg-daemon DAEMON=/usr/sbin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMON_ARGS="--pidfile $PIDFILE" MAX_WAIT_TIME=3 SLEEP_TIME=1 CPKG_PIPE="/etc/cpkg-daemon/cpkg-pipe" is_daemon_running(){ [ -s "$PIDFILE" ] || return 1 PID="$(cat "$PIDFILE")" if ps ax |grep "[[:blank:]]${DAEMON}[[:blank:]]${DAEMON_ARGS}$" |cut -f 1 -d " " |grep -q "^$PID$" ; then return 0 fi } cpkg_send_message(){ if [ ! -p "$CPKG_PIPE" ] || ! is_daemon_running ; then return $CPKG_RC_NOTRUNNINGDAEMON fi (echo "$*" > "$CPKG_PIPE" )& say_mesage "Sending cpkg commands to $NAME. See syslog for details" return 0 }