chiark / gitweb /
rcheck: Hunt down directory by chasing symlinks.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 22 Jun 2011 08:13:29 +0000 (09:13 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 22 Jun 2011 08:13:29 +0000 (09:13 +0100)
Better than hardwiring it.

rcheck

diff --git a/rcheck b/rcheck
index 84e7c51..cd40440 100755 (executable)
--- a/rcheck
+++ b/rcheck
@@ -3,7 +3,14 @@
 ### Run everyday health checks on remote systems.
 
 set -e
-cd /usr/local/share/rcheck
+prog=$0
+while
+  case "$prog" in */*) ;; *) prog=./$prog ;; esac
+  cd "${prog%/*}"
+  [ -L "${prog##*/}" ]
+do
+  prog=$(readlink "${prog##*/}")
+done
 
 for host in "$@"; do