Bonjour,
Pour le multi-utilisateur, quelles sont les modifications à faire sur le script medusa_user1 ?
J'ai créé un fichier par utilisateur en remplaçant user1
Le script à modifier :
Pour s'y retrouver, j'ai modifié 3 parties, reconnaissables aux nombreux #### 🙂
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: medusa_user1 ############### Partie modifiée
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Medusa
# Description: starts instance of Medusa using start-stop-daemon
### END INIT INFO
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
# Source Medusa configuration ############### Partie modifiée
APP_USER=user1
APP_GROUP=user1
APP_HOME=/opt/medusa
APP_DATA=$APP_HOME/data/$APP_USER
APP_PIDFILE=$APP_DATA/medusa.pid
## Don't set -e
## Don't edit this file!
## Edit user configuation in /etc/default/medusa to change
##
## APP_USER= #$RUN_AS, username to run medusa under, the default is medusa
## APP_GROUP= #$RUN_GROUP, group to run medusa under, the default is medusa
## APP_HOME= #$APP_PATH, the location of start.py, the default is /opt/medusa
## APP_DATA= #$DATA_DIR, the location of sickbeard.db, cache, logs, the default is /opt/medusa
## APP_PIDFILE= #$PID_FILE, the location of medusa.pid, the default is /var/run/PyMedusa/Medusa.pid
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python2.7
## APP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for medusa, i.e. " --config=/home/medusa/config.ini"
## SSD_OPTS= #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
##
## EXAMPLE if want to run as different user
## add APP_USER=username to /etc/default/medusa
## otherwise default medusa is used
# Script name
NAME=$(basename "$0")
# App name
DESC=Medusa
## The defaults
# Run as username
RUN_AS=${APP_USER-medusa}
# Run as group
RUN_GROUP=${APP_GROUP-medusa}
# Path to app APP_HOME=path_to_app_start.py
APP_PATH=${APP_HOME-/opt/medusa}
# Data directory where sickbeard.db, cache and logs are stored
DATA_DIR=${APP_DATA-/opt/medusa}
# Path to store PID file
PID_FILE=${APP_PIDFILE-/var/run/PyMedusa/Medusa.pid}
# path to python bin
DAEMON=${PYTHON_BIN-/usr/bin/python2.7}
# Extra daemon option like: APP_OPTS=" --config=/home/medusa/config.ini"
EXTRA_DAEMON_OPTS=$APP_DATA/config.ini #################### partie modifiée
# Extra start-stop-daemon option like START_OPTS=" --group=users"
EXTRA_SSD_OPTS=${SSD_OPTS-}
##
PID_PATH=$(dirname $PID_FILE)
DAEMON_OPTS=" start.py -q --daemon --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR} ${EXTRA_DAEMON_OPTS}"
##
test -x $DAEMON || exit 0
# Create PID directory if not exist and ensure the Medusa user can write to it
if [ ! -d $PID_PATH ]; then
mkdir -p $PID_PATH
chown $RUN_AS $PID_PATH
fi
if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $RUN_AS $DATA_DIR
fi
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
[ "$VERBOSE" != no ] && echo "Removing stale $PID_FILE"
rm -f $PID_FILE
fi
fi
start_medusa() {
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon -d $APP_PATH -c $RUN_AS --group=${RUN_GROUP} $EXTRA_SSD_OPTS --start --quiet --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
RETVAL="$?"
case "${RETVAL}" in
# Service was started or was running already
0|1) [ "${VERBOSE}" != no ] && log_end_msg 0 ;;
# Service couldn't be started
2) [ "${VERBOSE}" != no ] && log_end_msg 1 ;;
esac
[ "${RETVAL}" = 2 ] && return 2
return 0
}
stop_medusa() {
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --pidfile $PID_FILE --quiet --retry TERM/30/KILL/5
RETVAL="$?"
case "${RETVAL}" in
# Service was stopped or wasn't running
0|1) [ "${VERBOSE}" != no ] && log_end_msg 0 ;;
# Service couldn't be stopped
2) [ "${VERBOSE}" != no ] && log_end_msg 1 ;;
esac
[ "${RETVAL}" = 2 ] && return 2
[ -f "${PID_FILE}" ] && rm -f ${PID_FILE}
return 0
}
case "$1" in
start)
start_medusa
exit $?
;;
stop)
stop_medusa
exit $?
;;
restart|force-reload)
stop_medusa
sleep 2
start_medusa
exit $?
;;
status)
status_of_proc -p "$PID_FILE" "$DAEMON" "$DESC"
exit $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
J'aimerai savoir s'il n'y a pas (trop) d'erreur 😉