From: Matteo Nastasi (mop) Date: Thu, 18 Sep 2014 16:50:03 +0000 (+0200) Subject: restarter.sh commodity added and reduced time of directories rename X-Git-Tag: v4.15.0~11 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=b758f8bb41cd8ce44b531f2d05f2a5b4704a5d3c;p=brisk.git restarter.sh commodity added and reduced time of directories rename --- diff --git a/bin/restarter.sh b/bin/restarter.sh new file mode 100755 index 0000000..848c02c --- /dev/null +++ b/bin/restarter.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# set -x +cd "$PWD" 2>/dev/null +dirnm="$PWD" +cwd_old="$(ls -i -d "$dirnm" | cut -d ' ' -f 1)" +pid_exe="" +while true; do + if [ "$pid_exe" = "" ]; then + sleep 2 + cd "$dirnm" 2>/dev/null + "$@" & + pid_exe="$!" + fi + sleep 1 + kill -0 $pid_exe >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Process not present" + exit 0 + fi + for tloop in 1 2 3 4 5; do + cwd_cur="$(ls -i -d "$dirnm" 2>/dev/null | cut -d ' ' -f 1)" + if [ "$cwd_cur" ]; then + break + fi + sleep 1 + done + if [ $tloop -eq 5 ]; then + echo "Unavailable current working directory" + exit 1 + fi + if [ "$cwd_cur" != "$cwd_old" ]; then + kill $pid_exe + wait $pid_exe + echo "WAIT EXIT: $?" + pid_exe="" + fi + cwd_old="$cwd_cur" +done +