-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfirst-time
227 lines (186 loc) · 11.8 KB
/
first-time
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
225
226
227
#!/bin/bash
# first-time
##################################################################
# *** P25Link v2.40-7 ***
# Released: Jan 05, 2024. Created September 04, 2019.
# Created by: Juan Carlos Pérez De Castro (Wodie) KM4NNO, XE1F.
# www.wodielite.com
# wodielite at mac.com
##################################################################
# See LICENSE file for copyright and license details
# Based on ASL modification by mod4whip N8THN
CONFIGS=/opt/p25link
CONFIGPPATH=$CONFIGS/config.ini
MONTHDAY=$(date +%Y-%m-%d)
DATEEXT=$(date +%Y-%m-%d.%H:%M)
LOGFILE=/tmp/p25link_setup.log
do_check_if_firsttime() {
if [ -e $CONFIGS/firsttime ]; then
return
else
exit 0
fi
}
calc_wt_size() {
echo "doing calc_wt_size" >> $LOGFILE
WT_HEIGHT=22
WT_WIDTH=$(tput cols)
if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$(($WT_HEIGHT-7))
}
#################################################################################
# root/sudo test ################################################################
#################################################################################
check_if_root() {
echo "check_if_root" >> $LOGFILE
if [ `whoami` != root ]; then
whiptail --msgbox "This script must be run as root or with sudo" 20 60 2
exit 1
fi
}
#################################################################################
# Functions #####################################################################
#################################################################################
do_config() {
mkdir -p $CONFIGS/backup/$DATEEXT
cp -f $CONFIGPPATH $CONFIGS/backup/$DATEEXT/config.ini
HARDWAREMODE=$(grep '^HardwareMode =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
HARDWAREMODE=$(whiptail --inputbox "Current Harware Mode is $HARDWAREMODE, enter new Mode.\n
0 Serial Set if using KM4NNO HDLC to Serial board,
1 TCP Set if using Cisco router serial port." 12 78 "$HARDWAREMODE" --title "Hardware Mode" 3>&1 1>&2 2>&3)
MMDVM_ENABLED=$(grep '^MMDVM_Enabled =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
MMDVM_ENABLED=$(whiptail --inputbox "Current MMDVM network is $MMDVM_ENABLED, enter new mode.\n
0 No (disabled),
1 Yes (enabled)." 12 78 "$MMDVM_ENABLED" --title "MMDVM Network" 3>&1 1>&2 2>&3)
P25LINK_ENABLED=$(grep '^P25Link_Enabled =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
P25LINK_ENABLED=$(whiptail --inputbox "Current P25Link network mode is $P25LINK_ENABLED, enter new mode.\n
0 No (disabled),
1 Yes (enabled)." 12 78 "$P25LINK_ENABLED" --title "P25Link Network" 3>&1 1>&2 2>&3)
P25NX_ENABLED=$(grep '^P25NX_Enabled =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
P25NX_ENABLED=$(whiptail --inputbox "Current P25NX network is $P25NX_ENABLED, enter new mode.\n
0 No (disabled),
1 Yes (enabled)." 12 78 "$P25NX_ENABLED" --title "P25NX Network" 3>&1 1>&2 2>&3)
PRIORITYTG=$(grep '^PriorityTG =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
PRIORITYTG=$(whiptail --inputbox "Current Priority TG is $PRIORITYTG enter new Priority TG." 8 78 "$PRIORITYTG" --title "Priority TG" 3>&1 1>&2 2>&3)
MUTETGTIMEOUT=$(grep '^MuteTGTimeout =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
MUTETGTIMEOUT=$(whiptail --inputbox "Current MuteTGTimeout is $MUTETGTIMEOUT seconds, enter new MuteTGTimeout. This is the time Repeater Scan List TGs will be muted (halt), except for the TG in use by a local user." 8 78 "$MUTETGTIMEOUT" --title "MuteTGTimeout" 3>&1 1>&2 2>&3)
HANGTIME=$(grep '^Hangtime =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
HANGTIME=$(whiptail --inputbox "Current Hangtime is $HANGTIME seconds, enter new Hangtime. This is the time a dynamic TG will remain connected after the last local PTT (Default Revert timer)." 8 78 "$HANGTIME" --title "Hangtime" 3>&1 1>&2 2>&3)
USEVOICEPROMPTS=$(grep '^UseVoicePrompts =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
USEVOICEPROMPTS=$(whiptail --inputbox "Current Use Voice Prompts mode is $USEVOICEPROMPTS, enter new UseVoicePrompts mode.\n
0 No (disabled),
1 Yes (enabled)." 12 78 "$USEVOICEPROMPTS" --title "Use Voice Prompts" 3>&1 1>&2 2>&3)
USELOCALCOURTESYTONE=$(grep '^UseLocalCourtesyTone =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
USELOCALCOURTESYTONE=$(whiptail --inputbox "Current Local Courtesy Tone is $USELOCALCOURTESYTONE, enter new Local Courtesy Tone selection.\n
0 Disabled,
1 3Up Tone,
2 BeeBoo,
3 Bumblebee,
4 Nextel,
5 RC210-9,
6 RC210-10,
7 Quindar-Tone-Start,
8 Quindar-Tone-End,
9 CustomTone." 20 78 "$USELOCALCOURTESYTONE" --title "Local Courtesy Tone Selection" 3>&1 1>&2 2>&3)
USEREMOTECOURTESYTONE=$(grep '^UseRemoteCourtesyTone =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
USEREMOTECOURTESYTONE=$(whiptail --inputbox "Current Remote Courtesy Tone is $USEREMOTECOURTESYTONE, enter new Remote Courtesy Tone selection.\n
0 Disabled,
1 3Up Tone,
2 BeeBoo,
3 Bumblebee,
4 Nextel,
5 RC210-9,
6 RC210-10,
7 Quindar-Tone-Start,
8 Quindar-Tone-End,
9 CustomTone." 20 78 "$USEREMOTECOURTESYTONE" --title "Remote Courtesy Tone Selection" 3>&1 1>&2 2>&3)
RADIOID=$(grep '^RadioID =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
RADIOID=$(whiptail --inputbox "Current RadioID is $RADIOID, enter new RadioID." 8 78 "$RADIOID" --title "RadioID" 3>&1 1>&2 2>&3)
CALLSIGN=$(grep '^Callsign =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
CALLSIGN=$(whiptail --inputbox "Current Callsign is $CALLSIGN, enter new Callsign with no suffix." 8 78 "$CALLSIGN" --title "Callsign" 3>&1 1>&2 2>&3)
SUFFIX=$(grep '^Suffix =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
SUFFIX=$(whiptail --inputbox "Current APRS Suffix is $SUFFIX enter new Suffix." 8 78 "$SUFFIX" --title "APRS Suffix" 3>&1 1>&2 2>&3)
PASSCODE=$(grep '^Passcode =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
PASSCODE=$(whiptail --inputbox "Current APRS Passcode is $PASSCODE, enter new Passcode." 8 78 "$PASSCODE" --title "APRS Passcode" 3>&1 1>&2 2>&3)
# LATITUDE=$(grep '^Latitude =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
LATITUDE=$(whiptail --inputbox "Current Latitude is $LATITUDE, enter new Latitude in decimal degrees." 8 78 "$LATITUDE" --title "Latitude" -- ${LATITUDE} 3>&1 1>&2 2>&3)
# LONGITUDE=$(grep '^Longitude =' /$CONFIGS/config.ini | awk -F'=' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{10\}\).*/\1/')
# LONGITUDE=$(whiptail --inputbox "Current Longitude is $LONGITUDE, enter new Longitude in decimal degrees." 8 78 "$LONGITUDE" --title "Longitude" 3>&1 1>&2 2>&3)
LONGITUDE=$(whiptail --inputbox "Current Longitude is $LONGITUDE, enter new Longitude in decimal degrees." 8 78 "$LONGITUDE" --title "Longitude" -- ${LONGITUDE} 3>&1 1>&2 2>&3)
SYMBOL=$(grep '^Symbol =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{2\}\).*/\1/')
SYMBOL=$(whiptail --inputbox "Current APRS Symbol is $SYMBOL enter new Symbol." 8 78 "$SYMBOL" --title "Symbol" 3>&1 1>&2 2>&3)
ALTITUDE=$(grep '^Altitude =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
ALTITUDE=$(whiptail --inputbox "Current Altitude is $ALTITUDE, enter new Altitude in meters." 8 78 "$ALTITUDE" --title "Altitude" 3>&1 1>&2 2>&3)
FREQUENCY=$(grep '^Frequency =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
FREQUENCY=$(whiptail --inputbox "Current Frequency is $FREQUENCY enter new Frequencyin MHz (i.e. 445.000)." 8 78 "$FREQUENCY" --title "Frequency" 3>&1 1>&2 2>&3)
ACCESSTONE=$(grep '^AccessTone =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
ACCESSTONE=$(whiptail --inputbox "Current Access Tone is $ACCESSTONE, enter new Tone with APRS QSY format. UperCase for 25 KHz bandwidth and lowercase for 12.5 KHz bandwidth.\n T/t for Tone & SQL,\n C/c for Tone up and down\n D/d for Digital tone.\nUse only 3 digits format with no decimanls (i.e. d023 C123)." 12 78 "$ACCESSTONE" --title "Repeater Access Tone" 3>&1 1>&2 2>&3)
OFFSET=$(grep '^Offset =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
OFFSET=$(whiptail --inputbox "Current Offset is $OFFSET enter new Offset preceded with sign (i.e. +500 for UHF -060 for VHF)." 8 78 "$OFFSET" --title "Offset" 3>&1 1>&2 2>&3)
NAC=$(grep '^NAC =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}')
NAC=$(whiptail --inputbox "Current NAC is $NAC, enter new NAC." 8 78 "$NAC" --title "NAC" 3>&1 1>&2 2>&3)
APRSCOMMENT=$(grep '^APRSComment =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{44\}\).*/\1/'|sed 's/ //g')
APRSCOMMENT=$(whiptail --inputbox "Current APRS Comment is $APRSCOMMENT, enter new Comment (max 43 char, no spaces allowed, use underscore)." 8 78 "$APRSCOMMENT" --title "APRS Comment" 3>&1 1>&2 2>&3)
SITENAME=$(grep '^SiteName =' /$CONFIGS/config.ini | awk -F'=' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{31\}\).*/\1/'|sed 's/ //g')
SITENAME=$(whiptail --inputbox "Current site name is $SITENAME, enter new name (max 30 char, no spaces allowed, use underscore)." 8 78 "$SITENAME" --title "Site Name" 3>&1 1>&2 2>&3)
SITEINFO=$(grep '^SiteInfo =' /$CONFIGS/config.ini | awk -F'= ' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{31\}\).*/\1/'|sed 's/ //g')
SITEINFO=$(whiptail --inputbox "Current site information is $SITEINFO, enter new information (max 30 char, no spaces allowed, use underscore)." 8 78 "$SITEINFO" --title "Site Info" 3>&1 1>&2 2>&3)
sed -i 's/HardwareMode =.*/HardwareMode = '$HARDWAREMODE'/' $CONFIGS/config.ini
sed -i 's/MMDVM_Enabled =.*/MMDVM_Enabled = '$MMDVM_ENABLED'/' $CONFIGS/config.ini
sed -i 's/P25Link_Enabled =.*/P25Link_Enabled = '$P25LINK_ENABLED'/' $CONFIGS/config.ini
sed -i 's/P25NX_Enabled =.*/P25NX_Enabled = '$P25NX_ENABLED'/' $CONFIGS/config.ini
sed -i 's/PriorityTG =.*/PriorityTG = '$PRIORITYTG'/' $CONFIGS/config.ini
sed -i 's/MuteTGTimeout =.*/MuteTGTimeout = '$MUTETGTIMEOUT'/' $CONFIGS/config.ini
sed -i 's/Hangtime =.*/Hangtime = '$HANGTIME'/' $CONFIGS/config.ini
sed -i 's/UseVoicePrompts =.*/UseVoicePrompts = '$USEVOICEPROMPTS'/' $CONFIGS/config.ini
sed -i 's/UseLocalCourtesyTone =.*/UseLocalCourtesyTone = '$USELOCALCOURTESYTONE'/' $CONFIGS/config.ini
sed -i 's/UseRemoteCourtesyTone =.*/UseRemoteCourtesyTone = '$USEREMOTECOURTESYTONE'/' $CONFIGS/config.ini
sed -i 's/RadioID =.*/RadioID = '$RADIOID'/' $CONFIGS/config.ini
sed -i 's/Callsign =.*/Callsign = '$CALLSIGN'/' $CONFIGS/config.ini
sed -i 's/Suffix =.*/Suffix = '$SUFFIX'/' $CONFIGS/config.ini
sed -i 's/Passcode =.*/Passcode = '$PASSCODE'/' $CONFIGS/config.ini
echo " General config done."
sed -i 's/Latitude =.*/Latitude = '$LATITUDE'/' $CONFIGS/config.ini
sed -i 's/Longitude =.*/Longitude = '$LONGITUDE'/' $CONFIGS/config.ini
echo " Lat Long done."
sed -i 's/Symbol =.*/Symbol = '$SYMBOL'/' $CONFIGS/config.ini
echo " Symbol $SYMBOL done."
sed -i 's/Altitude =.*/Altitude = '$ALTITUDE'/' $CONFIGS/config.ini
sed -i 's/Frequency =.*/Frequency = '$FREQUENCY'/' $CONFIGS/config.ini
echo " ALt. and Freq. done."
sed -i 's/AccessTone =.*/AccessTone = '$ACCESSTONE'/' $CONFIGS/config.ini
sed -i 's/Offset =.*/Offset = '$OFFSET'/' $CONFIGS/config.ini
echo " Tone and Offset done."
sed -i 's/NAC =.*/NAC = '$NAC'/' $CONFIGS/config.ini
echo " NAC done."
sed -i 's/APRSComment =.*/APRSComment = '$APRSCOMMENT'/' $CONFIGS/config.ini
echo " APRS Comment done."
sed -i 's/SiteName =.*/SiteName = '$SITENAME'/' $CONFIGS/config.ini
echo " Site name done."
sed -i 's/SiteInfo =.*/SiteInfo = '$SITEINFO'/' $CONFIGS/config.ini
echo " Site info done."
P25LINK_RESTART=1
}
#################################################################################
# Main body here ################################################################
#################################################################################
#do_check_if_firsttime
check_if_root
if (whiptail --title "First time setup" --yesno "First time setup.\n\nDo you want to do this now?" --defaultno 15 78) then
ANSWER=$?
else
ANSWER=$?
fi
if [ $ANSWER = 1 ]
then
whiptail --msgbox "You can run this setup at any time later" 8 78
exit 0
else
calc_wt_size
do_config
fi