-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathconfig_module.sh
executable file
·184 lines (176 loc) · 5.05 KB
/
config_module.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
source pakuri.conf
source $MODULES_PATH/misc_module.sh
# Start Service
function service_start()
{
sudo systemctl start $1
}
# Stop Service
function service_stop()
{
sudo systemctl stop $1
}
# Change CUI/GUI
function modeswitching()
{
local mode
local mode_v
local KEY
while :
do
mode=`systemctl get-default`
if [ "graphical.target" = $mode ]; then
mode_v="GUI"
else
mode_v="CUI"
fi
clear
config_banner
box_4 "Mode Switching"
echo -e "--------- Now mode $mode_v ---------"
select_2 "Switch CUI mode" "Switch GUI mode"
read -n 1 -s KEY
clear
config_banner
box_4 "Mode Switching"
echo -e "--------- Now mode $mode_v ---------"
case "$KEY" in
1 )
box_1 "Switch CUI mode"
echo -e "CUI mode is enabled after a reboot"
systemctl set-default -f multi-user.target ;;
2 )
box_2 "Switch GUI mode"
echo -e "GUI mode is enabled after a reboot"
systemctl set-default -f graphical.target ;;
9 )
break ;;
* )
echo -e "error" ;;
esac
read -p "Press Enter to continue..."
done
}
function service_menu()
{
local flg_p
local flg_o
local KEY
local Ans
while :
do
if systemctl status postgresql|grep "active (exited)" >/dev/null ;then
flg_p=1
else
flg_p=0
fi
if ps -ef|grep [o]penvas > /dev/null; then
flg_o=1
else
flg_o=0
fi
clear
config_banner
box_2 "Configure Service"
echo -e "-------- Service Menu ----------"
if [ $flg_p = 1 ];then
box_1 "PpstgreSQL ${NC}[${GREEN_b}Running${NC}]"
else
box_1 "PostgreSQL ${NC}[${RED_b}DOWN${NC}]"
fi
if [ $flg_o = 1 ];then
box_2 "OpenVAS ${NC}[${GREEN_b}Running${NC}]"
else
box_2 "OpenVAS ${NC}[${RED_b}DOWN${NC}]"
fi
box_9
read -n 1 -s KEY
clear
config_banner
box_2 "Configure Service"
echo -e "-------- Service Menu ----------"
case "$KEY" in
1 )
if [ $flg_p = 1 ];then
box_1 "PpstgreSQL ${NC}[${GREEN_b}Running${NC}]"
echo -e "Do you want it to ${RED_b}stop${NC}?"
yes-no
read -n 1 -s Ans
if [ $Ans -eq 1 ];then
service_stop postgresql
fi
else
box_1 "PostgreSQL ${NC}[${RED_b}DOWN${NC}]"
echo -e "Do you want it to ${GREEN_b}start${NC}?"
yes-no
read -n 1 -s Ans
if [ $Ans -eq 1 ];then
service_start postgresql
fi
fi ;;
2 )
if [ $flg_o = 1 ];then
box_2 "OpenVAS ${NC}[${GREEN_b}Running${NC}]"
echo -e "Do you want it to ${RED_b}stop${NC}?"
yes-no
read -n 1 -s Ans
if [ $Ans -eq 1 ];then
tmux send-keys -t $WINDOW_NAME.1 "sudo openvas-stop" C-m
tmux select-pane -t $SESSION_NAME.0
fi
else
box_2 "OpenVAS ${NC}[${RED_b}DOWN${NC}]"
echo -e "Do you want it to ${GREEN_b}start${NC}?"
yes-no
read -n 1 -s Ans
if [ $Ans -eq 1 ];then
tmux send-keys -t $WINDOW_NAME.1 "sudo openvas-start" C-m
tmux select-pane -t $SESSION_NAME.0
fi
fi ;;
9 )
break ;;
esac
done
}
# Config main menu
function config_manage()
{
local KEY
while :
do
clear
config_banner
select_4 "Configure Targets" "Configure Service" "Mode Switching" "Help"
read -n 1 -t 25 -s KEY
clear
config_banner
case "$KEY" in
1 )
box_1 "Configure Targets"
tmux send-keys -t $SESSION_NAME.1 "nano $TARGETS;tmux select-pane -t $SESSION_NAME.0" C-m
tmux select-pane -t $SESSION_NAME.1
echo -e "Input your targets."
echo -e "This is an edit using nano. After editing, press Ctrl+X to save and exit."
echo -e ""
read -p "Press Enter to continue..."
;;
2 )
box_2 "Configure Service"
echo -e "-------- Service Menu ----------"
service_menu
;;
3 )
modeswitching ;;
4 )
tmux send-keys -t $WINDOW_NAME.1 "$MODULES_PATH/help/config_help_module.sh main" C-m
tmux select-pane -t $WINDOW_NAME.0 ;;
9 )
tmux select-window -t "${modules[0]}" ;;
* )
;;
esac
done
}
config_manage