forked from nostar/urfd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradmin
executable file
·192 lines (181 loc) · 4.38 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
#!/bin/bash
#
# Copyright (c) 2021 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 3 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 $urfserv ]; then
pushd reflector
sudo make uninstall
popd
fi
if [ -e $tcdserv ]; then
pushd ../tcd
sudo make uninstall
popd
fi
}
InstallReflector () {
if [ "$tcaddress" != none ]; then
pushd ../tcd
sudo make install || read -p "<Enter> to continue: " ans
popd
fi
pushd reflector
if [ ! -e urfd.whitelist ]; then
cp ../config/urfd.whitelist .
fi
if [ ! -e urfd.blacklist ]; then
cp ../config/urfd.blacklist .
fi
if [ ! -e urfd.interlink ]; then
cp ../config/urfd.interlink .
fi
if [[ "$g3support" == true ]] && [ ! -e urfd.terminal ]; then
cp ../config/urfd.terminal .
fi
sudo make install || read -p "<Enter> to continue: " ans
popd
}
Clean () {
pushd reflector
make clean
popd
pushd ../tcd
make clean
popd
}
Compile () {
local np
np=`getconf _NPROCESSORS_ONLN`
pushd reflector
make -j$np || read -p "<Enter to continue: " ans
popd
if [[ "$tcaddress" != none ]]; then
pushd ../tcd
make -j$np || read -p "<Enter to continue: " ans
popd
fi
}
# Execution starts here!
# service file locations
urfserv='/etc/systemd/system/urfd.service'
tcdserv='/etc/systemd/system/tcd.service'
# default values, we only need a few
tcaddress='none'
g3support=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 urfd -e tcd | wc -l)
if [ "$pcount" -gt 1 ]; then
echo
ps -aux | head -1
ps -aux | grep -e urfd -e tcd | grep -v grep
fi
echo
echo " Reflector Administration, Version #211204"
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 $urfserv ]; then
if [ -e $urfserv ]; then
echo "us : Uninstall the URF reflector"
echo "rl : Reflector log"
if [ -e $tcdserv ]; then
echo "tl : Transcoder log"
fi
fi
echo "rr : Reflector restart"
if [ -e $tcdserv ]; then
echo "tr : Transcoder restart"
fi
else
if [[ "$callsign" == URF* ]]; then
if [ -e reflector/urfd ]; then
if [[ "$tcaddress" == none ]]; then
echo "is : Install URF reflector without transcoder"
else
if [ -e ../tcd/tcd ]; then
echo "is : Install URF 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 [ -e $urfserv ]; then
UninstallReflector
fi
elif [[ "$key" == is* ]]; then
if [ -e reflector/urfd ] && [ ! -e $urfserv ]; then
InstallReflector
fi
elif [[ "$key" == gp* ]]; then
echo
git pull
echo
read -p "<Enter> to continue: " ans
pushd ../tcd
git pull
echo
read -p "<Enter> to continue: " ans
popd
elif [[ "$key" == br* ]]; then
echo
git checkout "$value"
echo
read -p "<Enter> to continue: " ans
pushd ../tcd
git checkout "$value"
echo
read -p "<Enter> to continue: " ans
popd
elif [[ "$key" == rr* ]]; then
if [ -e $urfserv ]; then
sudo systemctl restart urfd
fi
elif [[ "$key" == tr* ]] && [ -e $tcdserv ]; then sudo systemctl restart tcd
elif [[ "$key" == cl* ]]; then Clean
elif [[ "$key" == co* ]]; then Compile
elif [[ "$key" == tl* ]] && [ -e $tcdserv ]; then sudo journalctl -u tcd -f
elif [[ "$key" == rl* ]] && [ -e $urfserv ]; then sudo journalctl -u urfd -f
fi
done
exit 0