added termination handler

This commit is contained in:
2020-09-15 07:57:00 +02:00
parent 5eb2506fd1
commit e70f2c0a16

View File

@@ -18,4 +18,19 @@ fi
echo "---Starting...---"
chown -R ${UID}:${GID} /opt/scripts
chown -R ${UID}:${GID} ${DATA_DIR}
su ${USER} -c "/opt/scripts/start-server.sh"
term_handler() {
screenpid="$(su $USER -c "screen -list | grep "Detached" | grep "Barotrauma" | cut -d '.' -f1")"
su $USER -c "screen -S Barotrauma -X stuff 'quit^M'" >/dev/null
tail --pid="${screenpid//[[:blank:]]/}" -f 2>/dev/null
exit 143;
}
trap 'kill ${!}; term_handler' SIGTERM
su ${USER} -c "/opt/scripts/start-server.sh" &
killpid="$!"
while true
do
wait $killpid
exit 0;
done