From 897fd9c0e40ab9790adf0ad1e702eef2969e7786 Mon Sep 17 00:00:00 2001 From: Dan Van Atta Date: Tue, 9 Nov 2021 19:33:31 -0800 Subject: [PATCH] Allow 'ansible-cmdb' wrapper to be a symlink Enhances 'ansible-cmdb' wrapper script to be able to find 'ansible-cmdb.py' when 'ansible-cmdb' is a symlink. Currently the search paths around 'ansible-cmdb' are relative to the location of the symlink. We can use 'readlink -f' to instead follow the symlink and search from the actual location of 'ansible-cmdb' The use-case where this comes up is we want to add 'ansible-cmdb' to the path. To do this we are creating a symlink from '/bin/ansible-cmdb' to its actual location. After this update, the command '/bin/ansible-cmdb' works as expected because the wrapper script follows the symlink. --- src/ansible-cmdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansible-cmdb b/src/ansible-cmdb index 282ab16..f0e3c1f 100755 --- a/src/ansible-cmdb +++ b/src/ansible-cmdb @@ -30,7 +30,7 @@ find_py_bin () { # Find path to the real ansible-cmdb python script find_cmdb_bin () { - BIN_DIR=$(dirname "$0") + BIN_DIR=$(dirname "$(readlink -f "$0")") if [ -f "$BIN_DIR/ansible-cmdb.py" ]; then dbg "Trying ansible-cmdb bin: $BIN_DIR/ansible-cmdb.py" echo "$BIN_DIR/ansible-cmdb.py"