os-upgrade.sh: changes on script output.
This commit is contained in:
parent
30239c495b
commit
d24558027b
114
os-upgrade.sh
114
os-upgrade.sh
@ -56,54 +56,71 @@ echononl(){
|
|||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo X\\c > /tmp/shprompt$$
|
echo X\\c > /tmp/shprompt$$
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
echo -e -n " $*\\c" 1>&2
|
echo -e -n "[ \033[5m\033[1m...\033[m ]\033[13G$*\\c" 1>&2
|
||||||
else
|
else
|
||||||
echo -e -n " $*" 1>&2
|
echo -e -n "[ \033[5m\033[1m...\033[m ]\033[13G$*" 1>&2
|
||||||
fi
|
fi
|
||||||
rm /tmp/shprompt$$
|
rm /tmp/shprompt$$
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
#echo_print_command() {
|
||||||
|
# if $terminal ; then
|
||||||
|
# echo X\\c > /tmp/shprompt$$
|
||||||
|
# if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
# echo -e -n "\033[60G - \033[1m$*\\c\033[m" 1>&2
|
||||||
|
# else
|
||||||
|
# echo -e -n "\033[60G - \033[1m$*\033[m" 1>&2
|
||||||
|
# fi
|
||||||
|
# rm /tmp/shprompt$$
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
echo_print_command() {
|
echo_print_command() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo X\\c > /tmp/shprompt$$
|
echo X\\c > /tmp/shprompt$$
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
echo -e -n "\033[60G - \033[1m$*\\c\033[m" 1>&2
|
echo -e -n "\n\033[13G\033[1m$*\\c\033[m" 1>&2
|
||||||
else
|
else
|
||||||
echo -e -n "\033[60G - \033[1m$*\033[m" 1>&2
|
echo -e -n "\n\033[13G\033[1m$*\033[m" 1>&2
|
||||||
fi
|
fi
|
||||||
rm /tmp/shprompt$$
|
rm /tmp/shprompt$$
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_done() {
|
echo_done() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[32mdone\033[m ]"
|
echo -e "\033[1G[ \033[1;32mdone\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_ok() {
|
echo_ok() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[32mok\033[m ]"
|
echo -e "\033[1G[ \033[1;32mok\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_ignore() {
|
echo_ignore() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[33mignore\033[m ]"
|
echo -e "\033[1G[ \033[1;33mignore\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_warning() {
|
echo_warning() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[33m\033[1mwarn\033[m ]"
|
echo -e "\033[1G[ \033[1;33m\033[1mwarn\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_failed(){
|
echo_failed(){
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[1;31mfailed\033[m ]"
|
echo -e "\033[1G[ \033[1;31mfail\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
echo_skipped() {
|
echo_skipped() {
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\033[85G[ \033[37mskipped\033[m ]"
|
echo -e "\033[1G[ \033[1;37mskip\033[m ]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
echo_wait(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -en "\033[1G[ \033[5m\033[1m...\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fatal (){
|
fatal (){
|
||||||
blank_line
|
blank_line
|
||||||
@ -122,7 +139,9 @@ error(){
|
|||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e " [ \033[31m\033[1mFehler\033[m ]: $*"
|
echo -e " [ \033[31m\033[1mFehler\033[m ]: $*"
|
||||||
else
|
else
|
||||||
echo "Error: $*"
|
echo ""
|
||||||
|
echo "[ Error ]: $*"
|
||||||
|
echo ""
|
||||||
fi
|
fi
|
||||||
blank_line
|
blank_line
|
||||||
}
|
}
|
||||||
@ -190,29 +209,48 @@ fi
|
|||||||
|
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32m\033[1mUpgrade Packages with a 'smart' conflict resolution system\033[m"
|
echo ""
|
||||||
|
echo -e "\033[13G\033[33mUpgrade Packages with a 'smart' conflict resolution system\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
blank_line
|
||||||
echononl "Resynchronize the package index files"
|
echononl "Resynchronize the package index files"
|
||||||
echo_print_command "apt-get update"
|
echo_print_command "apt-get update"
|
||||||
|
if $terminal; then
|
||||||
|
echo -e "\033[2A"
|
||||||
|
fi
|
||||||
apt-get -y update > $log_file 2>&1
|
apt-get -y update > $log_file 2>&1
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo_failed
|
echo_failed
|
||||||
|
if ! $terminal ; then
|
||||||
|
error "Command \"apt-get update\" failed!"
|
||||||
|
fi
|
||||||
fatal "$(cat $log_file)"
|
fatal "$(cat $log_file)"
|
||||||
else
|
else
|
||||||
echo_done
|
echo_done
|
||||||
fi
|
fi
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[2B"
|
||||||
|
fi
|
||||||
|
|
||||||
# - get list of upgradable packages
|
# - get list of upgradable packages
|
||||||
#
|
#
|
||||||
packages_updated="$(apt-get -V -s dist-upgrade | grep -E "^ .*=>.*" | awk '{print$1}')"
|
packages_updated="$(apt-get -V -s dist-upgrade | grep -E "^ .*=>.*" | awk '{print$1}')"
|
||||||
|
|
||||||
|
#blank_line
|
||||||
#echononl "Upgrade Packages"
|
#echononl "Upgrade Packages"
|
||||||
|
#echo_print_command "apt full-upgrade"
|
||||||
|
#if $terminal; then
|
||||||
|
# echo -e "\033[2A"
|
||||||
|
#fi
|
||||||
#if [[ -n "$packages_updated" ]]; then
|
#if [[ -n "$packages_updated" ]]; then
|
||||||
# apt full-upgrade -y > $log_file 2>&1
|
# apt full-upgrade -y > $log_file 2>&1
|
||||||
# if [[ $? -gt 0 ]]; then
|
# if [[ $? -gt 0 ]]; then
|
||||||
# echo_failed
|
# echo_failed
|
||||||
|
# if ! $terminal ; then
|
||||||
|
# error "Command \"apt full-upgrade\" failed!"
|
||||||
|
# fi
|
||||||
# fatal "$(cat $log_file)"
|
# fatal "$(cat $log_file)"
|
||||||
# else
|
# else
|
||||||
# echo_done
|
# echo_done
|
||||||
@ -226,13 +264,24 @@ packages_updated="$(apt-get -V -s dist-upgrade | grep -E "^ .*=>.*" | awk '{pr
|
|||||||
#else
|
#else
|
||||||
# echo_skipped
|
# echo_skipped
|
||||||
#fi
|
#fi
|
||||||
|
#if $terminal ; then
|
||||||
|
# echo -e "\033[2B"
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
|
blank_line
|
||||||
echononl "Upgrade Packages"
|
echononl "Upgrade Packages"
|
||||||
echo_print_command "apt-get dist-upgrade"
|
echo_print_command "apt-get dist-upgrade"
|
||||||
|
if $terminal; then
|
||||||
|
echo -e "\033[2A"
|
||||||
|
fi
|
||||||
if [[ -n "$packages_updated" ]]; then
|
if [[ -n "$packages_updated" ]]; then
|
||||||
apt-get dist-upgrade -y > $log_file 2>&1
|
apt-get dist-upgrade -y > $log_file 2>&1
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo_failed
|
echo_failed
|
||||||
|
if ! $terminal ; then
|
||||||
|
error "Command \"apt-get dist-upgrade\" failed!"
|
||||||
|
fi
|
||||||
fatal "$(cat $log_file)"
|
fatal "$(cat $log_file)"
|
||||||
else
|
else
|
||||||
echo_done
|
echo_done
|
||||||
@ -240,7 +289,11 @@ if [[ -n "$packages_updated" ]]; then
|
|||||||
echo " This packages have been updated:"
|
echo " This packages have been updated:"
|
||||||
echo "[ $(date +%Y-%d-%m" "%H:%M) ] This packages have been updated:" >> "$updated_packages_log"
|
echo "[ $(date +%Y-%d-%m" "%H:%M) ] This packages have been updated:" >> "$updated_packages_log"
|
||||||
for _package in $packages_updated ; do
|
for _package in $packages_updated ; do
|
||||||
echo -e " \033[1m$_package\033[m"
|
if $terminal ; then
|
||||||
|
echo -e " \033[1m$_package\033[m"
|
||||||
|
else
|
||||||
|
echo -e " $_package\033[m"
|
||||||
|
fi
|
||||||
echo " $_package" >> "$updated_packages_log"
|
echo " $_package" >> "$updated_packages_log"
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
@ -251,26 +304,49 @@ if [[ -n "$packages_updated" ]]; then
|
|||||||
else
|
else
|
||||||
echo_skipped
|
echo_skipped
|
||||||
fi
|
fi
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[2B"
|
||||||
|
fi
|
||||||
|
|
||||||
|
blank_line
|
||||||
echononl "Remove unused Packages"
|
echononl "Remove unused Packages"
|
||||||
echo_print_command "apt-get autoremove"
|
echo_print_command "apt-get autoremove"
|
||||||
apt-get autoremove -y > $log_file 2>&1
|
apt-get autoremove -y > $log_file 2>&1
|
||||||
|
if $terminal; then
|
||||||
|
echo -e "\033[2A"
|
||||||
|
fi
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo_failed
|
echo_failed
|
||||||
|
if ! $terminal ; then
|
||||||
|
error "Command \"apt-get autoremove\" failed!"
|
||||||
|
fi
|
||||||
fatal "$(cat $log_file)"
|
fatal "$(cat $log_file)"
|
||||||
else
|
else
|
||||||
echo_done
|
echo_done
|
||||||
fi
|
fi
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[2B"
|
||||||
|
fi
|
||||||
|
|
||||||
|
blank_line
|
||||||
echononl "Clear out the local repository of retrieved package files"
|
echononl "Clear out the local repository of retrieved package files"
|
||||||
echo_print_command "apt-get clean"
|
echo_print_command "apt-get clean"
|
||||||
apt-get clean -y > $log_file 2>&1
|
apt-get clean -y > $log_file 2>&1
|
||||||
|
if $terminal; then
|
||||||
|
echo -e "\033[2A"
|
||||||
|
fi
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo_failed
|
echo_failed
|
||||||
|
if ! $terminal ; then
|
||||||
|
error "Command \"apt-get clean\" failed!"
|
||||||
|
fi
|
||||||
fatal "$(cat $log_file)"
|
fatal "$(cat $log_file)"
|
||||||
else
|
else
|
||||||
echo_done
|
echo_done
|
||||||
fi
|
fi
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[2B"
|
||||||
|
fi
|
||||||
|
|
||||||
# - Get list of packages with onlx config files present
|
# - Get list of packages with onlx config files present
|
||||||
# -
|
# -
|
||||||
@ -278,13 +354,17 @@ rc_packages="$(dpkg --list | awk '/^rc/ { print $2 }')"
|
|||||||
|
|
||||||
blank_line
|
blank_line
|
||||||
if $terminal; then
|
if $terminal; then
|
||||||
echo -e " Remove (purge) packages with only config files installed ((rc):"
|
echo -e "\033[13GRemove (purge) packages with only config files installed (rc):"
|
||||||
echo -en " \033[1mapt-get purge \$(dpkg --list | awk '/^rc/ { print $2 }')\033[m"
|
echo -en "\033[13G\033[1mapt-get purge \$(dpkg --list | awk '/^rc/ { print $2 }')\033[m"
|
||||||
|
echo -e "\033[2A"
|
||||||
fi
|
fi
|
||||||
if [[ -n "$rc_packages" ]] ; then
|
if [[ -n "$rc_packages" ]] ; then
|
||||||
apt-get purge -y $(dpkg --list | awk '/^rc/ { print $2 }') > $log_file 2>&1
|
apt-get purge -y $(dpkg --list | awk '/^rc/ { print $2 }') > $log_file 2>&1
|
||||||
if [[ $? -gt 0 ]]; then
|
if [[ $? -gt 0 ]]; then
|
||||||
echo_failed
|
echo_failed
|
||||||
|
if ! $terminal ; then
|
||||||
|
error "Command \"apt-get purge -y \$(dpkg --list | awk '/^rc/ { print \$2 }')\" failed!"
|
||||||
|
fi
|
||||||
fatal "$(cat $log_file)"
|
fatal "$(cat $log_file)"
|
||||||
else
|
else
|
||||||
echo_done
|
echo_done
|
||||||
@ -305,6 +385,10 @@ else
|
|||||||
echo_skipped
|
echo_skipped
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[2B"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ -f "/var/run/reboot-required" ]]; then
|
if [[ -f "/var/run/reboot-required" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user