The way shell scripts under tools/ folder are using relative paths results in absolutely undesired behavior, when they are executed by other scripts.
In following working example current directory will be "/path/to/in-portal/tools
", which is correct.
Working example
cd /path/to/in-portal/tools ./fix_perms.sh
In following working example current directory will be "/path/to/in-portal
", which is not correct.
Not working example
cd /path/to/in-portal ./tools/fix_perms.sh
After digging a bit on the Internet I've found a solution, that finds absolute path to folder, where executed script is actually located:
SCRIPT_FOLDER=`cd $(dirname $0); pwd`
Also these scripts missingĀ #!/bin/sh
at the top of the script.