New functions to simplify things...

master
bbruns 2010-08-20 19:22:29 +00:00
parent a7a3132554
commit fd2679b14b
1 changed files with 52 additions and 0 deletions

52
include/functions Normal file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# By Brielle Bruns <bruns@2mbit.com>
# URL: http://www.sosdg.org/freestuff/firewall
# License: GPLv3
#
# Copyright (C) 2009 - 2010 Brielle Bruns
# Copyright (C) 2009 - 2010 The Summit Open Source Development Group
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# display_c($COLOR,$TEXT,BOOL)
# $COLOR being bash colors
# $TEXT being what to output
# BOOL being (Y or N) to do newline at end or not
function display_c {
unset COLOR_CODE TEXT NEWLINE
DEFAULT_COLOR="\E[39m"
COLOR_CODE=`pick_color $1`
TEXT="$2"
if [ "$3" == "N" ]; then
NEWLINE="-n"
fi
echo -e $NEWLINE "$COLOR_CODE$TEXT$DEFAULT_COLOR"
}
# pick_color($COLOR)
# returns appropriate color codes for use in display_c and such
function pick_color {
case $1 in
BLUE) COLOR="\E[34m" ;;
GREEN) COLOR="\E[32m" ;;
RED) COLOR="\E[31m" ;;
YELLOW) COLOR="\E[33m" ;;
PURPLE) COLOR="\E[35m" ;;
AQUA) COLOR="\E[36m" ;;
WHITE) COLOR="\E[1m" ;;
GREY) COLOR="\E[37m" ;;
*) COLOR="\E[37m" ;;
esac
echo "$COLOR"
}