mirror of
https://github.com/donaldzou/WGDashboard
synced 2025-02-26 05:58:47 +00:00
Added a SIGTERM trap to the entrypoint script for faster stopping.
This commit is contained in:
parent
393dac1c99
commit
41772f28bd
@ -3,6 +3,14 @@
|
|||||||
# Path to the configuration file (exists because of previous function).
|
# Path to the configuration file (exists because of previous function).
|
||||||
config_file="/data/wg-dashboard.ini"
|
config_file="/data/wg-dashboard.ini"
|
||||||
|
|
||||||
|
trap 'stop_service' SIGTERM
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
echo "[WGDashboard] Stopping WGDashboard..."
|
||||||
|
./wgd.sh stop
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
echo "------------------------- START ----------------------------"
|
echo "------------------------- START ----------------------------"
|
||||||
echo "Starting the WireGuard Dashboard Docker container."
|
echo "Starting the WireGuard Dashboard Docker container."
|
||||||
|
|
||||||
@ -18,7 +26,7 @@ ensure_installation() {
|
|||||||
if [ ! -d "${WGDASH}/src/db" ]; then
|
if [ ! -d "${WGDASH}/src/db" ]; then
|
||||||
ln -s /data/db "${WGDASH}/src/db"
|
ln -s /data/db "${WGDASH}/src/db"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${config_file}" ]; then
|
if [ ! -f "${config_file}" ]; then
|
||||||
echo "Creating wg-dashboard.ini file"
|
echo "Creating wg-dashboard.ini file"
|
||||||
touch "${config_file}"
|
touch "${config_file}"
|
||||||
@ -33,7 +41,7 @@ ensure_installation() {
|
|||||||
|
|
||||||
echo "Moving PIP dependency from ephemerality to runtime environment: psutil"
|
echo "Moving PIP dependency from ephemerality to runtime environment: psutil"
|
||||||
mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
||||||
|
|
||||||
echo "Moving PIP dependency from ephemerality to runtime environment: bcrypt"
|
echo "Moving PIP dependency from ephemerality to runtime environment: bcrypt"
|
||||||
mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
||||||
|
|
||||||
@ -69,7 +77,7 @@ set_envvars() {
|
|||||||
# Check if the file is empty
|
# Check if the file is empty
|
||||||
if [ ! -s "${config_file}" ]; then
|
if [ ! -s "${config_file}" ]; then
|
||||||
echo "Config file is empty. Creating [Peers] section."
|
echo "Config file is empty. Creating [Peers] section."
|
||||||
|
|
||||||
# Create [Peers] section with initial values
|
# Create [Peers] section with initial values
|
||||||
{
|
{
|
||||||
echo "[Peers]"
|
echo "[Peers]"
|
||||||
@ -89,7 +97,7 @@ set_envvars() {
|
|||||||
current_dns=$(grep "peer_global_dns = " "${config_file}" | awk '{print $NF}')
|
current_dns=$(grep "peer_global_dns = " "${config_file}" | awk '{print $NF}')
|
||||||
if [ "${global_dns}" == "$current_dns" ]; then
|
if [ "${global_dns}" == "$current_dns" ]; then
|
||||||
echo "DNS is set correctly, moving on."
|
echo "DNS is set correctly, moving on."
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Changing default DNS..."
|
echo "Changing default DNS..."
|
||||||
sed -i "s/^peer_global_dns = .*/peer_global_dns = ${global_dns}/" "${config_file}"
|
sed -i "s/^peer_global_dns = .*/peer_global_dns = ${global_dns}/" "${config_file}"
|
||||||
@ -133,7 +141,7 @@ ensure_blocking() {
|
|||||||
|
|
||||||
# Find and tail the latest error and access logs if they exist
|
# Find and tail the latest error and access logs if they exist
|
||||||
local logdir="${WGDASH}/src/log"
|
local logdir="${WGDASH}/src/log"
|
||||||
|
|
||||||
latestErrLog=$(find "$logdir" -name "error_*.log" -type f -print | sort -r | head -n 1)
|
latestErrLog=$(find "$logdir" -name "error_*.log" -type f -print | sort -r | head -n 1)
|
||||||
#latestAccLog=$(find "$logdir" -name "access_*.log" -type f -print | sort -r | head -n 1) # Removed access line due to console spam.
|
#latestAccLog=$(find "$logdir" -name "access_*.log" -type f -print | sort -r | head -n 1) # Removed access line due to console spam.
|
||||||
|
|
||||||
@ -152,4 +160,4 @@ ensure_blocking() {
|
|||||||
ensure_installation
|
ensure_installation
|
||||||
set_envvars
|
set_envvars
|
||||||
start_core
|
start_core
|
||||||
ensure_blocking
|
ensure_blocking
|
||||||
|
Loading…
Reference in New Issue
Block a user