From 3f4e093ccdb793ef940d21c834fd2ada861f05b4 Mon Sep 17 00:00:00 2001 From: Per Andersson Date: Sat, 17 Apr 2010 18:33:51 +0200 Subject: added option to configure uid:gid to run daemon as. --- etherpad/bin/etherpad.default | 4 ++++ etherpad/bin/etherpad.init | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/etherpad/bin/etherpad.default b/etherpad/bin/etherpad.default index e5ef128..1943cdc 100644 --- a/etherpad/bin/etherpad.default +++ b/etherpad/bin/etherpad.default @@ -1,6 +1,10 @@ # Default settings for etherpad. This file is sourced by /bin/sh from # /etc/init.d/etherpad. +# User and group to run as +ETHERPAD_USER="etherpad" +ETHERPAD_GROUP="etherpad" + # Setup paths ETHERPAD_HOME=/usr/local/etherpad JAVA=/usr/bin/java diff --git a/etherpad/bin/etherpad.init b/etherpad/bin/etherpad.init index 010e811..9c2f447 100644 --- a/etherpad/bin/etherpad.init +++ b/etherpad/bin/etherpad.init @@ -23,6 +23,8 @@ NAME=etherpad #DAEMON_ARGS="--options args" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME +CHUID="$ETHERPAD_USER:$ETHERPAD_GROUP" + # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 @@ -46,11 +48,17 @@ do_start() # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started + + # Run as etherpad:etherpad by defaut + if [ "$CHUID" = ":" ]; then + CHUID="etherpad:etherpad" + fi + start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \ - --exec $JAVA --test > /dev/null \ + --chuid $CHUID --exec $JAVA --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \ - --exec $JAVA -- $ETHERPAD_OPTS + --chuid $CHUID --exec $JAVA -- $ETHERPAD_OPTS || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend -- cgit v1.2.3