#!/bin/bash
# run command (sudo nano ~/.bash_profile) and add this (PATH=$PATH:/home/usr/bin) without ()
# to be able to execute menu.sh from any directory
# place menu.sh file in /home/usr/bin
# replace usr with your username
# running ubuntu server 17.10 and openhabian
while true
do
clear
echo "======================"
echo "-------- Menu --------"
echo "======================"
echo "1: OpenHAB2 Start"
echo "2: OpenHAB2 Stop"
echo "3: OpenHAB2 Status"
echo "4: OpenHAB2 Restart"
echo "5: Openhabian Config"
echo "6: Karaf Console"
echo "7: Tail Events log"
echo "8: Tail OpenHAB log"
echo "9: Backup Openhab2"
echo "10: Info"
echo ""
echo "Press any key to Quit"
read answer
case "$answer" in
1) clear
echo "Starting OpenHAB2..."
sudo systemctl start openhab2.service
;;
2) clear
echo "Stopping OpenHAB2..."
sudo systemctl stop openhab2.service
echo "Stopped"
;;
3) clear
echo "Status OpenHAB2"
sudo systemctl status openhab2.service
;;
4) clear
echo "Restarting OpenHAB2..."
sudo systemctl restart openhab2.service
echo "Restarted"
;;
5) echo "Openhabian Config"
sudo openhabian-config
;;
6) echo "OpenHAB Karaf Console"
openhab-cli console
;;
7) echo "Tailing EVENTS LOG"
tail -f /var/log/openhab2/events.log
;;
8) echo "Tailing OPENHAB LOG"
tail -f /var/log/openhab2/openhab.log
;;
9) echo "Are You Sure? "Y", any other key to exit "
read input
if [ "$input" != "Y" ]; then
echo "you have fat fingers"
exit
fi
if [ "$input" == "Y" ]; then
echo "Backing up OpenHAB"
sudo openhab-cli backup
fi
;;
10) echo "Info"
sudo openhab-cli info
;;
esac
break
done
2 Likes
Hi @alokin79, good idea! What are your thoughts on adding a menu like this for the cli itself? One that could be launched via openhab-cli menu
for example which would go over all of the cli commands.
1 Like
I like it. Maybe the menu like this would be the default when you just run openhab-cli
. It makes the cli pretty self-documenting that way.