From: Nicolas Boisselier Date: Thu, 9 Jul 2015 10:43:44 +0000 (+0100) Subject: timeout, nb-update X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=1949c4dfd681aabf019937e2e5d976f8ec2b98eb;p=nb.git timeout, nb-update --- diff --git a/bin/nb-update b/bin/nb-update index 4a19686b..79a35d5f 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -6,11 +6,16 @@ ##################################################################### . "${BASH_SOURCE%/*}/../etc/profile" || exit declare -r NAME="$(basename "${0}")" +declare -r TMP="/tmp/$NAME.tmp" ##################################################################### # Gits pull # ex=0 + +printf '#!%s\n%s\n' `which sh` 'ssh -o BatchMode=yes $@' > "$TMP" && chmod 755 "$TMP" +export GIT_SSH="$TMP" + for repo in \ $NB_ROOT \ /opt/backup_servers \ @@ -35,7 +40,7 @@ for repo in \ if [ "$USER" == "$user" ]; then git pull else - su $user -c "cd \"$repo\" && git pull" + timeout 10 su $user -c "cd \"$repo\" && git pull" fi ret=$? @@ -44,6 +49,7 @@ for repo in \ echo done +rm -f "$TMP" ##################################################################### # Install diff --git a/etc/aliases b/etc/aliases index 19501492..dbede2dc 100644 --- a/etc/aliases +++ b/etc/aliases @@ -17,6 +17,8 @@ alias nmap-ping="nmap -sP -PE -PS443 -PA21,22,23,80,3389" alias arp-list="arp -an" alias pdf2jpegs='gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=5 -sOutputFile=pdf2jpegs%d.jpg -dJPEGQ=100 -r500 -c quit' alias nb-maildir-make="maildirmake -S Maildir; for d in Spam Trash Sent;do maildirmake -f $d Maildir; done" +which timeout 1>/dev/null || alias timeout="perl -e 'alarm(shift @ARGV); exec @ARGV' --" + #[ "$UID" = "0" ] && grep -q '^_\?postgres:' /etc/passwd && alias psql='sudo -u postgres psql' diff --git a/etc/bashrc b/etc/bashrc index 4c3170f2..718fc1fe 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -64,14 +64,14 @@ esac h='\h' color='' #case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in -case "$HOSTNAME" in +case "`hostname -f`" in pi*) color=31 ;; # ovh - yellow *.ovh.net|*.kimsufi.com|*.ip-*.eu) color=33 ;; # mac - magenta Nicolas-Boisselier-MacBook*) h="macbook"; color=35 ;; MacMini*) color=35 ;; - dev*|cst*|csp*|isp*) color=32 ;; + *.semantico.net|dev*|cst*|csp*|isp*) color=32 ;; *) color=36 ;; esac diff --git a/etc/profile b/etc/profile index 4aca4d5a..b84c3060 100644 --- a/etc/profile +++ b/etc/profile @@ -1,10 +1,10 @@ -case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac -[ -r "${path}/bashrc" ] && . "${path}/bashrc" -[ -r "${path}/aliases" ] && . "${path}/aliases" +case "$BASH_SOURCE" in */*) path_profile="${BASH_SOURCE%/*}";; *) path_profile='.' ;; esac +[ -r "${path_profile}/bashrc" ] && . "${path_profile}/bashrc" +[ -r "${path_profile}/aliases" ] && . "${path_profile}/aliases" for i in $NB_ROOT/etc/profile.d/*.sh; do [ -r "$i" ] && . "$i" done -unset i path +unset i path_profile true