-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathp25link-menu
executable file
·730 lines (653 loc) · 24.2 KB
/
p25link-menu
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
#!/bin/bash
# P25LINK-MENU
##################################################################
# *** 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
clear
# define variables
rm -f /tmp/p25link-menu.log
logfile=/tmp/p25link-menu.log
#logfile=/dev/null
## all other variables defined in get_node_info
INTERACTIVE=True
ASK_TO_REBOOT=0
#CONFIG=/opt/p25link/config.txt
PACKAGE_VER=p25link_2.40-7
DEPLOY_DIR=/opt/deploy/$PACKAGE_VER
#################################################################################
# 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
}
#################################################################################
# GUI ###########################################################################
#################################################################################
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))
}
#################################################################################
# Functions #####################################################################
#################################################################################
get_node_info() {
echo "get_node_info" >> $logfile
CONFIGS=/opt/p25link
WEBROOT=/var/www/html/pnx
TMP=/tmp
REBOOT_NEEDED=0
P25LINK_RESTART=0
#HTTPPORT=80
#HTTPSPORT=443
RADIOID=$(grep -o '^\[[0-9]*\]' $CONFIGS/config.ini | sed 's/.*\[\([^]]*\)\].*/\1/g')
CALLSIGN=$(grep '^idrecording =' $CONFIGS/config.ini | awk -F'=' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{9\}\).*/\1/')
SSHPORT=$(grep 'Port ' /etc/ssh/sshd_config | awk -F" " '{print $2}')
ETH0IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
HOSTNAME=$(cat /etc/hostname | tr -d " \t\n\r")
}
#################################################################################
# Main menu functions ###########################################################
#################################################################################
do_run_firsttime() {
echo "do_run_firsttime" >> $logfile
if (whiptail --title "Do you want to run update before install" --yesno --defaultno "Update Yes or No" 8 78) then
do_apt_get_update
fi
if (whiptail --title "Do you want to create a new user?" --yesno --defaultno "Create Yes or No" 8 78) then
echo "create new user" >> $logfile
P25LINKUSER="p25user"
NEWUSER=$(whiptail --inputbox "Enter the new user name." 8 78 "$P25LINKUSER" --title "New user" 3>&1 1>&2 2>&3)
adduser $NEWUSER --system --home /opt/p25link &&
P25LINKUSER=$NEWUSER
fi
if (whiptail --title "Do you want to set a different user from $NEWUSER to run p25link app?" --yesno --defaultno "Change Yes or No" 8 78) then
P25LINKUSER=$(whiptail --inputbox "Current P25Link user is $P25LINKUSER enter new user name." 8 78 "$P25LINKUSER" --title "P25Link User" 3>&1 1>&2 2>&3)
sed -i 's/User.*/User='$P25LINKUSER'/' $CONFIGS/x_p25link.service
chown $P25LINKUSER /opt/p25link
fi
touch $CONFIGS/firsttime
chmod +x $CONFIGS/first-time
$CONFIGS/first-time
rm -f $CONFIGS/firsttime
whiptail --msgbox "Please do not forget to edit hosts.txt file (option H) to add/remove available talk groups, select networks and add/remove TGs to scan list" 10 60 2
}
do_start() {
echo "do_start" >> $logfile
SCRIPTUSER=$(grep '^User=' /$CONFIGS/x_p25link.service | awk -F'=' '{print $2}' | sed 's/|\i//' | sed -e 's/^\(.\{9\}\).*/\1/'|sed 's/ //g')
SCRIPTUSER=$(whiptail --inputbox "Current P25Link user is $SCRIPTUSER enter new user name." 8 78 "$SCRIPTUSER" --title "Script User" 3>&1 1>&2 2>&3)
sed -i 's/User.*/User='$SCRIPTUSER'/' $CONFIGS/x_p25link.service
cp $CONFIGS/x_p25link.service /lib/systemd/system/p25link.service &&
chmod 644 /lib/systemd/system/p25link.service &&
systemctl enable p25link &&
systemctl start p25link &&
P25LINK_RESTART=0
whiptail --msgbox "P25Link service has been started" 20 60 2
}
do_restart() {
echo "do_restart" >> $logfile
systemctl restart p25link &&
P25LINK_RESTART=0
whiptail --msgbox "P25Link service has been restarted" 20 60 2
}
do_stop() {
echo "do_stop" >> $logfile
systemctl stop p25link &&
systemctl disable p25link &&
P25LINK_RESTART=0
whiptail --msgbox "P25Link service has been stoped" 20 60 2
}
do_about() {
whiptail --msgbox "\
Created by Juan Carlos Perez KM4NNO / XE1F.
This tool provides a straight-forward way of doing initial
configuration for P25Link on Raspberry Pi. Although it can be run
at any time, some of the options may have difficulties if
you have heavily customised your installation.\
" 20 70 1
}
#################################################################################
# Network menu functions ########################################################
#################################################################################
get_hostname() {
cat /etc/hostname | tr -d " \t\n\r"
}
do_hostname() {
echo "do_hostname" >> $logfile
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "\
Please note: RFCs mandate that a hostname's labels \
may contain only the ASCII letters 'a' through 'z' (case-insensitive),
the digits '0' through '9', and the hyphen.
Hostname labels cannot begin or end with a hyphen.
No other symbols, punctuation characters, or blank spaces are permitted.\
" 20 70 1
fi
CURRENT_HOSTNAME=`cat /etc/hostname | tr -d " \t\n\r"`
if [ "$INTERACTIVE" = True ]; then
NEW_HOSTNAME=$(whiptail --inputbox "Please enter a hostname" 20 60 "$CURRENT_HOSTNAME" 3>&1 1>&2 2>&3)
else
NEW_HOSTNAME=$1
true
fi
if [ $? -eq 0 ]; then
echo $NEW_HOSTNAME > /etc/hostname
sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts
ASK_TO_REBOOT=1
fi
}
do_net_setup() {
echo "do_net_setup" >> $logfile
if [ -x /opt/p25link/net-setup ]; then
whiptail --msgbox "You can now set up the networking for the system to use\neither static or DHCP (dynamic) addressing.\nIf you choose static addressing, you will need to have 5 key IP\naddresses handy: IP ADDRESS, NETMASK, DEFAULT GATEWAY,\nPRIMARY DNS, and SECONDARY DNS." 20 80 2
chmod +x $CONFIGS/net-setup
$CONFIGS/net-setup
fi
}
get_ssh() {
if service ssh status | grep -q inactive; then
echo 1
else
echo 0
fi
}
do_ssh() {
echo "do_ssh" >> $logfile
if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then
whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2
return 1
fi
DEFAULT=--defaultno
if [ $(get_ssh) -eq 0 ]; then
DEFAULT=
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the SSH server to be enabled?" $DEFAULT 20 60 2
RET=$?
else
RET=$1
fi
if [ $RET -eq 0 ]; then
update-rc.d ssh enable &&
invoke-rc.d ssh start &&
STATUS=enabled
elif [ $RET -eq 1 ]; then
update-rc.d ssh disable &&
invoke-rc.d ssh stop &&
STATUS=disabled
else
return $RET
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The SSH server is $STATUS" 20 60 1
fi
}
do_ssh_port() {
echo "do_ssh_port" >> $logfile
NEWSSHPORT=$(whiptail --inputbox "Current SSH port is $SSHPORT \nEnter new SSH port to use" 8 78 "$SSHPORT" --title "SSH Port" 3>&1 1>&2 2>&3)
#sed -i "s/^Port $SSHPORT/Port $NEWSSHPORT/" /etc/ssh/sshd_config
sed -i "/Port $SSHPORT/c\Port $NEWSSHPORT" /etc/ssh/sshd_config
$SERVICE ssh restart
whiptail --msgbox "SSH port set to $NEWSSHPORT\nUpdate firewall and port forwarding." 20 60 2
}
#################################################################################
# Settings menu functions #######################################################
#################################################################################
do_set_root_passwd() {
ANSWER=1
if (whiptail --title "First-time" --yesno "Welcome to P25Link first-time setup. \
\nThis script will walk you through a few of the basic system setup options. \
\nThe root login is disabled for SSH and CONSOLE login. \
\nBy setting the root password you will allow root to login on the console. \
\nWould you like to set the root password?" --defaultno 20 80) then
ANSWER=$?
fi
if [ "$ANSWER" = "0" ]; then # answered yes
# no options to pretty up the display for this part
while ! passwd root
do
whiptail --msgbox "ERROR: A valid password must be assigned to continue" 20 80 2
done
fi
}
do_set_my_passwd() {
ANSWER=1
REALID=$(who am i | awk '{print $1}')
if (whiptail --title "$REALID password" --yesno "Would you like to change your password?\nUser: $REALID" 20 80 2) then
ANSWER=$?
fi
if [ "$ANSWER" = "0" ]; then
while ! passwd $REALID
do
whiptail --msgbox "ERROR: " 20 80 2
done
fi
}
do_create_new_user() {
if (whiptail --title "Do you want to create a new user?" --yesno --defaultno "Create Yes or No" 8 78) then
echo "create new user" >> $logfile
P25LINKUSER="p25user"
NEWUSER=$(whiptail --inputbox "Enter the new user name." 8 78 "$P25LINKUSER" --title "New user" 3>&1 1>&2 2>&3)
adduser $NEWUSER --system --home /opt/p25link &&
P25LINKUSER=$NEWUSER
fi
}
do_apt_get_update() {
echo "do_apt_get_update" >> $logfile
whiptail --msgbox "Grab a cup of coffee if you have not run this in a while\nUpdating repository information" 20 60 2
apt-get update &&
apt-get install raspi-config &&
printf "Sleeping 5 seconds before reloading raspi-config\n" &&
sleep 5 &&
exec ./p25link-menu
whiptail --msgbox "Done running apt-get update" 20 60 2
}
do_apt_get_upgrade() {
echo "do_apt_get_upgrade" >> $logfile
whiptail --msgbox "Might be a good time for lunch this could take a while" 20 60 2
$APTGET -y upgrade
whiptail --msgbox "Done running apt-get upgrade" 20 60 2
}
do_install_webserver() {
echo "do_install_webserver" >> $logfile
DO_INSTALL_WEBSERVER_TITLE=$(grep '^do_install_webserver_title_t =' /$LANGUAGEFILE | awk -F'=' '{print $2}')
DO_INSTALL_WEBSERVER_YESNO=$(grep '^do_install_webserver_yesno_t =' /$LANGUAGEFILE | awk -F'=' '{print $2}')
DO_INSTALL_WEBSERVER_YES=$(grep '^do_install_webserver_yes_t =' /$LANGUAGEFILE | awk -F'=' '{print $2}')
DO_INSTALL_WEBSERVER_NO=$(grep '^do_install_webserver_no_t =' /$LANGUAGEFILE | awk -F'=' '{print $2}')
do_is_webserver_installed
if (whiptail --title "$DO_INSTALL_WEBSERVER_TITLE" --yesno "$DO_INSTALL_WEBSERVER_YESNO" 20 60) then
if [ $WEEBSERVE_YN = "YES" ]; then
whiptail --msgbox "$DO_INSTALL_WEBSERVER_YES" 20 60 2
$APTGET -y install --only-upgrade apache2
$APTGET -y install --only-upgrade php libapache2-mod-php
else
whiptail --msgbox "$DO_INSTALL_WEBSERVER_NO" 20 60 2
$APTGET update
$APTGET -y install apache2
$APTGET -y install php libapache2-mod-php
fi
fi
}
do_install_cpan() {
echo "do_install_cpan" >> $logfile
whiptail --msgbox "Grab a cup of coffee if you have not run this in a while\nUpdating repository information" 20 60 2
cpan install Switch &&
cpan install Config::IniFiles &&
cpan install Digest::CRC &&
cpan install Device::SerialPort &&
cpan install IO::Socket::Timeout &&
cpan install IO::Socket::IP &&
cpan install IO::Socket::Multicast &&
cpan install Term::ReadKey &&
cpan install Ham::APRS::IS &&
cpan install LWP::Simple &&
# For RadioID database:
cpan install JSON &&
# cpan install LWP::UserAgent &&
# cpan force install LWP::Protocol::https &&
# cpan install YAML &&
# sudo apt-get install libssl-dev -y &&
# cpan install Net::SSLeay &&
# cpan install IO::Socket::SSL &&
# cpan install IO::Socket::SSL::Utils &&
# cpan install Crypt::SSLeay &&
# sudo apt-get install libcrypt-ssleay-perl
# Used to make Exe files:
#cpan -i PAR::Packer &&
apt install libpar-packer-perl
whiptail --msgbox "Done running CPAN mod installations" 20 60 2
}
do_copywebfiles() {
rm -r /var/www/html/p25link
cp -r /opt/p25link/web /var/www/html/p25link
}
do_build_app() {
chmod +x $CONFIGS/p25link.pl &&
# Make app
pp -o /opt/p25link/p25link $CONFIGS/p25link.pl
whiptail --msgbox "Done building executable file" 20 60 2
}
do_build_deb() {
chmod +x $CONFIGS/p25link.pl &&
chmod 755 $CONFIGS -R
chmod 755 $CONFIGS/DEBIAN -R
# Make app
pp -o /opt/p25link/p25link $CONFIGS/p25link.pl
mkdir /opt/deploy
cd /opt/deploy
rm $DEPLOY_DIR -r
mkdir $DEPLOY_DIR
mkdir $DEPLOY_DIR/opt
mkdir $DEPLOY_DIR/opt/p25link
# Copy files
cp -r $CONFIGS/APRS_IS.pm $DEPLOY_DIR/opt/p25link/APRS_IS.pm
cp -r $CONFIGS/x_aprs.txt $DEPLOY_DIR/opt/p25link/aprs.txt
cp -r $CONFIGS/CiscoSTUN.pm $DEPLOY_DIR/opt/p25link/CiscoSTUN.pm
cp -r $CONFIGS/x_config.ini $DEPLOY_DIR/opt/p25link/config.ini
cp -r $CONFIGS/DMR.pm $DEPLOY_DIR/opt/p25link/DMR.pm
cp -r $CONFIGS/FAP.pm $DEPLOY_DIR/opt/p25link/FAP.pm
cp -r $CONFIGS/first-time $DEPLOY_DIR/opt/p25link/first-time
cp -r $CONFIGS/x_hosts.txt $DEPLOY_DIR/opt/p25link/hosts.txt
cp -r $CONFIGS/LICENSE.txt $DEPLOY_DIR/opt/p25link/LICENSE.txt
cp -r $CONFIGS/MMDVM.pm $DEPLOY_DIR/opt/p25link/MMDVM.pm
cp -r $CONFIGS/net-setup $DEPLOY_DIR/opt/p25link/net-setup
cp -r $CONFIGS/p25link $DEPLOY_DIR/opt/p25link/p25link
cp -r $CONFIGS/p25link-menu $DEPLOY_DIR/opt/p25link/p25link-menu
cp -r $CONFIGS/p25link.pl $DEPLOY_DIR/opt/p25link/p25link.pl
cp -r $CONFIGS/P25Link.pm $DEPLOY_DIR/opt/p25link/P25Link.pm
cp -r $CONFIGS/P25NX.pm $DEPLOY_DIR/opt/p25link/P25NX.pm
cp -r $CONFIGS/x_p25link.service $DEPLOY_DIR/opt/p25link/x_p25link.service
cp -r $CONFIGS/Packets.pm $DEPLOY_DIR/opt/p25link/Packets.pm
cp -r $CONFIGS/Quantar.pm $DEPLOY_DIR/opt/p25link/Quantar.pm
cp -r $CONFIGS/RDAC.pm $DEPLOY_DIR/opt/p25link/RDAC.pm
cp -r $CONFIGS/README.md $DEPLOY_DIR/opt/p25link/README.md
cp -r $CONFIGS/Recorder.pm $DEPLOY_DIR/opt/p25link/Recorder.pm
cp -r $CONFIGS/Serial.pm $DEPLOY_DIR/opt/p25link/Serial.pm
cp -r $CONFIGS/speech.ini $DEPLOY_DIR/opt/p25link/speech.ini
cp -r $CONFIGS/SuperFrame.pm $DEPLOY_DIR/opt/p25link/SuperFrame.pm
cp -r $CONFIGS/DEBIAN $DEPLOY_DIR/
# Build .deb
cd /opt/deploy
dpkg-deb --build $PACKAGE_VER
}
do_use_p25link_menu() {
echo "do_p25link_menu" >> $logfile
# use p25link-menu on login for user account
ANSWER=1
REALID=$(who am i | awk '{print $1}')
if (whiptail --title "p25link-menu at login" --yesno "Would you like to start the p25link-menu script\nat login by default for user: $REALID?" --defaultno 20 80 2 3>&1 1>&2 2>&3) then
ANSWER=$?
fi
if [ "$ANSWER" = "0" ]; then
cat /home/$REALID/.bashrc |grep p25link-menu > /dev/null
if [ $? = "1" ]; then
echo "sudo $CONFIGS/p25link-menu" >> /home/$REALID/.bashrc
whiptail --msgbox "p25link-menu will start at login for user $REALID" 20 60 2
else
whiptail --msgbox "p25link-menu already starts for user $REALID at login." 20 60 2
fi
else
sed -i '/p25link-menu/c\' /home/$REALID/.bashrc
whiptail --msgbox "the p25link-menu autostart at login has been disabled\nYou may run the p25link-menu script by typing sudo $CONFIGS/p25link-menu" 20 60 2
fi
}
do_system_restart() {
ANSWER=1
REALID=$(who am i | awk '{print $1}')
if (whiptail --title "System Restart" --yesno "Would you like to restart your system?" --defaultno 20 80 2 3>&1 1>&2 2>&3) then
ANSWER=$?
fi
if [ "$ANSWER" = "0" ]; then
reboot
fi
}
do_system_halt() {
ANSWER=1
REALID=$(who am i | awk '{print $1}')
if (whiptail --title "System Shutdown" --yesno "Would you like to shutdown your system?" --defaultno 20 80 2 3>&1 1>&2 2>&3) then
ANSWER=$?
fi
if [ "$ANSWER" = "0" ]; then
halt
fi
}
#################################################################################
# Other menu functions ##########################################################
#################################################################################
do_exit() {
echo "do_exit" >> $logfile
if (whiptail --title "Exit Yes or No" --yesno "Exit Yes or No" 8 78) then
do_finish
else
do_main_menu
fi
}
do_finish() {
echo "do_finish" >> $logfile
if [ $P25LINK_RESTART -eq 1 ]; then
whiptail --title "P25Link restart required" --yesno "P25Link reload is required for changes to take effect restart P25Link now?" 8 78
if [ $? -eq 0 ]; then #yes
$P25LINKRES
whiptail --msgbox "P25Link has been restarted" 20 60 2
else
whiptail --msgbox "Please restart P25Link at your convenience" 20 60 2
fi
fi
# check if reboot needed.
if [ $REBOOT_NEEDED -eq 1 ]; then
whiptail --title "Reboot is required" --yesno "Reboot required for changes to take effect Reboot now?" 8 78
if [ $? -eq 0 ]; then # yes
sync
reboot -t 30
else
whiptail --msgbox "You may reboot the machine at your convenience" 20 60 2
fi
fi
exit 0
}
do_nothing() {
echo "do_nothing" >> $logfile
# place to land the menu options that aren't done yet
whiptail --msgbox "Option not configured yet" 20 60 2
}
#################################################################################
# Direwolf ######################################################################
#################################################################################
do_direwolf_install() {
echo "do_direwolf_install" >> $logfile
whiptail --msgbox "Grab a cup of coffee if you have not run this in a while\nUpdating repository information" 20 60 2
cd /opt &&
echo "* apt-get install git"
#apt-get install git &&
echo "* apt-get install gcc"
#apt-get install gcc &&
echo "* apt-get install g++"
#apt-get install g++ &&
echo "* apt-get make"
#apt-get install make &&
echo "* apt-get cmake"
#apt-get install cmake &&
echo "apt-get install build-essential"
apt-get install build-essential
echo "apt-get install alsa-utils "
apt-get install alsa-utils
echo "* apt-get install libasound2-dev"
apt-get install libasound2-dev
echo "* apt-get install libudev-dev"
apt-get install libudev-dev
echo "* cd ~"
cd ~
echo "* clone direwolf"
#git clone https://www.github.com/wb2osz/direwolf /opt/direwolf
cd /opt/direwolf
#echo "* checkout dev"
#git checkout dev
echo "* build"
mkdir build && cd build
echo "* cmake"
cmake ..
echo "* make"
#make -j4 &&
echo "* make install"
#make install &&
echo "* make install-conf"
#make install-conf &&
echo "* apt-get update"
#apt-get update &&
echo "* apt-cache showpkg direwolf"
#apt-cache showpkg direwolf &&
echo "* apt-get install direwolf"
#apt-get install direwolf &&
whiptail --msgbox "Done Direwolf installations" 20 60 2
}
do_run_direwolf_firsttime() {
echo "do_run_direwolf_firsttime" >> $logfile
if (whiptail --title "Do you want to run update before install" --yesno --defaultno "Update Yes or No" 8 78) then
do_apt_get_update
fi
chmod +x $CONFIGS/direwolf-first-time
$CONFIGS/direwolf-first-time
}
#################################################################################
# Menus #########################################################################
#################################################################################
do_extras_menu() {
FUN=$(whiptail --title "Extras menu" --menu "Extras" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"A " "APRS Direwolf Install" \
"B " "APRS Direwolf first time configuration" \
"C " "Edit direwolf.conf file with advanced settings" \
"D " "Auto-start Direwolf software on boot" \
"R " "Restart Direwolf software only" \
"S " "Disable Auto-start Direwolf software on boot" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
elif [ $RET -eq 0 ]; then
case "$FUN" in
A\ *) do_direwolf_install ;;
B\ *) do_run_direwolf_firsttime ;;
C\ *) nano /root/direwolf.conf ;;
D\ *) do_direwold_start ;;
R\ *) do_direwolf_restart ;;
S\ *) do_direwolf_stop ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
}
do_utilities_menu() {
FUN=$(whiptail --title "P25Link Utilities menu" --menu "Utilities" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"A " "Change Root password" \
"B " "Change User password for the current user" \
"C " "Create New User" \
"D " "Run apt-get update" \
"E " "Run apt-get upgrade" \
"F " "Install/Update Web Server" \
"G " "Run p25link-menu at login" \
"R " "Restart system (Raspberry Pi)" \
"S " "Shutdown system" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
elif [ $RET -eq 0 ]; then
case "$FUN" in
A\ *) do_set_root_passwd ;;
B\ *) do_set_my_passwd ;;
C\ *) do_create_new_user ;;
D\ *) do_apt_get_update ;;
E\ *) do_apt_get_upgrade ;;
F\ *) do_install_webserver ;;
G\ *) do_use_p25link_menu ;;
R\ *) do_system_restart ;;
S\ *) do_system_halt ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
}
do_developer_menu() {
FUN=$(whiptail --title "P25Link Developer menu" --menu "Developer" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"A " "Install Perl CPAN modules" \
"B " "Build p25link" \
"C " "Build p25link.deb" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
elif [ $RET -eq 0 ]; then
case "$FUN" in
A\ *) do_install_cpan ;;
B\ *) do_build_app ;;
C\ *) do_build_deb ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
}
do_network_menu() {
FUN=$(whiptail --title "P25Link Network menu" --menu "Network" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"A " "Set the Hostname for this Pi on a network" \
"B " "Network configuration" \
"C " "Enable/Disable remote access using SSH" \
"D " "Change SSH port number used" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
elif [ $RET -eq 0 ]; then
case "$FUN" in
A\ *) do_hostname ;;
B\ *) do_net_setup ;;
C\ *) do_ssh ;;
D\ *) do_ssh_port ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
}
do_main_menu() {
echo "do_main_menu" >> $logfile
RET=0
while true; do
calc_wt_size
FUN=$(whiptail --title "P25Link Main Menu $HOSTNAME $ETH0IP:$SSHPORT" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
"A About p25link-menu" "Information about this configuration tool" \
"B First-time setup" "Run initial step by step configuration" \
"C Network Menu" "Network configuration menu options" \
"D Utilities Menu" "Utilities and misc options" \
"E Extras Menu" "Other apps installers & setup" \
"F Developer tools" "Advanced utilities for dev." \
"G config.ini" "Edit config.ini file with advanced settings" \
"H hosts.txt" "Edit hosts.txt file with your custom hosts" \
"I aprs.txt" "Edit aprs.txt file with your own objects" \
"P Stop Auto Start" "Disable Auto-start P25Link software on boot" \
"R Restart App" "Restart P25Link software only" \
"S Auto Start App" "Auto-start P25Link software on boot" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
do_exit
elif [ $RET -eq 0 ]; then
case "$FUN" in
A\ *) do_about ;;
B\ *) do_run_firsttime ;;
C\ *) do_network_menu ;;
D\ *) do_utilities_menu ;;
E\ *) do_extras_menu ;;
F\ *) do_developer_menu ;;
G\ *) nano $CONFIGS/config.ini ;;
H\ *) nano $CONFIGS/hosts.txt ;;
I\ *) nano $CONFIGS/aprs.txt ;;
P\ *) do_stop ;;
R\ *) do_restart ;;
S\ *) do_start ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
else
exit 1
fi
done
}
#################################################################################
# Main body here ################################################################
#################################################################################
check_if_root
get_node_info
do_main_menu
clear
exit 0