#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "${green}Step"%sStep $task%s: $desc%s.${nocolor}\n"%s\n" "$green" "$task" "$desc" "$nocolor"
printf "${yellow}$@${nocolor}\n""%ss%s\n" "$yellow" "$*" "$nocolor"
if sudo "$@"; then
printf "${green}Success"%sSuccess.${nocolor}\n"%s\n" "$green" "$nocolor"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "${red}Failure"%sFailure: $task${nocolor}\n"%s%s\n" "$red" "$task" "$nocolor"
#return $rc
printf "${red}Failure"%sFailure: $task${nocolor}\n"%s%s\n" "$red" "$task" "$nocolor"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "${green}Step $task: $desc.${nocolor}\n"
printf "${yellow}$@${nocolor}\n"
if sudo "$@"; then
printf "${green}Success.${nocolor}\n"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "${red}Failure: $task${nocolor}\n"
#return $rc
printf "${red}Failure: $task${nocolor}\n"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "%sStep %s: %s.%s\n" "$green" "$task" "$desc" "$nocolor"
printf "%ss%s\n" "$yellow" "$*" "$nocolor"
if sudo "$@"; then
printf "%sSuccess.%s\n" "$green" "$nocolor"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "%sFailure: %s%s\n" "$red" "$task" "$nocolor"
#return $rc
printf "%sFailure: %s%s\n" "$red" "$task" "$nocolor"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "${green}Step $task: $doco$desc.${nocolor}\n"
printf "${yellow}$@${nocolor}\n"
if sudo "$@"; then
printf "${green}Success.${nocolor}\n"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "${red}Failure: $task${nocolor}\n"
#return $rc
printf "${red}Failure: $task${nocolor}\n"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "${green}Step $task: $doco.${nocolor}\n"
printf "${yellow}$@${nocolor}\n"
if sudo "$@"; then
printf "${green}Success.${nocolor}\n"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "${red}Failure: $task${nocolor}\n"
#return $rc
printf "${red}Failure: $task${nocolor}\n"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
#!/bin/bash
set -e
run () {
local task=1ドル
local desc=2ドル
shift 2
#local rc
# More portable would be to use tput instead of literal escape codes
# Avoid uppercase for non-system variables
local red="033円[1;31m"
local green="033円[1;32m"
local yellow="033円[1;33m"
local nocolor="033円[0m"
printf "${green}Step $task: $desc.${nocolor}\n"
printf "${yellow}$@${nocolor}\n"
if sudo "$@"; then
printf "${green}Success.${nocolor}\n"
else
# The fix to capture the failed command's exit code
# was removed by the OP in an edit of the code
# but I'm recording it here for posterity.
#rc=$?
#printf "${red}Failure: $task${nocolor}\n"
#return $rc
printf "${red}Failure: $task${nocolor}\n"
return $task
fi
}
while IFS=: read exit cmd doco; do
run $exit "$doco" $cmd || exit
done <<____HERE
1:dpkg --configure -a :configure packages
2:apt-get install --fix-broken :fix broken dependencies
3:apt-get update :update cache
4:apt-get upgrade :upgrade packages
5:apt-get dist-upgrade :upgrade distribution
6:apt-get --purge autoremove :remove unused packages
7:apt-get autoclean :clean up
____HERE
Documentation for using lowercase private variable names is available e.g. in http://unix.stackexchange.com/questions/42847/are-there-naming-conventions-for-variables-in-shell-scripts https://unix.stackexchange.com/questions/42847/are-there-naming-conventions-for-variables-in-shell-scripts
Documentation for using lowercase private variable names is available e.g. in http://unix.stackexchange.com/questions/42847/are-there-naming-conventions-for-variables-in-shell-scripts
Documentation for using lowercase private variable names is available e.g. in https://unix.stackexchange.com/questions/42847/are-there-naming-conventions-for-variables-in-shell-scripts
- 2.1k
- 2
- 12
- 30