Refactored

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-15 10:19:58 +02:00
parent b8337b5699
commit 473de735de
2 changed files with 2 additions and 44 deletions

View File

@ -1,39 +1,8 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2010 # ls | grep allowed # shellcheck disable=SC2010 # ls | grep allowed
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
echo "Setupscript for Raspberry Pi devices" info "Setupscript for images started..."
echo
echo "@author Kevin Veen-Birkenbach [kevin@veen.world]"
echo "@since 2017-03-12"
echo
# Define colors
red_color=$(tput setaf 1)
green_color=$(tput setaf 2)
yellow_color=$(tput setaf 3)
blue_color=$(tput setaf 4)
magenta_color=$(tput setaf 5)
reset_color=$(tput sgr0)
message(){
echo "$1[$2]:${reset_color} $3 ";
}
question(){
message "${magenta_color}" "QUESTION" "$1";
}
info(){
message "${blue_color}" "INFO" "$1";
}
warning(){
message "${yellow_color}" "WARNING" "$1";
}
success(){
message "${green_color}" "SUCCESS" "$1";
}
destructor(){ destructor(){
info "Cleaning up..." info "Cleaning up..."
@ -50,17 +19,6 @@ destructor(){
rmdir -v "$working_folder" || warning "Removing $working_folder failed!" rmdir -v "$working_folder" || warning "Removing $working_folder failed!"
} }
error(){
message "${red_color}" "ERROR" "$1 -> Leaving program."
if [ "$2" != "no_destructor" ]
then
destructor
fi
exit 1;
}
info "Starting setup..."
info "Define variables..." info "Define variables..."
working_folder="/tmp/raspberry-pi-tools-$(date +%s)/"; working_folder="/tmp/raspberry-pi-tools-$(date +%s)/";