diff --git a/scripts/docker/entrypoint-smp-server b/scripts/docker/entrypoint-smp-server index 8958874f8..5817b7b56 100755 --- a/scripts/docker/entrypoint-smp-server +++ b/scripts/docker/entrypoint-smp-server @@ -1,25 +1,25 @@ #!/usr/bin/env sh -confd="/etc/opt/simplex" -logd="/var/opt/simplex/" +confd='/etc/opt/simplex' +logd='/var/opt/simplex/' # Check if server has been initialized -if [ ! -f "$confd/smp-server.ini" ]; then +if [ ! -f "${confd}/smp-server.ini" ]; then # If not, determine ip or domain - case "$ADDR" in - '') printf "Please specify \$ADDR environment variable.\n"; exit 1 ;; + case "${ADDR}" in + '') printf 'Please specify $ADDR environment variable.\n'; exit 1 ;; *[a-zA-Z]*) - case "$ADDR" in - *:*) set -- --ip "$ADDR" ;; - *) set -- -n "$ADDR" ;; + case "${ADDR}" in + *:*) set -- --ip "${ADDR}" ;; + *) set -- -n "${ADDR}" ;; esac ;; - *) set -- --ip "$ADDR" ;; + *) set -- --ip "${ADDR}" ;; esac # Optionally, set password - case "$PASS" in + case "${PASS}" in '') set -- "$@" --no-password ;; - *) set -- "$@" --password "$PASS" ;; + *) set -- "$@" --password "${PASS}" ;; esac # And init certificates and configs @@ -27,7 +27,20 @@ if [ ! -f "$confd/smp-server.ini" ]; then fi # Backup store log just in case -[ -f "$logd/smp-server-store.log" ] && cp "$logd"/smp-server-store.log "$logd"/smp-server-store.log."$(date +'%FT%T')" +# +# Uses the UTC (universal) time zone and this +# format: YYYY-mm-dd'T'HH:MM:SS +# year, month, day, letter T, hour, minute, second +# +# This is the ISO 8601 format without the time zone at the end. +# +_file="${logd}/smp-server-store.log" +if [ -f "${_file}" ]; then + _backup_extension="$(date -u '+%Y-%m-%dT%H:%M:%S')" + cp -v -p "${_file}" "${_file}.${_backup_extension:-date-failed}" + unset -v _backup_extension +fi +unset -v _file # Finally, run smp-sever. Notice that "exec" here is important: # smp-server replaces our helper script, so that it can catch INT signal diff --git a/scripts/docker/entrypoint-xftp-server b/scripts/docker/entrypoint-xftp-server index c23262670..55757401e 100755 --- a/scripts/docker/entrypoint-xftp-server +++ b/scripts/docker/entrypoint-xftp-server @@ -1,25 +1,25 @@ #!/usr/bin/env sh -confd="/etc/opt/simplex-xftp" -logd="/var/opt/simplex-xftp" +confd='/etc/opt/simplex-xftp' +logd='/var/opt/simplex-xftp' # Check if server has been initialized -if [ ! -f "$confd/file-server.ini" ]; then +if [ ! -f "${confd}/file-server.ini" ]; then # If not, determine ip or domain - case "$ADDR" in - '') printf "Please specify \$ADDR environment variable.\n"; exit 1 ;; + case "${ADDR}" in + '') printf 'Please specify $ADDR environment variable.\n'; exit 1 ;; *[a-zA-Z]*) - case "$ADDR" in - *:*) set -- --ip "$ADDR" ;; - *) set -- -n "$ADDR" ;; + case "${ADDR}" in + *:*) set -- --ip "${ADDR}" ;; + *) set -- -n "${ADDR}" ;; esac ;; - *) set -- --ip "$ADDR" ;; + *) set -- --ip "${ADDR}" ;; esac # Set quota - case "$QUOTA" in - '') printf "Please specify \$QUOTA environment variable.\n"; exit 1 ;; - *) set -- "$@" --quota "$QUOTA" ;; + case "${QUOTA}" in + '') printf 'Please specify $QUOTA environment variable.\n'; exit 1 ;; + *) set -- "$@" --quota "${QUOTA}" ;; esac # Init the certificates and configs @@ -27,7 +27,20 @@ if [ ! -f "$confd/file-server.ini" ]; then fi # Backup store log just in case -[ -f "$logd/file-server-store.log" ] && cp "$logd"/file-server-store.log "$logd"/file-server-store.log."$(date +'%FT%T')" +# +# Uses the UTC (universal) time zone and this +# format: YYYY-mm-dd'T'HH:MM:SS +# year, month, day, letter T, hour, minute, second +# +# This is the ISO 8601 format without the time zone at the end. +# +_file="${logd}/file-server-store.log" +if [ -f "${_file}" ]; then + _backup_extension="$(date -u '+%Y-%m-%dT%H:%M:%S')" + cp -v -p "${_file}" "${_file}.${_backup_extension:-date-failed}" + unset -v _backup_extension +fi +unset -v _file # Finally, run xftp-sever. Notice that "exec" here is important: # smp-server replaces our helper script, so that it can catch INT signal