-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid2app.sh
executable file
·209 lines (180 loc) · 6.71 KB
/
grid2app.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
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
#!/usr/bin/env bash
# This script will update the following apps with your current grid square
# requires gpsd2grid.py and sudo apt-get install crudini
# by K7MHI Kelly Keeton 2023
# Version 1.0.5
#user variables
BACKUP=0 #set to 1 to enable config backups ideal for inital confirmations but leave off for daily use
#run cgps to monitor accuisition on console? need to to exit app
WATCH_CGPS=0
#Watch GPSD with cgps if enabled
if [ $WATCH_CGPS -eq 1 ];then
echo "Running cgps to monitor GPSD, 'q' to exit"
echo
if [ -f /usr/bin/cgps ];then
cgps
fi
fi
#Set Grid to tempfile for conky
python3 gpsd2grid.py > /run/user/1000/gridinfo.txt
#Set $GRID for Ham Apps
GRID=$(cat /run/user/1000/gridinfo.txt)
#Check for GPSD Errors and halt if found
if grep "NOFIX" /run/user/1000/gridinfo.txt || [ -z "$GRID" ] || [ ! -f /run/user/1000/gridinfo.txt ];then
echo "GPSD Error, NO-GPS-FIX"
exit 1
else
echo "Setting Ham Apps to Grid: $GRID"
fi
# Handler for .ini files
if [[ $(whereis crudini | grep bin) ]];then
if [ -f ~/.wine/drive_c/RMS\ Express/RMS\ Express.ini ];then
echo "RMS Express.ini found, updating"
#Check for mycall
if [ -f ~/.grid2app.mycall ];then
CALL=$(cat ~/.grid2app.mycall)
echo "using profile for $CALL"
else
read -p "Enter your CALLSIGN for RMS profile: " CALL
echo $CALL > ~/.grid2app.mycall
fi
#Set RMS Express
if [ $BACKUP -eq 1 ];then
cp ~/.wine/drive_c/RMS\ Express/RMS\ Express.ini ~/.wine/drive_c/RMS\ Express/RMS\ Express.ini.bak
fi
crudini --set ~/.wine/drive_c/RMS\ Express/RMS\ Express.ini $CALL 'Grid Square' $GRID
fi
if [ -f ~/.config/WSJT-X.ini ];then
echo "WSJT-X.ini found, updating"
#Set WSJT
if [ $BACKUP -eq 1 ];then
cp ~/.config/WSJT-X.ini ~/.config/WSJT-X.ini.bak
fi
crudini --set ~/.config/WSJT-X.ini Configuration MyGrid $GRID
#check for ntp-gps edits
if grep GPS /etc/ntp.conf;then
ntpq -p | grep -E 'SHM|offset'
#set time from GPS
sudo ntpd -gq
else
echo "INFORMATION: NTP GPS config not found see readme for details"
fi
fi
if [ -f ~/.klog/klogrc2 ];then
echo "K Log found, updating"
#Set Klog
if [ $BACKUP -eq 1 ];then
cp ~/.klog/klogrc2 ~/.klog/klogrc2.bak
fi
crudini --set ~/.klog/klogrc2 UserData StationLocator $GRID
fi
if [ -f ~/.config/JS8Call.ini ];then
echo "JS8Call.ini found, updating"
#Set JS8Call
if [ $BACKUP -eq 1 ];then
cp ~/.config/JS8Call.ini ~/.config/JS8Call.ini.bak
fi
crudini --set ~/.config/JS8Call.ini Configuration MyGrid $GRID
fi
if [ -f ~/.config/JTDX.ini ];then
echo "JTDX.ini found, updating"
#Set JTDX
if [ $BACKUP -eq 1 ];then
cp ~/.config/JTDX.ini ~/.config/JTDX.ini.bak
fi
crudini --set ~/.config/JTDX.ini Configuration MyGrid $GRID
fi
if [ -f ~/VarAC.ini ];then
echo "VarAC.ini found, updating"
#Set VarAC
if [ $BACKUP -eq 1 ];then
cp ~/VarAC.ini ~/VarAC.ini.bak
fi
crudini --set ~/VarAC.ini MY_INFO MyLocator $GRID
fi
if [ -f ~/.config/ON4QZ/qsstv_9.0.conf ];then
echo "qsstv_9.0.conf found, updating"
#Set qsstv
if [ $BACKUP -eq 1 ];then
cp ~/.config/ON4QZ/qsstv_9.0.conf ~/.config/ON4QZ/qsstv_9.0.conf.bak
fi
crudini --set ~/.config/ON4QZ/qsstv_9.0.conf PERSONAL locator $GRID
fi
if [ -f ~/varim/varim.ini ];then
echo "varim.ini found, updating however due to issues with varim.ini, updates port2"
#Set varim
if [ $BACKUP -eq 1 ];then
cp ~/varim/varim.ini ~/varim/varim.ini.bak
fi
crudini --set ~/varim/varim.ini port gridsq $GRID
fi
#FreeData
if [ -f ~/FreeDATA/modem/config.ini ];then
echo "FreeDATA/modem/config.ini found, updating"
#Set FreeDATA
if [ $BACKUP -eq 1 ];then
cp ~/FreeDATA/modem/config.ini ~/FreeDATA/modem/config.ini.bak
fi
crudini --set ~/FreeDATA/modem/config.ini STATION mygrid $GRID
fi
if [ -f ~/FreeDATA/freedata_server/config.ini ];then
echo "FreeDATA/freedata_server/config.ini found, updating"
#Set FreeDATA
if [ $BACKUP -eq 1 ];then
cp ~/FreeDATA/freedata_server/config.ini ~/FreeDATA/modem/config.ini.bak
fi
crudini --set ~/FreeDATA/freedata_server/config.ini STATION mygrid $GRID
fi
if [ -f ~/.config/FreeDATA/config.ini ];then
echo "FreeDATA config.ini found, updating"
#Set FreeDATA
if [ $BACKUP -eq 1 ];then
cp ~/.config/FreeDATA/config.ini ~/.config/FreeDATA/config.ini.bak
fi
crudini --set ~/.config/FreeDATA/config.ini STATION mygrid $GRID
fi
else
echo "crudini not found, launched: sudo apt-get install crudini"
echo "Please re-run this script after crudini is installed"
sudo apt-get install crudini
fi
#Handler for Flat Files
if [ -f ~/.fldigi/fldigi_def.xml ];then
echo "fldigi_def.xml found, updating"
#FLDigi uses unparsable "XML"
sed -i "s/<MYLOC>.*<\/MYLOC>/<MYLOC>$GRID<\/MYLOC>/g" ~/.fldigi/fldigi_def.xml
fi
if [ -f ~/.conkyrc ];then
#reset Conky by reaction
touch ~/.conkyrc
fi
#handler for json files using jq
if [ -f ~/.config/FreeDATA/config.json ];then
echo "FreeDATA config.json found, updating"
#Set FreeDATA
if [ $BACKUP -eq 1 ];then
cp ~/.config/FreeDATA/config.json ~/.config/FreeDATA/config.json.bak
fi
jq '.mygrid = "'$GRID'"' ~/.config/FreeDATA/config.json > ~/.config/FreeDATA/config.json.tmp && mv ~/.config/FreeDATA/config.json.tmp ~/.config/FreeDATA/config.json
fi
if [ -f ~/.config/m0nnb/SparkSDR2/settings/settings.json ];then
echo "SparkSDR2 settings.json found, updating"
#Set SparkSDR2
if [ $BACKUP -eq 1 ];then
cp ~/.config/m0nnb/SparkSDR2/settings/settings.json ~/.config/n0nmb/SparkSDR2/settings/settings.json.bak
fi
jq '.locator = "'$GRID'"' ~/.config/m0nnb/SparkSDR2/settings/settings.json > ~/.config/m0nnb/SparkSDR2/settings/settings.json.tmp
mv ~/.config/m0nnb/SparkSDR2/settings/settings.json.tmp ~/.config/m0nnb/SparkSDR2/settings/settings.json
fi
if [ -f ~/.config/pat/config.json ];then
echo "pat config.json found, updating"
#Set pat
if [ $BACKUP -eq 1 ];then
cp ~/.config/pat/config.json ~/.config/pat/config.json.bak
fi
jq '.locator = "'$GRID'"' ~/.config/pat/config.json > ~/.config/pat/config.json.tmp
mv ~/.config/pat/config.json.tmp ~/.config/pat/config.json
fi
#Goodbye
echo "73.."
exit 0