Add teamspeak-fallback service
This commit is contained in:
parent
c95be92f46
commit
03f83ef7fd
6 changed files with 94 additions and 0 deletions
roles/teamspeak_fallback/templates
18
roles/teamspeak_fallback/templates/conditional-start.sh.j2
Normal file
18
roles/teamspeak_fallback/templates/conditional-start.sh.j2
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
while true
|
||||
do
|
||||
if nc -z "{{ teamspeak_fallback_check_server }}" "{{ teamspeak_fallback_check_port }}"
|
||||
then
|
||||
if docker compose ps --services | grep teamspeak >/dev/null; then
|
||||
echo "Stopping Server"
|
||||
docker compose down
|
||||
fi
|
||||
else
|
||||
if ! docker compose ps --services | grep teamspeak >/dev/null; then
|
||||
echo "Starting Server"
|
||||
docker compose up -d --pull=always
|
||||
fi
|
||||
fi
|
||||
sleep 5
|
||||
done
|
|
@ -0,0 +1,13 @@
|
|||
[Service]
|
||||
[Unit]
|
||||
Description=Teamspeak Fallback Starter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart={{ service_path }}/conditional-start.sh
|
||||
WorkingDirectory={{ service_path }}
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in a new issue