2024-08-23 06:15:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
echo "Starting the WireGuard Dashboard Docker container."
|
|
|
|
|
|
|
|
clean_up() {
|
|
|
|
# Cleaning out previous data such as the .pid file and starting the WireGuard Dashboard. Making sure to use the python venv.
|
|
|
|
echo "Looking for remains of previous instances..."
|
|
|
|
if [ -f "/opt/wireguarddashboard/app/src/gunicorn.pid" ]; then
|
|
|
|
echo "Found old .pid file, removing."
|
|
|
|
rm /opt/wireguarddashboard/app/src/gunicorn.pid
|
|
|
|
else
|
|
|
|
echo "No remains found, continuing."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
ensure_blocking() {
|
|
|
|
sleep 1s
|
|
|
|
echo "Ensuring container continuation."
|
|
|
|
|
|
|
|
# This function checks if the latest error log is created and tails it for docker logs uses.
|
2024-08-23 23:49:54 +02:00
|
|
|
if find "/opt/wireguarddashboard/src/log" -mindepth 1 -maxdepth 1 -type f | read -r; then
|
|
|
|
latestErrLog=$(find /opt/wireguarddashboard/src/log -name "error_*.log" | head -n 1)
|
|
|
|
latestAccLog=$(find /opt/wireguarddashboard/src/log -name "access_*.log" | head -n 1)
|
2024-08-23 06:15:39 +02:00
|
|
|
tail -f "${latestErrLog}" "${latestAccLog}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Blocking command in case of erroring. So the container does not quit.
|
|
|
|
sleep infinity
|
|
|
|
}
|
|
|
|
|
2024-08-25 10:01:21 +02:00
|
|
|
{ date; clean_up; printf "\n\n"; } >> ./log/install.txt
|
2024-08-23 06:15:39 +02:00
|
|
|
|
2024-08-23 23:49:54 +02:00
|
|
|
chmod u+x /opt/wireguarddashboard/src/wgd.sh
|
2024-08-25 10:01:21 +02:00
|
|
|
/opt/wireguarddashboard/src/wgd.sh install
|
|
|
|
/opt/wireguarddashboard/src/wgd.sh docker_start
|
2024-08-23 06:15:39 +02:00
|
|
|
ensure_blocking
|