multimedia/sickchill: Tweak shutdown/startup/restart for rc file

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Jeremy Hansen 2024-03-22 21:21:13 -07:00 committed by Willy Sudiarto Raharjo
parent 07ea90f807
commit 509e12cf32
No known key found for this signature in database
GPG key ID: 3F617144D7238786

View file

@ -97,6 +97,7 @@ status()
start()
{
if [ $STATUS == "stopped" ]; then
echo -n "Starting $PROG: "
if su "$USERNAME" -s /bin/sh -c "/usr/bin/${PROG} --daemon --pidfile=${PIDFILE} --datadir=${DATADIR} --port=${PORT} &> /dev/null"; then
echo "Startup Successful"
else
@ -121,11 +122,12 @@ stop()
echo "Please run as root"
exit 1
fi
echo -n $"Shutting down $PROG: "
curl -s http://localhost:"$PORT"/home/shutdown/?pid="$(cat "$PIDFILE")" | grep -q "shutting down"
# sickchill can take some time to properly shut down.
#Give it 10 seconds before forcing it to close.
TIMEOUT=10
# It takes more than 10 seconds on my system top properly close.
# If it doesn't close by the timeout, force close it.
TIMEOUT=15
echo -n $"Giving $PROG $TIMEOUT seconds to shut down: "
curl -s http://localhost:"$PORT"/home/shutdown/?pid="$(cat "$PIDFILE")" | grep -q "shutting down"
for (( COUNT=0; COUNT <= TIMEOUT; COUNT++ )); do
if pgrep -f "$FULLPROG.*$PORT" > /dev/null; then
SHUTDOWN=success
@ -155,6 +157,8 @@ case "$1" in
restart)
check
stop
sleep 1
check
start
;;
status)