]> git.nbdom.net Git - nb.git/commitdiff
bin/nb-repos-run-parts
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 8 Mar 2019 15:10:09 +0000 (15:10 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 8 Mar 2019 15:10:09 +0000 (15:10 +0000)
bin/nb-repos-run-parts [new file with mode: 0755]
bin/nb-run-parts
bin/nb-update
etc/cron/nb

diff --git a/bin/nb-repos-run-parts b/bin/nb-repos-run-parts
new file mode 100755 (executable)
index 0000000..abac972
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#####################################################################
+#
+# bin/nb-repos-run-parts
+#
+#####################################################################
+DIR=${1:?Missing DIR}
+
+nb_repos | while read repo; do
+       [ -d "$repo/$DIR" ] || continue
+       echo "$repo/$DIR"
+       user=`ls -dl "$repo/$DIR" | awk '{print $3}'`
+       cmd="cd \"$repo\""
+       cmd="$cmd && ls -lhd \"$repo/$DIR\" && whoami"
+       #cmd="$cmd && run-parts --report \"$repo/$DIR\""
+
+       if [ "$USER" = "$user" ]; then
+               sh -c "$cmd"
+       elif [ "$USER" = "root" ]; then
+               su $user -c "$cmd"
+       else
+               echo "Wrong user current user=$USER repo user=$user ($repo)"
+               false
+       fi
+       ret=$?
+
+       #echo "$cmd"
+done
index 8d63549592c1d73e669f4b4084fc01dcf7c24b09..ef10127db22cf564e023b7411425524b6edeb3c7 100755 (executable)
@@ -4,7 +4,6 @@
 # bin/nb-run-parts
 #
 #####################################################################
-
 USAGE="nb-run-parts PATH"
 DIR=${1:?$USAGE}
 LOG_DIR="/var/log/nb"
index 40aa744e33caf9a6c99cedf4a8ef4761c7a8c6bc..4967d5fa114c8cc4686661676a02152eda1ccaac 100755 (executable)
@@ -61,7 +61,7 @@ for repo in $(nb_repos); do
        #
        # Get user
        #
-       user=`ls -dl "$repo/.git" |awk '{print $3}'`
+       user=`ls -dl "$repo/.git" | awk '{print $3}'`
 
        cmd=""
 
index a8bf6996e1d6d10c4446a4823aaf5fd381a6114d..647926b572c0886111fb903046e524b2659e680c 100644 (file)
@@ -12,6 +12,11 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 0       00 * * * root . /etc/profile && nb-update -cleanup >/var/log/nb.log 2>&1 | true
 0    01-08 * * * root . /etc/profile && nb-update >/var/log/nb.log 2>&1 | true
 
+# NB 08.03.19 25 5     * * *   root    which run-parts &> /dev/null && . /etc/profile && cd / && nb_repos_ls etc/cron.daily | while read i; do run-parts --report "$i"; done
+# NB 08.03.19 47 4  * * 7      root    which run-parts &> /dev/null && . /etc/profile && cd / && nb_repos_ls etc/cron.weekly | while read i; do run-parts --report "$i"; done
+# NB 08.03.19 52 3  1 * *      root    which run-parts &> /dev/null && . /etc/profile && cd / && nb_repos_ls etc/cron.monthly | while read i; do run-parts --report "$i"; done
+# NB 08.03.19 52 1  1 * *      root    which run-parts &> /dev/null && . /etc/profile && cd / && nb_repos_ls etc/cron.yearly | while read i; do run-parts --report "$i"; done
+# NB 08.03.19 
 25 5   * * *   root    which run-parts &> /dev/null && . /etc/profile && [ -d "$NB_ROOT" -a -d "$NB_ROOT/etc/cron.daily" ] && cd / && run-parts --report $NB_ROOT/etc/cron.daily
 47 4   * * 7   root    which run-parts &> /dev/null && . /etc/profile && [ -d "$NB_ROOT" -a -d "$NB_ROOT/etc/cron.weekly" ] && cd / && run-parts --report $NB_ROOT/etc/cron.weekly
 52 3   1 * *   root    which run-parts &> /dev/null && . /etc/profile && [ -d "$NB_ROOT" -a -d "$NB_ROOT/etc/cron.monthly" ] && cd / && run-parts --report $NB_ROOT/etc/cron.monthly