Closed 314pies closed 1 year ago
@yxliaoyx Can you share your UDP connection detection script here for reference?
# Checks for active connections on ssh and Project Zomboid
# If no connections are found, shut down the server
ssh_ESTABLISHED=$(netstat | grep :ssh | grep ESTABLISHED)
if [[ -n $ssh_ESTABLISHED ]]; then
exit 0
fi
port_16262=$(sudo timeout 300 tcpdump -c 1 port 16262 2>/dev/null)
if [[ -z $port_16262 ]]; then
systemctl stop zomboid.service
/opt/dcscript/discord.sh --webhook-url "$WEBHOOK_URL" --text "stop"
sudo shutdown
fi
Task description
Write CDK code to configure server auto shutdown script.
Please refer to our existing script for checking user connection:
https://gist.github.com/314pies/ac0aa3aa4e42e83363b6ca1a6c426564
This script will auto check for TCP and SSH connection and shut down the server if no connection is found
Note:
Test
Make sure the server shutdown when no one is online.
Document
Update Readme if needed.