#!/bin/sh # -*- mode: sh; fill-column: 75; tab-width: 8; coding: utf-8-unix -*- [ -z "$TERM" ] && exit 0 [ -z "$prog" ] && prog=`basename $0 .bash` [ -z "$USER" ] && USER=$( id -un ) [ -z "$DEBUG" ] && DEBUG=0 if [ -n "$TERM" ] ; then # vars that can be used to change font color blue=$(tput setaf 6) cyan=$(tput setaf 5) green=$(tput setaf 2) yellow=$(tput setaf 3) red=$(tput setaf 1) normal=$(tput sgr0) # default color else blue= cyan= green= yellow= red= normal= fi FATL () { local code=0 [ $# -eq 1 ] && code=1 [ $# -gt 1 ] && code=$1 && shift echo ${red}FATL:${normal} $* exit $code } ftal () { FATL >&2 "$@" ; } panic () { FATL >&2 "$@" ; } PANIC () { FATL >&2 "$@" ; } ERROR () { echo ${red}EROR:${normal} $* return 0 } error () { ERROR >&2 $* ; } WARN () { echo ${yellow}WARN:${normal} $* return 0 } warn () { WARN >&2 $* ; } USAGE () { echo ${yellow}USAGE:${normal} $* return 0 } usage () { USAGE >&2 $* ; } INFO () { echo ${green}INFO:${normal} $* return 0 } info () { INFO >&2 $* ; } DBUG () { [ -z "$DEBUG" ] || [ "$DEBUG" = 0 ] || echo ${blue}DBUG:${normal} $* return 0 } dbug () { DBUG >&2 $* ; } debug () { [ "$DEBUG" = "1" ] && echo >&2 ${cyan}DBUG:${normal} $* ; return 0 ; } usage () { echo ${yellow}USAGE:${normal} $* return 0 } USAGE () { usage $* ; } ols_are_we_connected () { route | grep -q ^default ; return $? ; }