Author Topic: Run a pi-star script using Pistar-Remote  (Read 810 times)

0 Members and 1 Guest are viewing this topic.

Offline VE3RD

  • Newbie
  • *
  • Posts: 31
  • Karma: +0/-0

  • Total Badges: 16
    Badges: (View All)
    Level 4 Fifth year Anniversary Fourth year Anniversary
Run a pi-star script using Pistar-Remote
« on: February 07, 2020, 07:39:54 pm »
If you want to run an existing pi-star script file, just edit two files as follows, then reboot
Note the sample is for DMR. If you want YSF or P25, or NXDN, then make the appropriate changes.
If you need help, email me at ve3rd@rac.ca

File 1
/etc/pistar-remote

[enable]
# Is the Pi-Star Remote Enabled? (true|false)
enabled=true

[keeper]
# Keepers Information
# Please use your own callsign here
callsign=VE3RD

[dmr]
# TG commands
svckill=9999999
svcrestart=9999998
reboot=9999997
#use any name you like, but remember it for file 2 below.
#The number can be anything you like, but I would suggest a 7 digit number ending in an unused 7th digit
master1=9999991
master2=9999992

#shutdown=9999996

.
File 2
/usr/local/sbin/pistar-remote

#Scroll Down to
# DMR Control Options
if config.has_option('dmr', 'svckill'):
        dmrstop = config.get('dmr', 'svckill')
else:
        dmrstop = str(999999999999)
.........................
## Add the following lines for your script. Note the use of the script names in file1
if config.has_option('dmr', 'master1'):
        dmrmaster1 = config.get('dmr', 'master1')
else:
        dmrmaster1 = str(999999999999)
if config.has_option('dmr', 'master2'):
        dmrmaster2 = config.get('dmr', 'master2')
else:
        dmrmaster2 = str(999999999999)
..............................................


Scroll Down to the following
# Now run the loop
while True:
  ...............................

                # Parse the log lines
                for line in loglist:
                        # We only care about logs in the last 60 secs
                        if line[3:22] >= logstampnowminus60sec and line[3:22] <= logstampnow:

#Add the following lines replacing the path and script line with your own script,
                                # DMR  run master1
                                if str('received RF voice header from ' + keeperCall + ' to ' + dmrmaster1) in line:
                                        # Kill the Services
                                        os.system(r'sudo /home/pi-star/setmaster2.rsh 1')

                                # DMR run start master2
                                if str('received RF voice header from ' + keeperCall + ' to ' + dmrmaster2) in line:
                                        # Kill the Services
                                        os.system(r'sudo /home/pi-star/setmaster2.sh 2')



Create The Script "setmaster2.sh" in /home/pi-star
Cut and paste with the following into the file
Make it executible  with the command  ' chmod 755 setmaster2.sh'

#!/bin/bash
############################################################
#  Set DMR Master Server from Pi-Star Remote               #
#  Param 1 is the Address, Param 2 is the Port             #
#  VE3RD                                      2020/02/07   #
############################################################
set -o errexit
set -o pipefail
sudo mount -o remount,rw /
#echo "Set DMR Master Server"
if [ -z "$1" ]; then
        exit
fi
        sudo sed -i '/\[DMR\]/!b;n;cEnable='"1"'' /etc/mmdvmhost
        sudo sed -i '/\[DMR Network\]/!b;n;cEnable='"1"'' /etc/mmdvmhost
        sudo sed -i '/^\[/h;G;/DMR Network/s/\(Port=\).*/\162031/m;P;d'  /etc/mmdvmhost


if [ "$1" = 1 ]; then

        sudo sed -i '/^\[/h;G;/DMR Network/s/\(Address=\).*/\1tgif.network/m;P;d'  /etc/mmdvmhost
fi
if [ "$1" = 2 ]; then

        sudo sed -i '/^\[/h;G;/DMR Network/s/\(Address=\).*/\1107.191.99.14/m;P;d'  /etc/mmdvmhost
fi

sudo /usr/local/sbin/mmdvmhost.service restart > /dev/null



« Last Edit: February 07, 2020, 08:46:41 pm by VE3RD »

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
220 Views
Last post January 14, 2020, 09:12:59 pm
by KM6THY
1 Replies
491 Views
Last post April 10, 2020, 05:50:41 pm
by VA3CKI
4 Replies
598 Views
Last post June 23, 2021, 08:57:46 pm
by N0FKK
1 Replies
323 Views
Last post February 25, 2021, 09:07:25 am
by N1KK
0 Replies
325 Views
Last post November 19, 2021, 09:21:54 am
by VE3RD

TGIF Network - Thank God It's Friday!