Sisyphus repository
Last update: 18 january 2021 | SRPMs: 17780 | Visits: 20073292
en ru br
ALT Linux repos
S:0.9.6-alt4
5.0: 0.9.6-alt1
4.1: 0.9.6-alt1

Group :: System/Servers
RPM: pks

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

#!/bin/sh
#
# chkconfig: 345 90 30
# description: OpenPGP Public Key Server
# processname: /usr/sbin/pksd
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/pksd.conf

#configuration options
. /etc/init.d/functions
WITHOUT_RC_COMPAT=1

PKSD=/usr/sbin/pksd
PKSQUEUE=/usr/bin/pks-queue-run.sh
CONFIG=/etc/pksd.conf
DELAY=3
DB=/var/lib/pks
PKSCLIENT=/usr/bin/pksclient
LOCKFILE_PKSD=/var/lock/subsys/pksd
LOCKFILE_PKS_QUEUE=/var/lock/subsys/pks-queue-run
PIDFILE_PKSD=/var/run/pks/pksd
PIDFILE_PKS_QUEUE=/var/run/pks/pks-queue-run
SOCKET=pksd_socket
USER="_pks"
SU=/bin/su
CHMOD=/bin/chmod
SH=/bin/sh

RETVAL=0

start() {
if start-stop-daemon --start --test --quiet --pidfile "$PIDFILE_PKSD" \
--user $USER --exec "$PKSD" >/dev/null; then
action "Starting pks daemon:" \
start-stop-daemon --start -b -m --pidfile "$PIDFILE_PKSD" -c "$USER" -x $PKSD -- $CONFIG
else
msg_already_running pksd
passed "pksd startup"
echo
fi
RETVAL=$?
if [ $RETVAL = 0 ] ; then
touch "$LOCKFILE_PKSD"
$CHMOD 777 $DB/$SOCKET
fi

if start-stop-daemon --start --test --quiet --pidfile "$PIDFILE_PKS_QUEUE" \
--user $USER --exec $SH -- "$PKSQUEUE" >/dev/null; then
action "Starting pks queue processing daemon:" \
start-stop-daemon --start -b -m --pidfile "$PIDFILE_PKS_QUEUE" -c "$USER" -x $SH -- $PKSQUEUE $CONFIG $DELAY
else
msg_already_running pks-queue
passed "pks-queue startup"
echo
fi
RETVAL=$?
[ $RETVAL -ne 0 ] || touch "$LOCKFILE_PKS_QUEUE"

return $RETVAL
}

stop() {
action "Stoping pks daemon:" \
start-stop-daemon --stop --pidfile "$PIDFILE_PKSD" --user $USER
RETVAL=$?
[ "$RETVAL" -ne 0 ] || rm -f -- "$LOCKFILE_PKSD" "$PIDFILE_PKSD"
action "Stoping pks queue processing daemon:" \
start-stop-daemon --stop --pidfile "$PIDFILE_PKS_QUEUE" --user "$USER" --exec $SH -- $PKSQUEUE
RETVAL=$?
[ "$RETVAL" -ne 0 ] || rm -f -- "$LOCKFILE_PKS_QUEUE" "$PIDFILE_PKS_QUEUE"

return $RETVAL
}

initdb() {
if ! [ -f $DB/db/num_keydb ] ; then
$SU - $USER -c "$PKSCLIENT $DB/db create" >/dev/null 2>&1
fi
RETVAL=$?
return $RETVAL
}

setdb() {
echo "Repairing pks database"
$SU - $USER -c "$PKSCLIENT $DB/db recover >> $DB/recovery.log 2>&1" 1>/dev/null 2>&1
RETVAL=$?
return $RETVAL
}

restart() {
stop
setdb
start
}

# See how we were called.
case "$1" in
start)
initdb
setdb
start
;;
stop)
stop
;;
initdb)
initdb
;;
restart)
restart
;;
condstop)
if [ -e "$LOCKFILE_PKS" ]; then
stop
fi
;;
condrestart)
if [ -e "$LOCKFILE_PKS" ]; then
restart
fi
;;
status)
status --expect-user "$USER" --pidfile "$PIDFILE_PKSD" --lockfile "$LOCKFILE_PKSD" -- $PKSD
status --expect-user "$USER" --pidfile "$PIDFILE_PKS_QUEUE" --lockfile "$LOCKFILE_PKS_QUEUE" \
--displayname pks-queue -- /bin/sh $PKSQUEUE
RETVAL=$?
;;
*)
msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
RETVAL=1
esac

exit $RETVAL
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin