Index: cros_show_stacks |
diff --git a/cros_show_stacks b/cros_show_stacks |
index fa6b769321d821385ee337217ff0749f41768d5a..be2eb25e89796b05fbc187008f948e87854cfa93 100755 |
--- a/cros_show_stacks |
+++ b/cros_show_stacks |
@@ -6,11 +6,28 @@ |
# Script to generate stackdumps from a machine or dmp files. |
-# Load common constants. This should be the first executable line. |
-# The path to common.sh should be relative to your script's location. |
+# --- BEGIN COMMON.SH BOILERPLATE --- |
+# Load common CrOS utilities. Inside the chroot this file is installed in |
+# /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
+# location. |
+find_common_sh() { |
+ local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
+ local path |
+ |
+ SCRIPT_ROOT= |
+ for path in "${common_paths[@]}"; do |
+ if [ -r "${path}/common.sh" ]; then |
+ SCRIPT_ROOT=${path} |
+ break |
+ fi |
+ done |
+} |
+ |
+find_common_sh |
+. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
+# --- END COMMON.SH BOILERPLATE --- |
-. "$(dirname $0)/common.sh" |
-. "$(dirname $0)/remote_access.sh" |
+. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh" |
assert_inside_chroot |