-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic whiptail based script menu
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
# ============================================================================== | ||
# Copyright (c) 2019 Christian Riedel | ||
# | ||
# This file 'start_menu.bash' created 2019-11-29 is part of the project/program 'DoTH-DNS'. | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the MIT License as published by | ||
# the Massachusetts Institute of Technology. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# MIT License for more details. | ||
# | ||
# You should have received a copy of the MIT License | ||
# along with this program. If not, see <https://opensource.org/licenses/MIT>. | ||
# | ||
# Github: https://github.com/Cielquan/ | ||
# ============================================================================== | ||
|
||
|
||
err_script() { | ||
whiptail --msgbox "'start_doth_dns.bash' failed. You may need to restart the menu script with root privileges." 10 60 1 | ||
exit 1 | ||
} | ||
|
||
do_start() { | ||
./start_doth_dns.bash || err_script | ||
whiptail --msgbox "DoTH-DNS started." 10 60 1 | ||
} | ||
|
||
do_restart() { | ||
./start_doth_dns.bash -R || err_script | ||
whiptail --msgbox "DoTH-DNS restarted." 10 60 1 | ||
} | ||
|
||
do_update() { | ||
./start_doth_dns.bash -U || err_script | ||
whiptail --msgbox "DoTH-DNS update done and restarted." 10 60 1 | ||
} | ||
|
||
do_down() { | ||
./start_doth_dns.bash -D || err_script | ||
whiptail --msgbox "DoTH-DNS shut down." 10 60 1 | ||
} | ||
|
||
|
||
while true; do | ||
MENU=$(whiptail --title "DoTH-DNS menu" --menu "Choose an action for DoTH-DNS:" 20 60 4 --cancel-button Exit --ok-button Select\ | ||
"1 Start DoTH-DNS" "" \ | ||
"2 Restart DoTH-DNS" "" \ | ||
"3 Update DoTH-DNS" "" \ | ||
"4 Shut down DoTH-DNS" "" \ | ||
3>&1 1>&2 2>&3) | ||
MENU_RV=$? | ||
if [ $MENU_RV -eq 0 ]; then | ||
case "$MENU" in | ||
1\ *) do_start ;; | ||
2\ *) do_restart ;; | ||
3\ *) do_update ;; | ||
4\ *) do_down ;; | ||
*) whiptail --msgbox "Programmer error: unrecognized option" 10 60 1 ;; | ||
esac || whiptail --msgbox "There was an error running option $MENU" 10 60 1 | ||
else | ||
exit 1 | ||
fi | ||
done |