Improve init files

Hypnotoad does not use "user" and "group" settings anymore. So I
removed the setting in the configuration template and changed some
things in the init files accordingly.

+ some fixes for annoying behavior in initV and systemd files
This commit is contained in:
Luc Didry
2015-09-09 23:07:13 +02:00
parent bb5c7050bb
commit bb9fae43e2
5 changed files with 32 additions and 22 deletions

View File

@@ -7,12 +7,6 @@
hypnotoad => {
# array of IP addresses and ports you want to listen to
listen => ['http://127.0.0.1:8080'],
# user and group you want for Lutim to run with
# be sure that this user/group have rights on the lutim directory
# if you launch lutim from a different user, be sure that this user have the right to su this user/group
# => if current_user is not the user that you sets here and is not root, there's chances that it will fail (see https://github.com/ldidry/lutim/issues/25)
user => 'www-data',
group => 'www-data'
},
################

View File

@@ -1,3 +1,6 @@
# LDIR is the path where you installed Lutim
# It has to end with a final /
LDIR=/var/lutim/
LDIR=/var/www/lutim/
# USER is the user who will launch Lutim
USER=www-data

View File

@@ -26,6 +26,11 @@ then
echo "LDIR variable is empty, please fill it in /etc/default/lutim"
exit 0
fi
if [ -z $USER ]
then
echo "USER variable is empty, please fill it in /etc/default/lutim"
exit 0
fi
else
echo "Missing /etc/default/lutim file"
exit 0
@@ -49,7 +54,7 @@ do_start()
# 2 if daemon could not be started
cd $LDIR
carton exec hypnotoad $DAEMON >/dev/null 2>&1
su $USER -c "carton exec hypnotoad $DAEMON >/dev/null 2>&1"
return "$?"
}
@@ -62,7 +67,7 @@ do_stop()
# other if a failure occurred
cd $LDIR
carton exec hypnotoad -s $DAEMON >/dev/null 2>&1
su $USER -c "carton exec hypnotoad -s $DAEMON >/dev/null 2>&1"
return "$?"
}
@@ -75,10 +80,10 @@ do_status()
if [ "$?" = "0" ]; then
log_progress_msg "$NAME is running"
else
log_progress_msg "$NAME is NOT running"
log_failure_msg "$NAME is NOT running but PID file exists"
fi
else
log_progress_msg "$NAME is NOT running"
log_failure_msg "$NAME is NOT running"
fi
}
@@ -101,7 +106,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
@@ -114,7 +119,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
@@ -134,16 +139,16 @@ case "$1" in
log_end_msg 0
;;
*)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
else
log_progress_msg "$NAME is NOT running. Unable to stop"
log_failure_msg "$NAME is NOT running. Unable to stop"
log_end_msg 1
fi
else
log_progress_msg "$NAME is NOT running. Unable to stop"
log_failure_msg "$NAME is NOT running. Unable to stop"
log_end_msg 1
fi
;;
@@ -155,13 +160,14 @@ case "$1" in
reload)
log_daemon_msg "Reloading $NAME"
do_start
sleep 1
case "$?" in
0|1)
log_progress_msg "done"
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
@@ -169,7 +175,7 @@ case "$1" in
restart)
log_daemon_msg "Restarting $NAME"
do_stop
sleep 1
sleep 6
do_start
case "$?" in
0|1)
@@ -177,7 +183,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed";
log_failure_msg "failed";
log_end_msg 1
;;
esac

View File

@@ -5,10 +5,12 @@ Requires=network.target
After=network.target
[Service]
Type=simple
Type=forking
User=www-data
RemainAfterExit=yes
WorkingDirectory=/var/www/lutim/
PIDFile=/var/www/lutim/script/hypnotoad.pid
ExecStart=/usr/local/bin/carton exec hypnotoad -f script/lutim
ExecStart=/usr/local/bin/carton exec hypnotoad script/lutim
ExecStop=/usr/local/bin/carton exec hypnotoad -s script/lutim
ExecReload=/usr/local/bin/carton exec hypnotoad script/lutim

View File

@@ -14,10 +14,15 @@ script
echo "LDIR variable is empty, please fill it in /etc/default/lutim"
exit 0
fi
if [ -z $USER ]
then
echo "USER variable is empty, please fill it in /etc/default/lutim"
exit 0
fi
else
echo "Missing /etc/default/lutim file"
exit 0
fi
cd $LDIR
carton exec hypnotoad script/lutim -f
su $USER -c "carton exec hypnotoad -f script/lutim"
end script