2014-03-08 04:47:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-03-09 21:39:41 +00:00
|
|
|
export NO_COLOR='\033[0m'
|
|
|
|
export OK_COLOR='\033[32;01m'
|
|
|
|
export ERROR_COLOR='\033[31;01m'
|
|
|
|
export WARN_COLOR='\033[33;01m'
|
|
|
|
|
2014-03-08 04:47:13 +00:00
|
|
|
log() {
|
2014-03-09 23:20:37 +00:00
|
|
|
echo " [${RELEASE}] ${1}" >>${LOG}
|
2014-03-08 05:23:06 +00:00
|
|
|
echo " [${RELEASE}] ${1}" >&2
|
2014-03-08 04:47:13 +00:00
|
|
|
}
|
|
|
|
|
2014-03-08 05:23:06 +00:00
|
|
|
warn() {
|
2014-03-09 23:20:37 +00:00
|
|
|
echo "==> [${RELEASE}] [WARN] ${1}" >>${LOG}
|
2014-03-08 05:23:06 +00:00
|
|
|
echo -e "${WARN_COLOR}==> [${RELEASE}] ${1}${NO_COLOR}"
|
|
|
|
}
|
|
|
|
|
|
|
|
info() {
|
2014-03-09 23:20:37 +00:00
|
|
|
echo "==> [${RELEASE}] [INFO] ${1}" >>${LOG}
|
2014-03-08 05:23:06 +00:00
|
|
|
echo -e "${OK_COLOR}==> [${RELEASE}] ${1}${NO_COLOR}"
|
2014-03-08 04:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
confirm() {
|
|
|
|
question=${1}
|
|
|
|
default=${2}
|
|
|
|
default_prompt=
|
|
|
|
|
|
|
|
if [ $default = 'n' ]; then
|
|
|
|
default_prompt="y/N"
|
|
|
|
default='No'
|
|
|
|
else
|
|
|
|
default_prompt="Y/n"
|
|
|
|
default='Yes'
|
|
|
|
fi
|
|
|
|
|
2014-03-08 05:23:06 +00:00
|
|
|
echo -e -n "${WARN_COLOR}==> [${RELEASE}] ${question} [${default_prompt}] ${NO_COLOR}" >&2
|
2014-03-08 04:47:13 +00:00
|
|
|
read answer
|
|
|
|
|
|
|
|
if [ -z $answer ]; then
|
|
|
|
debug "Answer not provided, assuming '${default}'"
|
|
|
|
answer=${default}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo ${answer} | grep -q -i '^y'); then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
2014-03-08 05:23:06 +00:00
|
|
|
|
|
|
|
debug() {
|
|
|
|
[ ! $DEBUG ] || echo " [${RELEASE}] [DEBUG] ${1}" >&2
|
|
|
|
}
|