File pkg.depotd.init of Package pkg

#!/bin/sh
#
# pkg.depotd   Start/Stop the IPS depotd.
#
### BEGIN INIT INFO
# Provides:          pkg.depotd
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: IPS depot daemon
# Description:       IPS depot daemon
### END INIT INFO

PKGDEPOTD_BIN=/usr/lib/pkg.depotd
test -x $PKGDEPOTD_BIN || { echo "$PKGDEPOTD_BIN not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

PKGDEPOTD_CONFIG=/etc/sysconfig/pkg.depotd
test -r $PKGDEPOTD_CONFIG || { echo "$PKGDEPOTD_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

. $PKGDEPOTD_CONFIG

PKGDEPOTD_OPTIONS=

if [ -n "$INST_ROOT" ]
then
	if [ ! -d "$INST_ROOT" ]
	then
		if [ "$1" = "stop" ]
		then
			exit 0
		else
			echo "Instance root $INST_ROOT does not exist, use 'pkgrepo create' to create a repository."
			exit 7
		fi
	fi

	if [ ! -d "$INST_ROOT" ]
	then
		echo 
	fi

	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS -d $INST_ROOT"
else
	echo "Instance root not set."
	exit 8
fi

if [ -n "$WRITABLE_ROOT" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --writable-root $WRITABLE_ROOT"
fi

if [ -n "$CONTENT_ROOT" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --content-root $CONTENT_ROOT"
fi

if [ -n "$PROXY_BASE" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --proxy-base $PROXY_BASE"
fi

if [ -n "$PORT" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS -p $PORT"
fi

if [ -n "$THREADS" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS -s $THREADS"
fi

if [ "$MIRROR" = "1" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --mirror"
fi

if [ "$READONLY" = "1" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --readonly"
fi

if [ -n "$LOG_ACCESS" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --log-access $LOG_ACCESS"
fi

if [ -n "$LOG_ERRORS" ]
then
	PKGDEPOTD_OPTIONS="$PKGDEPOTD_OPTIONS --log-errors $LOG_ERRORS"
fi

if [ -z "$USER" ]
then
	USER=pkg
fi

. /lib/lsb/init-functions
. /etc/rc.status

case "$1" in
	start)
		echo -n "Starting pkg.depotd "
		start_daemon -u $USER $PKGDEPOTD_BIN $PKGDEPOTD_OPTIONS &

		rc_status -v
		;;
	stop)
		echo -n "Shutting down pkg.depotd "
		/sbin/killproc -TERM $PKGDEPOTD_BIN

		rc_status -v
		;;
	try-restart|condrestart)
		if test "$1" = "condrestart"; then
			echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
		fi
		$0 status
		if test $? = 0; then
			$0 restart
		else
			rc_reset
		fi

		rc_status
		;;
	restart)
		$0 stop
		$0 start

		rc_status
		;;
	reload|force-reload)
		/sbin/killproc -HUP $PKGDEPOTD_BIN

		rc_status -v
		;;
	status)
		echo -n "Checking for service pkg.depotd "
		/sbin/checkproc $PKGDEPOTD_BIN

		rc_status -v
		;;
	*)
		echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
		exit 1
		;;
esac

rc_exit
openSUSE Build Service is sponsored by