-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.sh
96 lines (89 loc) · 2.01 KB
/
menu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
stty erase ^H
# Files included
source colors
source functions
source vars
if [[ $EUID -ne 0 ]]; then
echo -e "------------------------------------------------------------------"
echo -e "$(color_red 'must be run as root.')"
echo -e "------------------------------------------------------------------"
exit 1
fi
submenu_p() {
echo -ne "
$(color_red 'Plugins')
$(color_green '1)') Install
$(color_green '2)') Remove
$(color_green '0)') Exit
$(color_blue 'Choose an option:')"
read -r ans
case $ans in
1) install_plugin ; submenu_p ;;
2) remove_plugin ; submenu_p ;;
3) mainmenu ;;
0) bye ;;
*) fail ;;
esac
}
submenu_c() {
echo -ne "
$(color_red 'Configure')
$(color_green '1)') LDAP
$(color_green '2)') SSO
$(color_green '3)') Go Back to Main Menu
$(color_green '0)') Exit
$(color_blue 'Choose an option:')"
read -r ans
case $ans in
1) ldap ; submenu_c ;;
2) sso ; submenu_c ;;
3) mainmenu ;;
0) bye ;;
*) fail ;;
esac
}
submenu_b() {
echo -ne "
$(color_red 'Backup')
$(color_green '1)') Full
$(color_green '2)') Schema-Only
$(color_green '3)') Schedule job
$(color_green '4)') Go Back to Main Menu
$(color_green '0)') Exit
$(color_blue 'Choose an option:')"
read -r ans
case $ans in
1) full_backup ; submenu_b ;;
2) schema_only_backup ; submenu_b ;;
3) schedule_job ; submenu_b ;;
4) mainmenu ;;
0) bye ;;
*) fail ;;
esac
}
mainmenu() {
echo -ne "
$(color_red 'MAIN MENU')
$(color_green '1)') Install
$(color_green '2)') Update
$(color_green '3)') Plugins
$(color_green '4)') Configure
$(color_green '5)') Backup
$(color_green '6)') Restore
$(color_green '0)') Exit
$(color_blue 'Choose an option:')"
read -r ans
case $ans in
1) install_netbox ; mainmenu ;;
2) update_netbox ; mainmenu ;;
3) submenu_p ; mainmenu ;;
4) submenu_c ; mainmenu ;;
5) submenu_b ; mainmenu ;;
6) restore ; mainmenu ;;
0) bye ;;
*) fail ;;
esac
}
# Call menu function
mainmenu