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

0 Members and 0 Guests are viewing this topic.

Offline VE3RD

  • Newbie
  • *
  • Posts: 26
  • Referrals: 0
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 »

Share on Facebook Share on Twitter


 

Related Topics

  Subject / Started by Replies Last post
0 Replies
45 Views
Last post February 20, 2019, 01:35:29 pm
by ke5cdk
6 Replies
124 Views
Last post July 14, 2019, 11:22:27 pm
by WB3IHY
2 Replies
46 Views
Last post January 14, 2020, 09:12:59 pm
by KM6THY
1 Replies
132 Views
Last post April 10, 2020, 05:50:41 pm
by VA3CKI
3 Replies
97 Views
Last post September 21, 2020, 11:11:50 pm
by Robert K4WZV