-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathradmin
executable file
·224 lines (213 loc) · 5.68 KB
/
radmin
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/bash
#
# Copyright (c) 2020 by Thomas A. Early N7TAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
trap ControlC INT
ControlC () {
echo "caught SIGINT"
}
UninstallReflector () {
if [ -e $xlxserv ] || [ -e $xrfserv ]; then
cd src
sudo make uninstall
cd ..
fi
if [ -e $ambserv ]; then
cd ambed
sudo make uninstall
cd ..
fi
}
InstallReflector () {
if [ "$tcaddress" != none ]; then
cd ambed
sudo make install || read -p "<Enter> to continue: " ans
cd ..
fi
cd src
if [[ "$callsign" == XLX* ]]; then
if [ ! -e xlxd.whitelist ]; then
cp ../config/xlxd.whitelist .
fi
if [ ! -e xlxd.blacklist ]; then
cp ../config/xlxd.blacklist .
fi
if [ ! -e xlxd.interlink ]; then
cp ../config/xlxd.interlink .
fi
if [[ "$g3support" == true ]] && [ ! -e xlxd.terminal ]; then
cp ../config/xlxd.terminal .
fi
else
if [ ! -e xrfd.whitelist ]; then
cp ../config/xlxd.whitelist xrfd.whitelist
fi
if [ ! -e xrfd.blacklist ]; then
cp ../config/xlxd.blacklist xrfd.blacklist
fi
if [ ! -e xrfd.interlink ]; then
cp ../config/xlxd.interlink xrfd.interlink
fi
if [[ "$g3support" == true ]] && [ ! -e xrfd.terminal ]; then
cp ../config/xlxd.terminal xrfd.terminal
fi
fi
sudo make install || read -p "<Enter> to continue: " ans
cd ..
}
Clean () {
cd src
make clean
cd ../ambed
make clean
cd ..
}
Compile () {
local np
np=`getconf _NPROCESSORS_ONLN`
cd src
make -j$np || read -p "<Enter to continue: " ans
cd ..
if [[ "$callsign" == XLX* ]] && [[ "$tcaddress" != none ]]; then
cd ambed
make -j$np || read -p "<Enter to continue: " ans
cd ..
fi
}
# Execution starts here!
# service file locations
xlxserv='/etc/systemd/system/xlxd.service'
xrfserv='/etc/systemd/system/xrfd.service'
ambserv='/etc/systemd/system/ambed.service'
# default values, we only need a few
#callsign='CHNGME'
#nummod=26
#ip4addr='none'
#ip6addr='none'
tcaddress='none'
#tcmodules='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
#ysfenable=false
#ysfmodule='D'
g3support=false
#dbsupport=false
if [ -e reflector.cfg ]; then
source reflector.cfg
else
echo 'No configuration file found...'
exit 1
fi
key='x'
# main loop
while [[ "$key" != q* ]]
do
clear
pcount=$(ps -aux | grep -e xlxd -e xrfd -e ambed | wc -l)
if [ "$pcount" -gt 1 ]; then
echo
ps -aux | head -1
ps -aux | grep -e xlxd -e xrfd -e ambed | grep -v grep
fi
echo
echo " Reflector Administration, Version #210127"
echo
git status | head -1
echo
echo "ls : List the configuration file"
echo "cl : Clean (remove) compiled objects and executables"
echo "gp : Pull the latest software from the repo"
echo "br : Change git branch to <value>"
echo "co : Compile the system executable(s)"
if [ -e $xlxserv ] || [ -e $xrfserv ]; then
if [ -e $xlxserv ] && [ -e $xrfserv ]; then
echo "ERROR: both xlxd and xrfd seem to be installed!"
exit 1
elif [ -e $xlxserv ]; then
echo "us : Uninstall the XLX reflector"
echo "rl : Reflector log"
if [ -e $ambserv ]; then
echo "tl : Transcoder log"
fi
elif [ -e $xrfserv ]; then
echo "us : Uninstall the XRF reflector"
echo "rl : Reflector log"
fi
echo "rr : Reflector restart"
if [ -e $ambserv ]; then
echo "tr : Transcoder restart"
fi
else
if [[ "$callsign" == XRF* ]] || [[ "$callsign" == XLX* ]]; then
if [[ "$callsign" == XRF* ]] && [ -e src/xrfd ]; then
echo "is : Install XRF reflector"
elif [[ "$callsign" == XLX* ]] && [ -e src/xlxd ]; then
if [[ "$tcaddress" == none ]]; then
echo "is : Install XLX reflector without transcoder"
else
if [ -e ambed/ambed ]; then
echo "is : Install XLX reflector and transcoder"
fi
fi
fi
fi
fi
echo
echo "q : Quit"
echo
read -p "Please input <key> <value> - omit value to toggle a true/false : " key value garbage
if [[ "$key" == ls* ]]; then
cat reflector.cfg;
echo
read -p "<Enter> to return to main menu: " ans
elif [[ "$key" == us* ]]; then
if [[ "$callsign" == XLX* ]] && [ -e $xlxserv ]; then
UninstallReflector
elif [[ "$callsign" == XRF* ]] && [ -e $xrfserv ]; then
UninstallReflector
fi
elif [[ "$key" == is* ]]; then
if [[ "$callsign" == XLX* ]] && [ -e src/xlxd ] && [ ! -e $xlxserv ] && [ ! -e $xrfserv ]; then
InstallReflector
elif [[ "$callsign" == XRF* ]] && [ -e src/xrfd ] && [ ! -e $xlxserv ] && [ ! -e $xrfserv ]; then
InstallReflector
fi
elif [[ "$key" == gp* ]]; then
echo
git pull
echo
read -p "<Enter> to continue: " ans
elif [[ "$key" == br* ]]; then
echo
git checkout "$value"
echo
read -p "<Enter> to continue: " ans
elif [[ "$key" == rr* ]]; then
if [[ "$callsign" == XLX* ]] && [ -e $xlxserv ]; then
sudo systemctl restart xlxd
elif [[ "$callsign" == XRF* ]] && [ -e $xrfserv ]; then
sudo systemctl restart xrfd
fi
elif [[ "$key" == tr* ]] && [ -e $ambserv ]; then sudo systemctl restart ambed
elif [[ "$key" == cl* ]]; then Clean
elif [[ "$key" == co* ]]; then Compile
elif [[ "$key" == tl* ]] && [ -e $ambserv ]; then sudo journalctl -u ambed -f
elif [[ "$key" == rl* ]]; then
if [ -e $xlxserv ]; then
sudo journalctl -u xlxd -f
elif [ -e $xrfserv ]; then
sudo journalctl -u xrfd -f
fi
fi
done
exit 0