Use red color in die() function
This is the function where red color SHOULD be used.
This commit is contained in:
parent
b86866579a
commit
fb2aab414a
|
@ -1,16 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ `id -u` != 0 ];
|
echo "Building base image"
|
||||||
then
|
|
||||||
echo "! you must be root to run $0"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
|
|
||||||
. $DIR/function.sh
|
. $DIR/function.sh
|
||||||
|
|
||||||
[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
|
[ `id -u` -eq 0 ] || die "You must be root to run $0"
|
||||||
|
|
||||||
|
[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
|
||||||
. $DIR/../testing.conf
|
. $DIR/../testing.conf
|
||||||
|
|
||||||
# additional packages
|
# additional packages
|
||||||
|
@ -26,7 +24,6 @@ mkdir -p $CACHEDIR
|
||||||
rm -f $ROOTFS
|
rm -f $ROOTFS
|
||||||
|
|
||||||
echo "`date`, building $ROOTFS" >>$LOGFILE
|
echo "`date`, building $ROOTFS" >>$LOGFILE
|
||||||
echo "Building base image"
|
|
||||||
log_action "Creating image $ROOTFS"
|
log_action "Creating image $ROOTFS"
|
||||||
execute "dd if=/dev/null of=$ROOTFS bs=1M seek=$ROOTFSSIZE count=1"
|
execute "dd if=/dev/null of=$ROOTFS bs=1M seek=$ROOTFSSIZE count=1"
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@ execute_chroot()
|
||||||
}
|
}
|
||||||
|
|
||||||
export TERM=xterm
|
export TERM=xterm
|
||||||
|
RED=$(tput setaf 1)
|
||||||
|
GREEN=$(tput setaf 2)
|
||||||
|
NORMAL=$(tput op)
|
||||||
|
|
||||||
function cecho {
|
function cecho {
|
||||||
echo -e "\033[1;31m$1\033[0m"
|
echo -e "\033[1;31m$1\033[0m"
|
||||||
|
@ -64,10 +67,6 @@ log_action()
|
||||||
# $1 - exit status of action
|
# $1 - exit status of action
|
||||||
log_status()
|
log_status()
|
||||||
{
|
{
|
||||||
RED=$(tput setaf 1)
|
|
||||||
GREEN=$(tput setaf 2)
|
|
||||||
NORMAL=$(tput op)
|
|
||||||
|
|
||||||
tput hpa 0
|
tput hpa 0
|
||||||
if [ $1 -eq 0 ]; then
|
if [ $1 -eq 0 ]; then
|
||||||
/bin/echo -ne "[${GREEN} ok ${NORMAL}"
|
/bin/echo -ne "[${GREEN} ok ${NORMAL}"
|
||||||
|
@ -77,14 +76,11 @@ log_status()
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################
|
# exit with given error message
|
||||||
# output all args to stderr and exit with
|
# $1 - error message
|
||||||
# return code 1
|
|
||||||
#
|
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo $* 1>&2
|
echo -e "${RED}$1${NORMAL}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
|
|
Loading…
Reference in New Issue