]> git.nbdom.net Git - nb.git/commitdiff
bin/crontab_install
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 9 Oct 2024 12:06:57 +0000 (14:06 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 9 Oct 2024 12:06:57 +0000 (14:06 +0200)
bin/crontab_install
bin/nb-repo-install
bin/nb-update

index b20198ed21d414fa047aeae6f882e1156b4eed8f..d77c231faff1e34d5cef5690b83e78a57e55b4e6 100755 (executable)
@@ -109,10 +109,10 @@ done
 #
 #################################################################################
 cd ~ || exit
-which crontab > /dev/null || exit
+which crontab > /dev/null || exit 0
 CRON="$(cat_crontab)"
 [ -n "$CRON" ] || exit
-[ "$(crontab -l)" != "$CRON" ] || exit
+[ "$(crontab -l)" = "$CRON" ] && exit
 [ "$VERBOSE" -gt "0" ] && echo "Update crontab"
 #echo "<$CRON>"
 echo "$CRON" | crontab
index 04d43f6b21b3ef6717f9723929b31dfe5d1d6b22..ddfb918a9634043537315f1b85ad0e1bcab2f955 100755 (executable)
@@ -5,28 +5,26 @@
 #
 #################################################################################
 
+################################################################################
 #
 # Checks and globals
 #
+################################################################################
+
+# Ensure this script is run from the root of the repository
+REPO_ROOT="$(git rev-parse --show-toplevel)"
+[ -n "$REPO_ROOT" ] || exit
+cd "$REPO_ROOT" || exit
 
-#exec echo $0
-#eval "ls -1 "$0" | awk '{print $3}'"
 CURRENT_USER="$(whoami)"
-FILE_USER="$(stat --format '%U' "$0")"
-#if [ "$(whoami)" != "$(stat --format '%U' "$0")" ]
+FILE_USER="$(stat --format '%U' "$REPO_ROOT")"
 if [ "$CURRENT_USER" != "$FILE_USER" ]
 then
-       echo "Wrong user: $CURRENT_USER != $FILE_USER"
+       echo "Wrong user: $CURRENT_USER != $FILE_USER repo=$REPO_ROOT"
        #exec sudo -u "$FILE_USER" "$0"
        #su "$FILE_USER" -c "$0"
        exit -1
 fi
-#[ -z "$UID" ] && UID=`id -u`
-# NB 08.10.24 if [ "$UID" != "0" ] && echo "$NAME: please login as root." 1>&2 && exit 1
-
-# Ensure this script is run from the root of the repository
-REPO_ROOT="$(git rev-parse --show-toplevel)"
-[ -n "$REPO_ROOT" ] || exit
 
 REPO_NAME="$(basename -s .git $(git remote get-url origin))"
 [ -n "$REPO_NAME" ] || exit
index eafbf1a0173ee1e93e2327e0823dc26d4663ef2d..3ffc0f6940b1f9da9370b170935cb65b32cc6fe2 100755 (executable)
@@ -129,10 +129,11 @@ for dir in $(nb_repos); do
        #
        # Get user
        #
-       user=`ls -dl "$dir/.git" | awk '{print $3}'`
+       user=$(stat --format '%U' "$dir/.git")
        if [ -z "$user" ]
        then
                echo "Can't read user owner for '$dir'" 1>&2
+               continue
        fi
 
        cd "$dir" || continue