os-upgrade.sh: changes on script output.
This commit is contained in:
parent
d24558027b
commit
6cc2688f21
@ -15,66 +15,98 @@ clean_up() {
|
|||||||
|
|
||||||
# Perform program exit housekeeping
|
# Perform program exit housekeeping
|
||||||
rm $log_file
|
rm $log_file
|
||||||
|
blank_line
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
echononl(){
|
echononl(){
|
||||||
echo X\\c > /tmp/shprompt$$
|
if $terminal ; then
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
echo X\\c > /tmp/shprompt$$
|
||||||
echo -e -n "$*\\c" 1>&2
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
else
|
echo -e -n "[ \033[5m\033[1m...\033[m ]\033[13G$*\\c" 1>&2
|
||||||
echo -e -n "$*" 1>&2
|
else
|
||||||
|
echo -e -n "[ \033[5m\033[1m...\033[m ]\033[13G$*" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
fi
|
fi
|
||||||
rm /tmp/shprompt$$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error(){
|
error(){
|
||||||
echo ""
|
blank_line
|
||||||
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
|
if $terminal ; then
|
||||||
echo ""
|
echo -e " [ \033[31m\033[1mFehler\033[m ]: $*"
|
||||||
}
|
else
|
||||||
|
echo ""
|
||||||
fatal(){
|
echo "[ Error ]: $*"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\t[ \033[31m\033[1mFatal\033[m ]: $*"
|
fi
|
||||||
echo ""
|
blank_line
|
||||||
echo -e "\t\033[37m\033[1mInstalllation will be interrupted\033[m\033[m"
|
|
||||||
echo ""
|
|
||||||
clean_up 1
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
warn (){
|
|
||||||
echo ""
|
|
||||||
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
info (){
|
|
||||||
echo ""
|
|
||||||
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo_done() {
|
echo_done() {
|
||||||
echo -e "\033[80G[ \033[32mdone\033[m ]"
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;32mdone\033[m ]"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
echo_ok() {
|
echo_ok() {
|
||||||
echo -e "\033[80G[ \033[32mok\033[m ]"
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;32mok\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_ignore() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;33mignore\033[m ]"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
echo_warning() {
|
echo_warning() {
|
||||||
echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]"
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;33m\033[1mwarn\033[m ]"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
echo_failed(){
|
echo_failed(){
|
||||||
echo -e "\033[80G[ \033[1;31mfailed\033[m ]"
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;31mfail\033[m ]"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
echo_skipped() {
|
echo_skipped() {
|
||||||
echo -e "\033[80G[ \033[37mskipped\033[m ]"
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;37mskip\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_wait(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -en "\033[1G[ \033[5m\033[1m...\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
blank_line() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Jobhandling
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
|
||||||
|
# -
|
||||||
trap clean_up SIGHUP SIGINT SIGTERM
|
trap clean_up SIGHUP SIGINT SIGTERM
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Some Checks
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# - Running in a terminal?
|
||||||
|
# -
|
||||||
|
if [[ -t 1 ]] ; then
|
||||||
|
terminal=true
|
||||||
|
else
|
||||||
|
terminal=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
#-----------------------------
|
#-----------------------------
|
||||||
# Read Configurations from $conf_file
|
# Read Configurations from $conf_file
|
||||||
@ -89,20 +121,28 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
if $terminal ; then
|
||||||
echo ""
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[13G\033[33mUpdate GIT repositories..\033[m"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
||||||
|
blank_line
|
||||||
for _dir in $(ls ${_git_base_dir}/) ; do
|
for _dir in $(ls ${_git_base_dir}/) ; do
|
||||||
[[ ! -d "${_git_base_dir}/$_dir" ]] && continue
|
[[ ! -d "${_git_base_dir}/$_dir" ]] && continue
|
||||||
[[ ! -d "${_git_base_dir}/${_dir}/.git" ]] && continue
|
[[ ! -d "${_git_base_dir}/${_dir}/.git" ]] && continue
|
||||||
[[ "$_dir" = "bash" ]] && continue
|
[[ "$_dir" = "bash" ]] && continue
|
||||||
echononl " Update Repository ${_git_base_dir}/$(basename $_dir).."
|
echononl "Update Repository \033[1m$(basename $_dir)\033[m.."
|
||||||
#if [[ "$_dir" = "dehydrated-cron" ]]; then
|
#if [[ "$_dir" = "dehydrated-cron" ]]; then
|
||||||
# echo_skipped
|
# echo_skipped
|
||||||
# warn "Update this repository manually, because username and password\n\t is needed."
|
# warn "Update this repository manually, because username and password\n\t is needed."
|
||||||
#else
|
#else
|
||||||
git -C "${_git_base_dir}/${_dir}" pull > $log_file 2>&1
|
git -C "${_git_base_dir}/${_dir}" pull > $log_file 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
echo_ok
|
echo_done
|
||||||
else
|
else
|
||||||
echo_failed
|
echo_failed
|
||||||
error "$(cat $log_file)"
|
error "$(cat $log_file)"
|
||||||
@ -112,16 +152,16 @@ for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
||||||
echo ""
|
blank_line
|
||||||
echononl " Update Repository /root/crontab/backup-rcopy.."
|
echononl "Update Repository \033[1mbackup-rcopy\033[m.."
|
||||||
git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
echo_ok
|
echo_done
|
||||||
else
|
else
|
||||||
echo_failed
|
echo_failed
|
||||||
error "$(cat $log_file)"
|
error "$(cat $log_file)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
blank_line
|
||||||
clean_up
|
clean_up
|
||||||
|
Loading…
Reference in New Issue
Block a user