From 28872f7f25b0f9d2cf0d8d5e2706adf474fd070f Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 3 Mar 2024 17:58:17 +0100 Subject: [PATCH] Move run files to run directory. --- docker-compose.yml | 10 +++++----- start_or_update.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ce88ccc..7bcc154 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,8 @@ services: restart: always network_mode: "host" volumes: - - ./crontab.yaml:/root/crontab.yaml:Z - - ./id_rsa:/root/.ssh/id_rsa:Z - - ./id_rsa.pub:/root/.ssh/id_rsa.pub:Z - - ./config:/root/.ssh/config:Z - - ./scripts:/root/scripts:Z + - ${RUN_DIRECTORY}/crontab.yaml:/root/crontab.yaml:Z + - ${RUN_DIRECTORY}/id_rsa:/root/.ssh/id_rsa:Z + - ${RUN_DIRECTORY}/id_rsa.pub:/root/.ssh/id_rsa.pub:Z + - ${RUN_DIRECTORY}/config:/root/.ssh/config:Z + - ${RUN_DIRECTORY}/scripts:/root/scripts:Z diff --git a/start_or_update.sh b/start_or_update.sh index 7ec4055..2e1400d 100755 --- a/start_or_update.sh +++ b/start_or_update.sh @@ -1,5 +1,19 @@ #!/bin/bash +#Absolute path to this script +SCRIPT=$(readlink -f $0) +#Absolute path this script is in +SCRIPTPATH=$(dirname $SCRIPT) +STACK=$(basename "$SCRIPTPATH") +export RUN_DIRECTORY="/usr/local/docker-mounted-files/${STACK}" +cd "$SCRIPTPATH" source vars + +sudo mkdir -p "${RUN_DIRECTORY}" +sudo chmod a+rx "${RUN_DIRECTORY}" +sudo cp config "${RUN_DIRECTORY}" + +cd "${RUN_DIRECTORY}" + test -z $KEY && { echo "KEY is not defined."; exit 1; } test -z $1 || HOST="_$1" test -z $2 || INSTANCE="_$2" @@ -21,6 +35,7 @@ sudo chown root. crontab.yaml id_rsa id_rsa.pub config scripts sudo chmod 644 crontab.yaml sudo chmod 400 id_rsa id_rsa.pub config +cd "$SCRIPTPATH" unset VERSION_CRON export VERSION_CRON=$(git ls-remote https://${GIT_SERVER}/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10)