Created
April 30, 2012 09:25
-
-
Save cheeming/2556801 to your computer and use it in GitHub Desktop.
Link binaries to /opt/local/bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# BIN_PATH should not require trailing slash | |
BIN_PATH=${1} | |
if [ -z "${BIN_PATH}" ]; then | |
echo Please state the path to the bin folder, e.g.: > /dev/stderr | |
echo ${0} PATH_TO_BIN_FOLDER > /dev/stderr | |
exit 1 | |
fi | |
shift 1 | |
DRY_RUN=1 | |
while getopts "x" option_name; do | |
case "$option_name" in | |
x) DRY_RUN=0;; | |
esac | |
done | |
BIN_FILES=`find ${BIN_PATH} -type f -perm +0111 -depth 1` | |
for FILE in $BIN_FILES; do | |
COMMAND="ln -s $FILE /opt/local/bin/`basename $FILE`" | |
if [ ${DRY_RUN} -eq 1 ]; then | |
echo ${COMMAND} | |
else | |
eval ${COMMAND} | |
fi | |
done | |
if [ ${DRY_RUN} -eq 1 ]; then | |
echo Please use flag -x to get script to run commands | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment