Skip to content
Duncan Holm edited this page Oct 24, 2018 · 2 revisions

Here is an OpenRC initscript I have used to run yt2pod on Alpine Linux.

It assumes a user called yt2pod has already been created (adduser yt2pod).

#!/sbin/openrc-run

APP_USER="$RC_SVCNAME"
APP_DIR="/home/$APP_USER"

BINARY="$APP_DIR/$RC_SVCNAME"
BINARY_ARGS="-syslog -dataclean"

LOG_OUT="$APP_DIR/out.log"
LOG_ERR="$APP_DIR/err.log"
LOG_PID="$APP_DIR/pid.log"

STARTED_OK_AFTER_MS=5000

depend() {
	need net
	need localmount
}

start() {
	ebegin "Starting $RC_SVCNAME"

	start-stop-daemon --exec "$BINARY" \
		--start \
		--background \
		--chdir "$APP_DIR" \
		--user "$APP_USER" \
		--make-pidfile \
		--pidfile "$LOG_PID" \
		--stdout "$LOG_OUT" \
		--stderr "$LOG_ERR" \
		--wait "$STARTED_OK_AFTER_MS" \
		-- \
		$BINARY_ARGS

	eend $?
}

stop() {
	ebegin "Stopping $RC_SVCNAME"

	start-stop-daemon --exec "$BINARY" \
		--stop \
		--pidfile "$LOG_PID"

	eend $?
}

Write that to the file /etc/init.d/yt2pod and then register and start the service using:

rc-update add yt2pod default
rc-service yt2pod start
Clone this wiki locally