This commit is contained in:
hjelev
2022-03-20 22:29:38 +02:00
parent 294c53c2de
commit 070c2b629d

View File

@@ -1,7 +1,7 @@
welcome(){ welcome(){
echo "This script will install if not installed: Pip and python module paho-mqtt." echo " This script will install if not installed: Pip and python module paho-mqtt,"
echo "Configure Raspberry Pi MQTT monitor and create a cronjob to run it." echo " configure Raspberry Pi MQTT monitor and create a cronjob to run it."
read -r -p "Do you want to proceed? [y/N] " response read -r -p " Do you want to proceed? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
printf "" printf ""
else else
@@ -31,9 +31,9 @@ printm(){
length=$(expr length "$1") length=$(expr length "$1")
length=$(($length + 4)) length=$(($length + 4))
printf "\n" printf "\n"
printf -- '-%.0s' $(seq $length); echo "" #printf -- '-%.0s' $(seq $length); echo ""
printf "| $1 |\n" printf ":: $1 \n\n"
printf -- '-%.0s' $(seq $length); echo "" #printf -- '-%.0s' $(seq $length); echo ""
} }
print_green(){ print_green(){
@@ -63,7 +63,7 @@ install_requirements(){
} }
update_config(){ update_config(){
printf "\nCopy config.py.example to config.py\n" print_green "+ Copy config.py.example to config.py"
cp src/config.py.example src/config.py cp src/config.py.example src/config.py
printm "MQTT settings" printm "MQTT settings"
@@ -93,7 +93,7 @@ update_config(){
fi fi
sed -i "s/rpi-MQTT-monitor/${TOPIC}/" src/config.py sed -i "s/rpi-MQTT-monitor/${TOPIC}/" src/config.py
printf "\nconfig.py is updated with provided settings\n" print_green "+ config.py is updated with provided settings"
} }
set_cron(){ set_cron(){
@@ -102,7 +102,7 @@ set_cron(){
crontab -l > tempcron crontab -l > tempcron
if grep -q rpi-cpu2mqtt.py tempcron; then if grep -q rpi-cpu2mqtt.py tempcron; then
cronfound=$(grep rpi-cpu2mqtt.py tempcron) cronfound=$(grep rpi-cpu2mqtt.py tempcron)
print_yellow " There is already a cronjob running rpi-cpu2mqtt.py - skipping cronjob creation\n" print_yellow " There is already a cronjob running rpi-cpu2mqtt.py - skipping cronjob creation.\n"
print_yellow " If you want the cronjob to be automatically created remove the line below from your\n cronjobs list and run the installer again.\n\n" print_yellow " If you want the cronjob to be automatically created remove the line below from your\n cronjobs list and run the installer again.\n\n"
echo " ${cronfound}" echo " ${cronfound}"
else else