soscmd/soscmd-azuracast
2023-06-03 11:28:50 +02:00

63 lines
2 KiB
Bash
Executable file

#!/bin/bash
if [ ! "$(whoami)" == "root" ]; then
echo "The soscmd-azuracast command must be ran as root user (superuser)."
/usr/bin/sudo -E /usr/bin/bash $0 $@
exit $?
fi
if [ "$1" == "help" ]; then
echo "soscmd-azuracast [help|start|stop|restart|update|cli|shell]"
exit 0
fi
cd /var/azuracast || exit 41
if [ "$1" == "start" ]; then
echo "::${AZURACAST_SPACES} Starting AzuraCast"
./docker.sh up
exit $?
elif [ "$1" == "stop" ]; then
echo "::${AZURACAST_SPACES} Stopping AzuraCast"
./docker.sh down
exit $?
elif [ "$1" == "restart" ]; then
echo "::${AZURACAST_SPACES} Restarting AzuraCast"
AZURACAST_SPACES="${AZURACAST_SPACES} " $0 stop
AZURACAST_SPACES="${AZURACAST_SPACES} " $0 start
echo "::${AZURACAST_SPACES} Restarted AzuraCast"
exit 0
elif [ "$1" == "update" ]; then
echo "::${AZURACAST_SPACES} Updating AzuraCast"
#env AZURACAST_SPACES="${AZURACAST_SPACES} " $0 stop
echo "::${AZURACAST_SPACES} Updating script"
./docker.sh update-self
echo "::${AZURACAST_SPACES} Updating AzuraCast"
./docker.sh update
echo "::${AZURACAST_SPACES} Reapplying docker-compose.yml"
cp /var/azuracast/docker-compose.recommended.yml /var/azuracast/docker-compose.yml
env AZURACAST_ARROWS="${AZURACAST_SPACES} " $0 restart
echo "::${AZURACAST_SPACES} Updated AzuraCast"
exit 0
elif [ "$1" == "cli" ]; then
echo "::${AZURACAST_SPACES} Entering AzuraCast CLI"
echo "::${AZURACAST_SPACES} Execute cli:help for help."
while true; do
echo -n "AZURACAST$ "
read -r AZURACAST_CLI
if [ "$AZURACAST_CLI" == "cli:help" ]; then
echo "help | Help command"
echo "exit | Exit CLI"
elif [ "$AZURACAST_CLI" == "cli:exit" ]; then
break
elif [ "$AZURACAST_CLI" == "cli" ] || [ "$AZURACAST_CLI" == "cli:" ]; then
echo "Use cli:help for help."
else
./docker.sh cli $AZURACAST_CLI
fi
done
exit $?
elif [ "$1" == "shell" ]; then
echo "::${AZURACAST_SPACES} Entering AzuraCast shell"
./docker.sh bash
exit $?
else
echo "::${AZURACAST_SPACES} ERROR: Invalid subcommand."
exit 1
fi