| 1 |
#!/bin/sh |
| 2 |
# $FreeWRT$ |
| 3 |
#- |
| 4 |
# This file is part of the FreeWRT project. FreeWRT is copyrighted |
| 5 |
# material, please see the LICENCE file in the top-level directory |
| 6 |
# or at http://www.freewrt.org/licence for details. |
| 7 |
#- |
| 8 |
#FWINIT 80 |
| 9 |
|
| 10 |
case $1 in |
| 11 |
args) |
| 12 |
shift |
| 13 |
sp= |
| 14 |
while test $# -gt 0; do |
| 15 |
printf "$sp'%s'" "$(printf '%s' "$1" | sed "s/'/'\\''/g")" |
| 16 |
sp=' ' |
| 17 |
shift |
| 18 |
done |
| 19 |
printf '\n' |
| 20 |
exit 0 |
| 21 |
;; |
| 22 |
autostart|start) ;; |
| 23 |
*) exit 0 ;; |
| 24 |
esac |
| 25 |
|
| 26 |
sleep 30 |
| 27 |
|
| 28 |
naspid=$(cat /var/run/nas.lan.pid) |
| 29 |
if test ! "$naspid" -ge 1; then |
| 30 |
echo No NAS found. | logger -t naswatch |
| 31 |
exit 1 |
| 32 |
fi |
| 33 |
|
| 34 |
cmd=$(xargs -0 /bin/sh "$0" args </proc/$naspid/cmdline) |
| 35 |
case $cmd in |
| 36 |
*bin/nas*) ;; |
| 37 |
*) |
| 38 |
echo Error reading command line. | logger -t naswatch |
| 39 |
exit 1 |
| 40 |
;; |
| 41 |
esac |
| 42 |
|
| 43 |
while sleep 30; do |
| 44 |
test -z "$(pidof nas)" || continue |
| 45 |
echo Restarting NAS. | logger -t naswatch |
| 46 |
eval "$cmd" |
| 47 |
done & |
| 48 |
exit 0 |