Created
July 3, 2014 23:35
-
-
Save hamiltont/7e038ed3adf1109138c7 to your computer and use it in GitHub Desktop.
temp
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 -E | |
# If you are running a large number of installs back to back | |
# (e.g. for FwBm development), then setting this variable | |
# will cause apt-get and wget to use your proxy server. If | |
# your proxy server has a cache for static content, this can | |
# save you quite a lot of download time | |
# export http_proxy=http://10.0.1.0:3128 | |
export fw_get () { | |
wget --no-check-certificate --trust-server-names "$@" | |
} | |
export fw_untar() { | |
# tar xzf "$@" | |
tar xvzf "$@" | |
} | |
export fw_unzip() { | |
unzip "$@" | |
} | |
# Requires dependencies to come in order e.g. Nimrod before | |
# Jester, etc. Users should be know this | |
# fairly well (e.g. you can't use Yaf without PHP) | |
fw_depends() { | |
# Turn on errtrace (-E), so that our ERR | |
# trap is passed on to any subshells | |
set -E | |
trap 'traperror $? $LINENO "$BASH_COMMAND"' ERR | |
# Was ERR trapped during this dependency installation? | |
error_happened=0 | |
# Was ERR trapped ever during this execution? | |
any_errors_happened=0 | |
for depend in "$@" | |
do | |
echo Searching for $depend | |
if [ -f ../toolset/setup/linux/systools/${depend}.sh ]; then | |
echo Installing system tool: $depend | |
bash ../toolset/setup/linux/systools/${depend}.sh | |
elif [ -f ../toolset/setup/linux/languages/${depend}.sh ]; then | |
echo Installing language: $depend | |
bash ../toolset/setup/linux/languages/${depend}.sh | |
elif [ -f ../toolset/setup/linux/webservers/${depend}.sh ]; then | |
echo Installing webserver: $depend | |
bash ../toolset/setup/linux/webservers/${depend}.sh | |
elif [ -f ../toolset/setup/linux/frameworks/${depend}.sh ]; then | |
echo Installing framework: $depend | |
bash ../toolset/setup/linux/frameworks/${depend}.sh | |
else | |
echo WARN: No installer found for $depend | |
continue | |
fi | |
if [ $error_happened -ne 0 ]; then | |
echo ERROR: Problem installing $depend | |
# Reset variable for future dependencies | |
error_happened=0 | |
else | |
echo $depend is installed! | |
fi | |
done | |
# Politely clean up our trap and trace | |
set +E | |
trap - ERR | |
if [ $any_errors_happened -ne 0 ]; then | |
echo ERROR: Problems installing dependencies: "$@" | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
# Exits 0 if file or directory exists | |
export fw_exists() { | |
if [ -f $1 ] || [ -d $1 ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
export traperror () { | |
file=`basename $0` | |
err=$1 # error status | |
line=$2 # LINENO | |
command="$3" | |
error_happened=1 | |
any_errors_happened=1 | |
echo "ERROR: $file at line $line - command '$command' exited with status: $err" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment