Skip to content

Instantly share code, notes, and snippets.

@mheiges
Last active August 29, 2015 14:04
Show Gist options
  • Save mheiges/d4c9de27fecc3399014c to your computer and use it in GitHub Desktop.
Save mheiges/d4c9de27fecc3399014c to your computer and use it in GitHub Desktop.
Link executables into $admin_path/bin/ for cluster/workflow software management
#!/bin/sh
set -u -e
admin_path=$1;
if [ -d "$admin_path/bin" ]; then
mv "$admin_path/bin" "$admin_path/bin.bak"
fi
mkdir "$admin_path/bin"
# maxdepth of 3 will find
# software/rubygems-1.8.15/bin
# and
# software/rubygems-1.8.15/gems/bin
# but not e.g.
# software/rubygems-1.8.15/gems/gems/bundler-1.0.21/bin/
# which avoids duplicates
# will break if whitespace in path, but there should not be any
for bindir in $(find "$admin_path/software/" -maxdepth 3 -type d -name bin); do
for binfile in $(find "$bindir" -type f); do
ln -fs "$binfile" "$admin_path/bin";
done;
done;
if [ -d "$admin_path/bin.bak" ]; then
rm -r "$admin_path/bin.bak"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment