This commit is contained in:
hjelev
2022-03-20 22:08:07 +02:00
parent 5e6d35efc4
commit cea4ab7604

View File

@@ -1,10 +1,12 @@
printm(){ welcome(){
length=$(expr length "$1") echo "This script will install if not installed: Pip and python module paho-mqtt."
length=$(($length + 4)) echo "Configure Raspberry Pi MQTT monitor and create a cronjob to run it."
printf "\n" read -r -p "Do you want to proceed? [y/N] " response
printf -- '-%.0s' $(seq $length); echo "" if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
printf "| $1 |\n" printf ""
printf -- '-%.0s' $(seq $length); echo "" else
exit
fi
} }
find_python(){ find_python(){
@@ -15,7 +17,23 @@ else
python=$(which python3) python=$(which python3)
pip="python3-pip" pip="python3-pip"
fi fi
echo "$python"
if [[ "$python" == *"python"* ]]; then
print_green "+ Found: $python"
else
print_yellow "Python not found!\n Exiting\n"
exit
fi
}
printm(){
length=$(expr length "$1")
length=$(($length + 4))
printf "\n"
printf -- '-%.0s' $(seq $length); echo ""
printf "| $1 |\n"
printf -- '-%.0s' $(seq $length); echo ""
} }
print_green(){ print_green(){
@@ -36,7 +54,7 @@ check_and_install_pip(){
echo "- Pip is not installed, installing it." echo "- Pip is not installed, installing it."
sudo apt install $pip sudo apt install $pip
else else
print_green "+ Found $pip" print_green "+ Found: $pip"
fi fi
} }
@@ -101,6 +119,7 @@ set_cron(){
main(){ main(){
printm "Raspberry Pi MQTT monitor installer" printm "Raspberry Pi MQTT monitor installer"
welcome
find_python find_python
check_and_install_pip check_and_install_pip
install_requirements install_requirements