Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 106 lines (100 sloc) 2.33 KB
#!/bin/sh
# gotit
#
# David Jones, Climate Code Foundation, 2012
# drj@climatecode.org
#
# Script to test whether all of the required
# Software Carpentry boot camp software is installed.
#
# run with:
# curl https://raw.github.com/drj11/prace/master/gotit | sh
#
# Bugs:
#
# On Mac OS X claims firefox is missing even when it's not.
#
# Doesn't test whether the Firefox extension sqlite tool
# is installed.
#
# Doesn't check the version of any tools.
#
# REFERENCES
#
# [SETUP]
# http://software-carpentry.org/boot-camps/boot-camp-standard-software-set-up/ (accessed on 2012-11-19)
echo "Hello $(whoami), if you can see this, we have a shell; good."
try () {
# Try the command "$@" and if successful return true (exit
# status 0), otherwise returns false (exit status non-0). All
# output is suppressed.
"$@" > /dev/null 2>&1
}
check () {
# run the command "$1 --version", or if more than one
# argument is supplied, "$@".
# if successful, print "$1 good"; if unsucessful,
# print "$1 missing". If $REPORT is set then use that
# instead of $1 for reporting.
if [ $# -eq 0 ]
then
echo 1>&2 "check command # command is required"
return 99
fi
if [ $# -eq 1 ]
then
set -- "$1" --version
fi
printf "%s " "${REPORT:-$1}"
if try "$@"
then
echo good
else
echo missing
fi
}
runsatall () {
# Runs the command "$@" and returns code 0, unless
# the result of running the command is exit code 127
# (which the shell uses to indicate "command not found").
try "$@"
if [ $? -eq 127 ]
then
return 127
else
return 0
fi
}
editors () (
editors_ok=false
editors="nano vi emacs xemacs"
for ed in $editors
do
try "$ed" --version && editors_ok=true &&
printf "%s good\n" "$ed"
done
$editors_ok || printf "%s all missing\n" "$editors"
)
Firefox () (
# First one works on Linux, second on Mac OS X
try firefox --version ||
try open -g -a Firefox --args --version
)
check bash
check zip
check unzip -v
check tar
check gunzip
check wget
check make
editors
check python
# The subshell appears to be necessary for dash, ksh and
# bash --posix. My reading of the SUSv2 is that it
# should not be necessary.
(REPORT=python-sqlite check python -c 'import sqlite3')
(REPORT=easy_install check runsatall easy_install --version)
check nosetests
(REPORT=Mercurial check hg)
check sqlite3
check Firefox