mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
b5938: modified crontab build process
This commit is contained in:
1 parent
8ba5a37371
commit
72da44f21b
1 file changed
+12
-9
@@ -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 <ENVIRONMENT_TYPE> <USER_WITH_CODE> <NAME_OF_GIT_DIR>"
|
||||
@@ -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
|
||||
Reference in new issue
Block a user