From 72da44f21b3129098b9a22005f958e10bd0801a7 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Fri, 29 Dec 2023 14:59:36 +0000 Subject: [PATCH] b5938: modified crontab build process --- .../environments_scripts/build-crontab | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/configuration/environments_scripts/build-crontab b/configuration/environments_scripts/build-crontab index 67a4aad215c..cc14509b9f8 100755 --- a/configuration/environments_scripts/build-crontab +++ b/configuration/environments_scripts/build-crontab @@ -4,7 +4,7 @@ # that contains the git repo. It then goes to the environment type directory and concatenates all files with the names crontab*, placing the result # into the home directory specified by the USER file. -#then construct the crontab, replacing a keyword with the user in the specification. install the crontab in the path of the user +#then construct the crontab, replacing a keyword with the user in the specification. install the crontab in the path of the user #and then run it for the specified user. if [[ $# -ne 3 ]]; then echo "$0 " @@ -18,13 +18,16 @@ GIT_USER="$2" GIT_DIR_NAME="$3" cd "$(dirname "$0")/${ENV_TYPE}" -HOME_DIR=$(grep "^$(cat USER)" /etc/passwd | cut -d':' -f6) # The path to the home dir of the user whose cronjob will be installed. GIT_PATH="$(grep "^${GIT_USER}" /etc/passwd | cut -d':' -f6)/${GIT_DIR_NAME}" # The path to the git repo that contains the files needed. -touch $HOME_DIR/crontab -for crontab in $(ls crontab*); do - cat "$crontab" >> $HOME_DIR/crontab - echo "" >> $HOME_DIR/crontab # Adds a newline +for dir in $(ls -d */ ); do + USERNAME=$(echo $dir | sed "s/\/$//") + HOME_DIR=$(grep "^${USERNAME}" /etc/passwd | cut -d':' -f6) # The path to the home dir of the user whose cronjob will be installed. + touch $HOME_DIR/crontab + for crontab in $(ls ${USERNAME}/crontab*); do + cat "$crontab" >> $HOME_DIR/crontab + echo "" >> $HOME_DIR/crontab # Adds a newline + done + sed -i "s|PATH_OF_GIT_HOME_DIR_TO_REPLACE|${GIT_PATH}|g" $HOME_DIR/crontab # Sets correct path to the git repo within the crontab. + sed -i "s|PATH_OF_HOME_DIR_TO_REPLACE|${HOME_DIR}|g" $HOME_DIR/crontab # Sets the correct path to the home dir of the user whose crontab will be installed. + # crontab -u ${USERNAME} $HOME_DIR/crontab done -sed -i "s|PATH_OF_GIT_HOME_DIR_TO_REPLACE|${GIT_PATH}|g" $HOME_DIR/crontab # Sets correct path to the git repo within the crontab. -sed -i "s|PATH_OF_HOME_DIR_TO_REPLACE|${HOME_DIR}|g" $HOME_DIR/crontab # Sets the correct path to the home dir of the user whose crontab will be installed. -crontab -u $(cat USER) $HOME_DIR/crontab