From 1a422aeededcc5483c7d0d3a55f66bc5616cbed7 Mon Sep 17 00:00:00 2001 From: hjelev Date: Sat, 19 Mar 2022 01:10:29 +0200 Subject: [PATCH] update --- install.sh | 21 +++++++++------------ remote_install.sh | 14 ++++++++------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/install.sh b/install.sh index 46d3b76..3395bc7 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -printm () { +printm(){ length=$(expr length "$1") length=$(($length + 4)) printf "\n" @@ -7,19 +7,19 @@ printm () { printf -- '-%.0s' $(seq $length); echo "" } -print_green () { +print_green(){ tput setaf 2; echo "$1" tput sgr 0 } -print_yellow () { +print_yellow(){ tput setaf 3; printf "$1" tput sgr 0 } printm "Raspberry Pi MQTT monitor installer" -check_and_install_pip () { +check_and_install_pip(){ cwd=$(pwd) python=$(which python) pip=$(python -m pip --version 2>&1); @@ -31,19 +31,16 @@ check_and_install_pip () { fi } -install_requirements () { +install_requirements(){ printm "Installing requirements" pip install -r requirements.txt } -update_config () { +update_config(){ printf "\nCopy config.py.example to config.py\n" - cp src/config.py.example src/config.py - printm "MQTT settings" - - + printf "Enter mqtt_host: " read HOST sed -i "s/ip address or host/${HOST}/" src/config.py @@ -73,7 +70,7 @@ update_config () { printf "\nconfig.py is updated with provided settings\n" } -set_cron () { +set_cron(){ printm "Setting Cronjob" crontab -l > tempcron @@ -95,7 +92,7 @@ set_cron () { rm tempcron } -main () { +main(){ check_and_install_pip install_requirements update_config diff --git a/remote_install.sh b/remote_install.sh index 50acc5a..00f8fb1 100755 --- a/remote_install.sh +++ b/remote_install.sh @@ -1,5 +1,5 @@ #!/bin/bash -printm () { +printm(){ length=$(expr length "$1") length=$(($length + 4)) printf "\n" @@ -8,8 +8,10 @@ printm () { printf -- '-%.0s' $(seq $length); echo "" } -printm "Cloning rpi-mqtt-monitor git repository" - -git clone https://github.com/hjelev/rpi-mqtt-monitor.git -cd rpi-mqtt-monitor -bash install.sh +main(){ + printm "Cloning rpi-mqtt-monitor git repository" + git clone https://github.com/hjelev/rpi-mqtt-monitor.git + cd rpi-mqtt-monitor + bash install.sh +} +main