#!/usr/bin/bash # sanity.sh, 2002-Oct-01, gash, http://www.moosenugget.org # # Demonstration script to verify a sane environment. ################################################################################ # # Set a sane PATH # export PATH="/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/local/sbin" # # Binaries that are required by our script # BINARIES="awk echo egrep ifconfig ipchains logger mail" # # Verify BASH version # if [ -z "${BASH_VERSINFO[0]}" -o -z "$BASH_VERSION" ] ; then echo -e "\n\nCould not verify BASH version. Quitting.\n" exit 1 fi if [ "${BASH_VERSINFO[0]}" -lt "2" ] ; then echo -e "\n\nThis script requires BASH version 2 or greater. Quitting.\n" echo -e " Your version reports: $BASH_VERSION\n" echo -n "Download a newest version from " echo -e "http://www.gnu.org/directory/bash.html\n\n" exit 1 fi # # Verify that our support files exist before we kick off # for BIN in $BINARIES ; do type $BIN >/dev/null 2>&1 \ || { echo -e "\n${BIN} not found in:\n ${PATH}.\n\nQuitting." ; exit 1; } done # # Some scripts like to be run by root only # if [ ! "0${UID}0" = "000" ] ; then echo -e "\nPlease run this script as root. Quitting.\n\n" exit 1 fi # # Ready to roll, begin script below # echo "A hollow voice says \"plugh\"."