Skip to content

Commit eb5bd1c

Browse files
committed
Add funcion to automate checksum update
1 parent bac7cf3 commit eb5bd1c

File tree

2 files changed

+98
-2
lines changed

2 files changed

+98
-2
lines changed

bin/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ REPLACE_LETSENCRYPT_SERVICE_NAME="nginx-proxy-automation-letsencrypt"
5656
#
5757
# md5 checksum for .env and docker-compose.yml files
5858
#
59-
MD5_SUM_DOCKER_COMPOSE=acb712ecf4c2edd04583032b1cd4da07
60-
MD5_SUM_ENV_SAMPLE=b299b584d68c1a6f7ac1b1a753a7517d
59+
MD5_SUM_DOCKER_COMPOSE=0a91c69a103cd6c7cd475477b78a237b
60+
MD5_SUM_ENV_SAMPLE=7a8b027dc2bf252a8c91d23f74e2bd2a

bin/update-checksum.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
#-----------------------------------------------------------------------
4+
#
5+
# Update checksum in .env files
6+
#
7+
# Part of https://github.com/evertramos/nginx-proxy-automation
8+
#
9+
# Script written by
10+
# Evert Ramos <[email protected]>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
16+
# Bash settings (do not mess with it)
17+
shopt -s nullglob globstar
18+
19+
# Get the script name and its file real path
20+
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
21+
SCRIPT_NAME="${0##*/}"
22+
23+
# Source basescript functions
24+
source $SCRIPT_PATH"/../basescript/bootstrap.sh"
25+
26+
# Source localscripts
27+
source $SCRIPT_PATH"/localscript/bootstrap.sh"
28+
29+
# Log
30+
printf "${energy} Start execution '${SCRIPT_PATH}/${SCRIPT_NAME} "
31+
log "Start execution"
32+
log "$@"
33+
34+
#-----------------------------------------------------------------------
35+
# Initial check - DO NOT CHANGE SETTINGS BELOW
36+
#-----------------------------------------------------------------------
37+
38+
# Check if there is an .env file in local folder
39+
run_function check_local_env_file
40+
41+
# Specific PID File if needs to run multiple scripts
42+
NEW_PID_FILE=${PID_FILE_FRESH_INSTALL:-".update_checksum"}
43+
44+
# Run initial check function
45+
run_function starts_initial_check $NEW_PID_FILE
46+
47+
# Save PID
48+
system_save_pid $NEW_PID_FILE
49+
50+
# DO NOT CHANGE ANY OPTIONS ABOVE THIS LINE!
51+
52+
#-----------------------------------------------------------------------
53+
# [function] Undo script actions
54+
#-----------------------------------------------------------------------
55+
local_undo_restore() {
56+
# local LOCAL_KEEP_RESTORE_FILES
57+
#
58+
# LOCAL_KEEP_RESTORE_FILES=${1:-$KEEP_RESTORE_FILES}
59+
60+
echoerror \
61+
"It seems something went wrong! \
62+
\nRunning '${FUNCNAME[0]} to try to UNDO all actions done by this script. \
63+
\nPlease make sure everything was put it back in place." false
64+
65+
# If docker network was created
66+
# if [[ "$ACTION_DOCKER_NETWORK_CREATED" == true ]]; then
67+
# [[ "$SILENT" != true ]] && echowarning "[undo] Deleting created docker network '$DOCKER_NETWORK_NAME'."
68+
# run_function docker_network_remove $DOCKER_NETWORK_NAME
69+
# ACTION_DOCKER_NETWORK_CREATED=false
70+
# fi
71+
72+
exit 0
73+
}
74+
75+
#-----------------------------------------------------------------------
76+
# Verify checksum of docker-compose.yml and .env.sample files
77+
#-----------------------------------------------------------------------
78+
run_function md5_check_checksum "$SCRIPT_PATH/../" "docker-compose.yml" $MD5_SUM_DOCKER_COMPOSE
79+
if [[ ! "$MD5_CHECKSUM" == true ]]; then
80+
DOCKER_COMPOSE_CHECKSUM=$(md5sum "$SCRIPT_PATH/../docker-compose.yml" | awk '{print $1}')
81+
echowarning "Updating the checksum for 'MD5_SUM_DOCKER_COMPOSE'"
82+
run_function env_update_variable "$SCRIPT_PATH" "MD5_SUM_DOCKER_COMPOSE" "$DOCKER_COMPOSE_CHECKSUM"
83+
else
84+
echosuccess "Checksum for 'MD5_SUM_DOCKER_COMPOSE' is just fine!"
85+
fi
86+
87+
run_function md5_check_checksum "$SCRIPT_PATH/../" ".env.sample" $MD5_SUM_ENV_SAMPLE
88+
if [[ ! "$MD5_CHECKSUM" == true ]]; then
89+
ENV_CHECKSUM=$(md5sum "$SCRIPT_PATH/../.env.sample" | awk '{print $1}')
90+
echowarning "Updating the checksum for 'MD5_SUM_ENV_SAMPLE'"
91+
run_function env_update_variable "$SCRIPT_PATH" "MD5_SUM_ENV_SAMPLE" "$ENV_CHECKSUM"
92+
else
93+
echosuccess "Checksum for 'MD5_SUM_ENV_SAMPLE' is just fine!"
94+
fi
95+
96+
exit 0

0 commit comments

Comments
 (0)