22
33# # Install the Grott proxy server on the current system
44# #
5- # # install_grott(String openhab-ip-address , String username, String interactive )
5+ # # install_grott(String install|remove , String username, String openhab-ip-address )
66# #
77install_grott () {
88 # Validate install type argument
@@ -43,7 +43,7 @@ install_grott() {
4343 EXT_URL=" http://$3 :8080/growatt"
4444
4545 echo -n " [openHABian] Installing Grott Proxy with extension URL: $EXT_URL "
46-
46+
4747 # Update system and install dependencies
4848 sudo apt update
4949 sudo apt install -y python3 python3-pip
@@ -55,10 +55,10 @@ install_grott() {
5555 echo " Error: Installation directory $INSTALL_DIR does not exist."
5656 exit 1
5757 fi
58-
59- download_grott_files || {
60- echo " Failed to download Grott files. Exiting."
61- return 1
58+
59+ download_grott_files || {
60+ echo " Failed to download Grott files. Exiting."
61+ return 1
6262 }
6363
6464 # Create grott.service systemd file from template
@@ -67,14 +67,14 @@ install_grott() {
6767 " ${BASEDIR:-/ opt/ openhabian} /includes/grott.service" > " $SERVICE_FILE " ; then
6868 echo " FAILED (sed substitution)"
6969 return 1
70- fi
71-
70+ fi
71+
7272 # Create grott.ini file from template
7373 if ! sed -e " s|%EXT_URL|$EXT_URL |g" \
7474 " ${BASEDIR:-/ opt/ openhabian} /includes/grott.ini" > " $INSTALL_DIR /grott.ini" ; then
7575 echo " FAILED (sed substitution)"
7676 return 1
77- fi
77+ fi
7878
7979 # Enable and start service
8080 sudo systemctl daemon-reexec
@@ -86,10 +86,10 @@ install_grott() {
8686 fi
8787
8888 return 0
89-
89+
9090 elif [[ $INSTALL_TYPE == " remove" ]]; then
9191 echo -n " [openHABian] Removing Grott Proxy... "
92-
92+
9393 # Stop and disable systemd service
9494 if sudo systemctl is-active --quiet grott; then
9595 sudo systemctl stop grott
@@ -116,7 +116,7 @@ install_grott() {
116116 if [[ -n " $INTERACTIVE " ]]; then
117117 whiptail --title " Grott Proxy removed" --msgbox " We removed Grott Proxy from your system." 7 80
118118 fi
119-
119+
120120 return 0
121121 fi
122122}
0 commit comments