mklive/scripts/functions.sh

54 lines
813 B
Bash

RED='\033[0;31m'
GREEN='\033[0;32m'
ORGANGE='\033[0;33m'
BLUE='\033[0;34m'
LGRAY='\033[0;37m'
NC='\033[0m'
[ -z "$ARCHISO_SERVER" ] && ARCHISO_SERVER=${PXE_SERVER}
[ -z "$ARCHISO_HTTP_BASE" ] && ARCHISO_HTTP_BASE=${PXE_HTTP_BASE}
requiredir() {
[ -n "$1" ] || exit 1
[ -e $1 ] || mkdir $1
}
eexit() {
eerr "$1"
exit 1
}
checkstage() {
[ -e ${WORKDIR}/stage/_$1 ] || return 1
[ "$(cat $WORKDIR/stage/_$1)" != "done" ] && return 2
return 0
}
startstage() {
requiredir ${WORKDIR}/stage
echo -n "started" > ${WORKDIR}/stage/_$1
}
endstage() {
echo -n "done" > ${WORKDIR}/stage/_$1
}
edebug() {
[ "$MKLIVE_DEBUG" == "true" ] && echo "[dd] $1" 1>&2
}
eok() {
echo -e "${GREEN}[++] $1${NC}" 1>&2
}
einfo() {
echo -e "${BLUE}[ii] ${1}${NC}" 1>&2
}
eerr(){
echo -e "${RED}[--] ${1}${NC}" 1>&2
}