emq-TE1/emq-TE1x.sh

2015 lines
51 KiB
Bash

#!/bin/sh
echo Actualizando sistema
apt-get update -y
#apt-get upgrade -y
#apt-get dist-upgrade -y
############################################
echo instalando pre-requisitos
######################################################################################################
#!/bin/sh
apt-get install sudo -y
sudo apt-get purge needrestart -y
sudo apt-get install wget -y
sudo apt-get install git -y
sudo apt-get install screen -y
sudo apt-get install gcc -y
sudo apt-get install g++ -y
sudo apt-get install make -y
sudo apt-get install cmake -y
sudo apt-get install musl-dev -y
sudo apt-get install python2 -y
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo apt-get install libasound2-dev -y
sudo apt-get install libudev-dev -y
sudo apt-get install libusb-1.0-0-dev -y
sudo apt-get install libx11-dev -y
sudo apt-get install libfftw3-dev -y
sudo apt-get install libpulse-dev -y
sudo apt-get install build-essential -y
sudo apt-get install alsa-utils -y
sudo apt-get install rsyslog -y
sudo apt-get install logrotate -y
sudo apt-get install gpsd libgps-dev -y
sudo apt-get install qt4-qmake -y
sudo apt-get install libtool -y
sudo apt-get install autoconf -y
sudo apt-get install automake -y
sudo apt-get install python-pkg-resources -y
sudo apt-get install sox -y
sudo apt-get install git-core -y
sudo apt-get install libi2c-dev -y
sudo apt-get install i2c-tools -y
sudo apt-get install lm-sensors -y
sudo apt-get install wiringpi -y
sudo apt-get install chkconfig -y
sudo apt-get install wavemon -y
sudo apt-get install libffi-dev -y
sudo apt-get install libssl-dev -y
sudo apt-get install cargo -y
sudo apt-get install sed -y
sudo apt install python3 -y
sudo apt install python3-pip -y
sudo apt install python3-distutils -y
sudo apt install python3-dev -y
sudo apt install python3-websockets
sudo apt install python3-psutil
sudo apt-get install python3-serial
sudo apt install python3-gpiozero -y
sudo apt-get install gpsd gpsd-clients python-gps -y
sudo pip install aprslib
sudo pip install tinydb
sudo apt install socket
sudo apt install threading
sudo apt install queue
sudo apt install sys
sudo apt install os
sudo apt install time
sudo apt install re
sudo apt install datetime
sudo apt install signal
sudo apt install datetime
sudo apt install bisect
sudo apt install struct
sudo apt install ansi2html
sudo apt install logrotate
sudo pip3 install ansi2html
sudo apt-get install python-pip -y
sudo apt-get install python-dev -y
sudo apt-get install rrdtool -y
##################
sudo cat > /opt/emq-ver <<- "EOF"
EMQ-VER: 21
EOF
#########
sh -c "$(curl -fsSL https://raw.githubusercontent.com/hp3icc/emq-TE1ws/main/menu.sh)"
########################
if [ -f "/opt/obp.txt" ]
then
echo "found file"
else
sudo cat > /opt/obp.txt <<- "EOF"
#Coloque abajo su lista de obp y peer
EOF
fi
####################
cd /home/
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
sudo cat > /home/requirements.txt <<- "EOF"
autobahn
jinja2==2.11.3
bitstring>=3.1.5
bitarray>=0.8.1
Twisted>=16.3.0
dmr_utils3>=0.1.19
configparser>=3.0.0
aprslib>=0.6.42
tinydb
pynmea2
maidenhead
requests
libscrc
flask
folium
mysql-connector
resettabletimer>=0.7.0
setproctitle
EOF
#
pip3 install setuptools wheel
pip3 install -r requirements.txt
sudo rm requirements.txt
sudo rm get-pip.py
#
#########################
if [ -d "/var/www" ]
then
rm -r /var/www
#echo "found file"
fi
mkdir /var/www
mkdir /var/www/html
if [ -d "/var/log/ysf2dmr" ]
then
rm -r /var/log/ysf2dmr
#echo "found file"
fi
mkdir /var/log/ysf2dmr
if [ -d "/var/log/mmdvm" ]
then
rm -r /var/log/mmdvm
#echo "found file"
fi
mkdir /var/log/mmdvm
if [ -d "/var/log/direwolf" ]
then
rm -r /var/log/direwolf
#echo "found file"
fi
mkdir /var/log/direwolf
if [ -d "/var/log/mmdvmh" ]
then
rm -r /var/log/mmdvmh
#echo "found file"
fi
mkdir /var/log/mmdvmh
if [ -d "/var/log/DMRGateway" ]
then
rm -r /var/log/DMRGateway
#echo "found file"
fi
mkdir /var/log/DMRGateway
if [ -d "/var/log/FreeDMR" ]
then
rm -r /var/log/FreeDMR
#echo "found file"
fi
mkdir /var/log/FreeDMR
if [ -d "/var/log/YSFReflector" ]
then
rm -r /var/log/YSFReflector
#echo "found file"
fi
mkdir /var/log/YSFReflector
sudo chmod +777 /var/log
sudo chmod +777 /var/log/*
####################
echo iniciando instalacion
sh -c "$(curl -fsSL https://raw.githubusercontent.com/hp3icc/emq-TE1ws/main/rm.sh)"
######################################################################################################################
# raspberry
#####################################################################################################################
#########################################################################################################################
# direwolf
#########################################################################################################################
###############################
mkdir /opt/YSF2DMR
cd /opt/
git clone https://github.com/juribeparada/MMDVM_CM.git
sudo cp -r /opt/MMDVM_CM/YSF2DMR /opt/
cd YSF2DMR
sudo make
sudo make install
sudo cp -r /opt/YSF2DMR/ /opt/YSF2DMRGW
wget http://freedmr-hp.ddns.net/downloads/TGList_BM.txt -O /opt/YSF2DMRGW/TGList-DMR.txt
sudo chmod +x /opt/YSF2DMRGW/*
############################################################################################
#web
cd /opt/
git clone --recurse-submodules -j8 https://github.com/dg9vh/MMDVMHost-Websocketboard
sudo chown -R mmdvm:mmdvm /opt/MMDVMHost-Websocketboard
#
sudo sed '264 a <!--' -i /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed '266 a -->' -i /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed -i "s/\`Custom-Headline-Text\`/\`Websocket-Based\`/g" /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i "s/about = 1/about = 0/g" /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i "s/currtx = 1/currtx = 0/g" /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i "s/qso = 1/qso = 0/g" /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i "s/dapnet = 1/dapnet = 0/g" /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i "s/DGIdGateway/YSFGateway/g" /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i "s/BinaryName5/#BinaryName5/g" /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/Logdir=\/mnt\/ramdisk/Logdir=\/var\/log\/mmdvmh/' /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/5678/5679/' /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/Filerotate=True/Filerotate=False/' /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/etc\/MMDVM/opt\/MMDVMHost/' /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/usr\/local\/bin/opt\/MMDVMHost/' /opt/MMDVMHost-Websocketboard/logtailer.ini
sudo sed -i 's/Prefix=MMDVM/Prefix=MMDVMH/' /opt/MMDVMHost-Websocketboard/logtailer.ini
variable2=$(date +'%Y' | tail -c 5)
sudo sed -i "s/switch theme.*/switch theme<\/a><\/span> <\/div> <p style=\"text-align: center;\"><span class=\"text-muted\"><a title=\"Raspbian Proyect by HP3ICC © 2018-$variable2\" target=\"_blank\" href=https:\/\/github.com\/hp3icc\/emq-TE1ws\/>Proyect: emq-TE1ws<\/a><\/span>/g" /opt/MMDVMHost-Websocketboard/html/index.html
#
cd /opt/MMDVMHost-Websocketboard/html/
sudo sed -i 's/5678/5679/' /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed -i 's/<span class="navbar-brand float:center"><script type="text\/javascript">document.write(customHeadlineText);<\/script><\/span>/<span style="color: #808080;" class="navbar-brand float:center"><script type="text\/javascript">document.write(customHeadlineText);<\/script><\/span>/g' /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed -i 's/<script type="text\/javascript">document.write(customText);<\/script>/<span style="color: #3cff33;"><script type="text\/javascript">document.write(customText);<\/script>/g' /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed -i 's/This is an example/MMDVMHost Dashboard/' /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i 's/you can use all html-tags and multiline-text./MMDVMHost-Websocketboard by DG9VH/' /opt/MMDVMHost-Websocketboard/html/js/config.js
sudo sed -i 's/<span class="navbar-brand float:right">Websocket-Based<\/span>/<span style="color: #808080;" <li>Temperature: <span id="cputemp"><\/span> °C<\/li>/g' /opt/MMDVMHost-Websocketboard/html/index.html
sudo sed -i 's/<a class="navbar-brand" href="#">MMDVM-Dashboard by DG9VH<\/a>/<h6 style="text-align: center;"><span style="color: #808080;"><a style="color: #808080;" href="https:\/\/github.com\/hp3icc\/emq-TE1ws\/" target="_blank">emq-te1ws Raspbian Proyect by hp3icc<\/a> copyright 2018-YK00<\/span><\/h6>/g' /opt/MMDVMHost-Websocketboard/html/index.html
variable2=$(date +'%Y' | tail -c 5)
sudo sed -i "s/YK00/$variable2/g" /opt/MMDVMHost-Websocketboard/html/index.html
############################
cat > /lib/systemd/system/http.server-mmdvmh.service <<- "EOF"
[Unit]
Description=Python3 http.server.mmdvmhost
After=network.target
[Service]
User=root
ExecStartPre=/bin/sleep 30
# Modify for different location of Python3 or other port
ExecStart=/usr/bin/python3 -m http.server 80 --directory /opt/MMDVMHost-Websocketboard/html
[Install]
WantedBy=multi-user.target
EOF
#
cat > /lib/systemd/system/logtailer-mmdvmh.service <<- "EOF"
[Unit]
Description=Python3 logtailer for MMDVMDash
After=network.target
[Service]
Type=simple
User=mmdvm
Group=mmdvm
Restart=always
ExecStartPre=/bin/sleep 30
# Modify for different location of Python3 or other port
WorkingDirectory=/opt/MMDVMHost-Websocketboard/
ExecStart=/usr/bin/python3 /opt/MMDVMHost-Websocketboard/logtailer.py
[Install]
WantedBy=multi-user.target
EOF
#
wget https://raw.githubusercontent.com/hp3icc/emq-TE1ws/main/TG_List.csv -O /opt/MMDVMHost-Websocketboard/html/data/TG_List.csv
#
cat > /lib/systemd/system/rebooter1.service <<- "EOF"
[Unit]
Description=Rebooter
#Wants=network-online.target
#After=syslog.target network-online.target
[Service]
User=root
ExecStart=/usr/local/bin/rebooter1.sh
[Install]
WantedBy=default.target
EOF
####################################
cd /boot
sudo sed -i 's/console=serial0,115200 //' cmdline.txt
sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl stop bluetooth.service
sudo systemctl disable serial-getty@ttyAMA0.service
sudo systemctl disable bluetooth.service
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/' config.txt
sudo sed -i 's/dtparam=audio=on/#dtparam=audio=on/' config.txt
echo "enable_uart=1" >> config.txt
echo "dtoverlay=pi3-disable-bt" >> config.txt
echo "dtparam=spi=on" >> config.txt
##################
cat > /lib/systemd/system/monp.service <<- "EOF"
[Unit]
Description=sudo modprobe i2c-dev
#Wants=network-online.target
#After=syslog.target network-online.target
[Service]
User=root
#ExecStartPre=/bin/sleep 1800
ExecStart=sudo modprobe i2c-dev
[Install]
WantedBy=multi-user.target
EOF
##########
##############################
cat > /usr/local/bin/rpt-on.sh <<- "EOF"
#!/bin/bash
#TI4OP Oscar, [1/25/2022 12:51 PM]
if [ "$(grep "Duplex=1" /opt/MMDVMHost/MMDVM.ini)" != "" ]; then
# echo "rpt"
sudo systemctl enable mmdvmh.service
else
# echo "gateway"
sudo systemctl disable mmdvmh.service
fi
EOF
#
sudo chmod +x /usr/local/bin/rpt-on.sh
#########################
cd /opt
git clone https://github.com/g4klx/MMDVMHost.git
cd MMDVMHost/
sudo make
sudo make install
git clone https://github.com/hallard/ArduiPi_OLED
cd ArduiPi_OLED
sudo make
cd /opt/MMDVMHost/
make clean
sudo make -f Makefile.Pi.OLED
groupadd mmdvm
useradd mmdvm -g mmdvm -s /sbin/nologin
chown mmdvm /var/log/
##################################################################################################################################
# DMRGateway
#################################################################################################################################
cd /opt/
git clone https://github.com/g4klx/DMRGateway.git
cd DMRGateway
sudo make clean
sudo make
sudo make install
#################################################################################################################################
sudo cat > /usr/local/bin/rebooter1.sh <<- "EOF"
#!/bin/bash
sleep 180
while :
do
SERVER=noip.com
ping -c1 ${SERVER} > /dev/null
if [ $? != 0 ]
then
#
sudo reboot
fi
sleep 60
done
EOF
#
########ionosphere
mkdir /opt/ionsphere
cd /opt/ionsphere
wget https://github.com/cceremuga/ionosphere/releases/download/v1.0.0-beta1/ionosphere-raspberry-pi.tar.gz
tar vzxf ionosphere-raspberry-pi.tar.gz
cd /opt/ionsphere/ionosphere-raspberry-pi
cat > /opt/ionsphere/ionosphere-raspberry-pi/ionos.sh <<- "EOF"
#!/bin/sh
PATH=/bin:/usr/bin:/usr/local/bin
unset LANG
/opt/ionsphere/ionosphere-raspberry-pi/ionosphere
EOF
sudo chmod +x /opt/ionsphere/ionosphere-raspberry-pi/ionosphere
sudo chmod +x /opt/ionsphere/ionosphere-raspberry-pi/ionos.sh
chmod +777 /opt/ionsphere/ionosphere-raspberry-pi/ionos.sh
###nano /opt/ionsphere/ionosphere-raspberry-pi/config/config.yml
#########
cat > /lib/systemd/system/ionos.service <<- "EOF"
[Unit]
Description=Ionphere-RTL Service
Wants=network-online.target
After=syslog.target network-online.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/ionsphere/ionosphere-raspberry-pi
#ExecStartPre=/bin/sleep 30
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=sh /opt/ionsphere/ionosphere-raspberry-pi/ionos.sh
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
[Install]
# To make the network-online.target available
# systemctl enable systemd-networkd-wait-online.service
WantedBy=network-online.target
EOF
#############################################################
cat > /lib/systemd/system/dmrid-mmdvm.service <<- "EOF"
[Unit]
Description=DMRIDupdate MMDVMHost
Wants=network-online.target
After=syslog.target network-online.target
[Service]
User=root
#ExecStartPre=/bin/sleep 1800
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/MMDVMHost/DMRIDUpdate.sh
[Install]
WantedBy=multi-user.target
EOF
###################
cat > /lib/systemd/system/mmdvmh.service <<- "EOF"
[Unit]
Description=MMDVM Host Service
After=syslog.target network.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/MMDVMHost
#ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini
ExecStop=/usr/bin/screen -S MMDVMHost -X quit
[Install]
WantedBy=multi-user.target
EOF
#
cat > /lib/systemd/system/dmrgw.service <<- "EOF"
[Unit]
Description=DMRGateway Service
After=syslog.target network.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/DMRGateway
#ExecStartPre=/bin/sleep 10
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/usr/local/bin/DMRGateway /opt/DMRGateway/DMRGateway.ini
ExecStop=/usr/bin/screen -S DMRGateway -X quit
[Install]
WantedBy=multi-user.target
EOF
############
cat > /lib/systemd/system/dmrid-ysf2dmr.service <<- "EOF"
[Unit]
Description=DMRIDupdate YSF2DMR
Wants=network-online.target
After=syslog.target network-online.target
[Service]
User=root
#ExecStartPre=/bin/sleep 60
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/YSF2DMR/DMRIDUpdate.sh
[Install]
WantedBy=multi-user.target
EOF
#########
cat > /lib/systemd/system/multimon-rtl.service <<- "EOF"
[Unit]
Description=Multimon-RTL Service
Wants=network-online.target
After=syslog.target network-online.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=sudo pymultimonaprs
[Install]
WantedBy=multi-user.target
EOF
#####################
cat > /lib/systemd/system/ysf2dmr.service <<- "EOF"
[Unit]
Description=YSF2DMR Service
After=syslog.target network.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/YSF2DMR
#ExecStartPre=/bin/sleep 30
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/YSF2DMR/YSF2DMR /opt/YSF2DMR/YSF2DMR.ini
[Install]
WantedBy=multi-user.target
EOF
###########################
cat > /lib/systemd/system/ysf2dmrgw.service <<- "EOF"
[Unit]
Description=YSF2DMRGW Service
After=syslog.target network.target
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/YSF2DMRGW
#ExecStartPre=/bin/sleep 30
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/YSF2DMRGW/YSF2DMR /opt/YSF2DMRGW/YSF2DMR.ini
[Install]
WantedBy=multi-user.target
EOF
###########################
cat > /opt/MMDVMHost/MMDVM.ini <<- "EOF"
[General]
# Coloque su indicativo
Callsign=HP3ICC
# Coloque su DMRID de 7 digitos mas 2 digitos para su conexion
Id=000000000
Timeout=300
Duplex=0
ModeHang=10
#RFModeHang=10
#NetModeHang=3
Display=None
#Display=OLED
#Display=Nextion
Daemon=0
[Info]
# Colocar frecuencia 9 digitos sin puntos
RXFrequency=433400000
TXFrequency=433400000
Power=1
# The following lines are only needed if a direct connection to a DMR master is being used
Latitude=0.0
Longitude=0.0
Height=0
Location=Panama
Description=emq-TE1ws-MMDVM
URL=https://github.com/hp3icc/emq-TE1ws
[Log]
# Logging levels, 0=No logging
DisplayLevel=1
FileLevel=1
FilePath=/var/log/mmdvmh
FileRoot=MMDVMH
FileRotate=0
[CW Id]
Enable=0
Time=10
# Callsign=
[DMR Id Lookup]
File=/opt/MMDVMHost/DMRIds.dat
Time=24
[NXDN Id Lookup]
File=/opt/MMDVMHost/NXDN.csv
Time=24
[Modem]
# Valid values are "null", "uart", "udp", and (on Linux) "i2c"
Protocol=uart
# The port and speed used for a UART connection
# UARTPort=\\.\COM4
# UARTPort=/dev/ttyACM0
UARTPort=/dev/ttyAMA0
UARTSpeed=115200
#460800
# The port and address for an I2C connection
I2CPort=/dev/i2c
I2CAddress=0x22
# IP parameters for UDP connection
ModemAddress=192.168.2.100
ModemPort=3334
LocalAddress=192.168.2.1
LocalPort=3335
TXInvert=1
RXInvert=0
PTTInvert=0
TXDelay=100
RXOffset=0
TXOffset=0
DMRDelay=0
RXLevel=50
TXLevel=50
RXDCOffset=0
TXDCOffset=0
RFLevel=50
# CWIdTXLevel=50
# D-StarTXLevel=50
DMRTXLevel=50
YSFTXLevel=50
# P25TXLevel=50
# NXDNTXLevel=50
# M17TXLevel=50
# POCSAGTXLevel=50
# FMTXLevel=50
# AX25TXLevel=50
RSSIMappingFile=RSSI.dat
UseCOSAsLockout=0
Trace=0
Debug=0
[Transparent Data]
Enable=0
RemoteAddress=127.0.0.1
RemotePort=40094
LocalPort=40095
# SendFrameType=0
[D-Star]
Enable=0
Module=C
SelfOnly=0
AckReply=1
AckTime=750
AckMessage=0
ErrorReply=1
RemoteGateway=0
# ModeHang=10
WhiteList=
[DMR]
Enable=1
Beacons=0
BeaconInterval=60
BeaconDuration=3
ColorCode=1
SelfOnly=0
EmbeddedLCOnly=1
DumpTAData=0
# Prefixes=234,235
# Slot1TGWhiteList=
# Slot2TGWhiteList=
CallHang=3
TXHang=4
# ModeHang=10
# OVCM Values, 0=off, 1=rx_on, 2=tx_on, 3=both_on, 4=force off
# OVCM=0
[System Fusion]
Enable=1
LowDeviation=0
SelfOnly=0
TXHang=4
RemoteGateway=0
# ModeHang=10
[P25]
Enable=0
NAC=293
SelfOnly=0
OverrideUIDCheck=0
RemoteGateway=0
TXHang=5
# ModeHang=10
[NXDN]
Enable=0
RAN=1
SelfOnly=0
RemoteGateway=0
TXHang=5
# ModeHang=10
[M17]
Enable=0
CAN=0
SelfOnly=0
TXHang=5
# ModeHang=10
[POCSAG]
Enable=0
Frequency=439987500
[FM]
Enable=0
# Callsign=G4KLX
CallsignSpeed=20
CallsignFrequency=1000
CallsignTime=10
CallsignHoldoff=0
CallsignHighLevel=50
CallsignLowLevel=20
CallsignAtStart=1
CallsignAtEnd=1
CallsignAtLatch=0
RFAck=K
ExtAck=N
AckSpeed=20
AckFrequency=1750
AckMinTime=4
AckDelay=1000
AckLevel=50
# Timeout=180
TimeoutLevel=80
CTCSSFrequency=88.4
CTCSSThreshold=30
# CTCSSHighThreshold=30
# CTCSSLowThreshold=20
CTCSSLevel=20
KerchunkTime=0
HangTime=7
# AccessMode values are:
# 0 - Carrier access with COS
# 1 - CTCSS only access without COS
# 2 - CTCSS only access with COS
# 3 - CTCSS only access with COS to start, then carrier access with COS
AccessMode=1
# LinkMode=1 to remove almost all of the logic control
LinkMode=0
COSInvert=0
NoiseSquelch=0
SquelchThreshold=30
# SquelchHighThreshold=30
# SquelchLowThreshold=20
RFAudioBoost=1
MaxDevLevel=90
ExtAudioBoost=1
# ModeHang=10
[AX.25]
Enable=0
TXDelay=300
RXTwist=6
SlotTime=30
PPersist=128
Trace=1
[D-Star Network]
Enable=0
#LocalAddress=127.0.0.1
#LocalPort=20011
GatewayAddress=127.0.0.1
GatewayPort=20010
# ModeHang=3
Debug=0
[DMR Network]
Enable=1
# habilitar , o deshabilitar todas las lineas de 'Direct' o 'Gateway'
# quitando los simbolos # segun su tipo de conexion.
#
# Configuracion Gateway , habilita DMRGateway, conexion multiples server dmr.
# configuracion Direct , habilita conexion directa a un solo server dmr.
#
#########################################################
# Gateway - Multiples Server - DMRGateway #
#########################################################
#Type=Gateway
#LocalAddress=127.0.0.1
#LocalPort=62034
#RemoteAddress=127.0.0.1
#RemotePort=62033
#
#########################################################
# Direct - single server #
#########################################################
Type=Direct
RemoteAddress=198.211.36.245
RemotePort=62031
Password=passw0rd
#
#########################################################
Jitter=500
Slot1=1
Slot2=1
# No active linea de Option para TG estaticos, si utiliza BM,TGIF,DMR-Central
# Puede activar linea de option de selfcare FDMR-Mon y colocar su propia contraseña o
# utilizar linea de options con opciones de tg estaticos
Options=PASS=abc123
#Options=TS2=714,7144;DIAL=0;VOICE=0;LANG=es_ES;SINGLE=0;TIMER=10;
# ModeHang=3
Debug=0
[System Fusion Network]
Enable=1
# habilitar , o deshabilitar todas las lineas de 'Direct' o 'Gateway'
# quitando los simbolos # segun su tipo de conexion.
#
# Configuracion Gateway , habilita YSFGateway, WiresXCommandPassthrough.
# configuracion Direct , habilita conexion directa a un solo server YSF.
#
#########################################################
# Gateway mode - Multiples Server - DMRGateway #
#########################################################
#
#LocalAddress=127.0.0.1
#LocalPort=3330
#GatewayAddress=127.0.0.1
#GatewayPort=4330
#
#########################################################
# Direct mode - Multiples Server - DMRGateway #
#########################################################
#
GatewayAddress=europelink.pa7lim.nl
GatewayPort=42000
#
##########################################################
# ModeHang=3
Debug=0
[P25 Network]
Enable=0
#LocalAddress=127.0.0.1
#LocalPort=32010
GatewayAddress=127.0.0.1
GatewayPort=42020
# ModeHang=3
Debug=0
[NXDN Network]
Enable=0
Protocol=Icom
#LocalAddress=127.0.0.1
#LocalPort=14021
GatewayAddress=127.0.0.1
GatewayPort=14020
# ModeHang=3
Debug=0
[M17 Network]
Enable=0
#LocalAddress=127.0.0.1
#LocalPort=17011
GatewayAddress=127.0.0.1
GatewayPort=17010
# ModeHang=3
Debug=0
[POCSAG Network]
Enable=0
#LocalAddress=127.0.0.1
#LocalPort=3800
GatewayAddress=127.0.0.1
GatewayPort=4800
# ModeHang=3
Debug=0
[FM Network]
Enable=0
# Protocol=USRP
#LocalAddress=127.0.0.1
#LocalPort=3810
GatewayAddress=127.0.0.1
GatewayPort=4810
PreEmphasis=1
DeEmphasis=1
TXAudioGain=1.0
RXAudioGain=1.0
# ModeHang=3
Debug=0
[AX.25 Network]
Enable=0
Port=/dev/ttyp7
Speed=9600
Debug=0
[TFT Serial]
# Port=modem
Port=/dev/ttyAMA0
Brightness=50
[HD44780]
Rows=2
Columns=16
# For basic HD44780 displays (4-bit connection)
# rs, strb, d0, d1, d2, d3
Pins=11,10,0,1,2,3
# Device address for I2C
I2CAddress=0x20
# PWM backlight
PWM=0
PWMPin=21
PWMBright=100
PWMDim=16
DisplayClock=1
UTC=0
[Nextion]
Port=modem
#Port=/dev/ttyAMA0
Brightness=50
DisplayClock=1
UTC=0
#Screen Layout: 0=G4KLX 2=ON7LDS
ScreenLayout=2
IdleBrightness=20
[OLED]
Type=3
Brightness=1
Invert=0
Scroll=0
Rotate=1
Cast=0
LogoScreensaver=0
[LCDproc]
Address=localhost
Port=13666
#LocalPort=13667
DimOnIdle=0
DisplayClock=1
UTC=0
[Lock File]
Enable=0
File=/tmp/MMDVM_Active.lck
[Remote Control]
Enable=0
Address=127.0.0.1
Port=7642
EOF
########
cat > /opt/DMRGateway/DMRGateway.ini <<- "EOF"
[General]
Timeout=10
# RFTimeout=10
# NetTimeout=7
RptAddress=127.0.0.1
RptPort=62034
LocalAddress=127.0.0.1
LocalPort=62033
RuleTrace=0
Daemon=0
Debug=0
[Log]
# Logging levels, 0=No logging
DisplayLevel=1
FileLevel=1
FilePath=.
FileRoot=DMRGateway
FileRotate=1
[Voice]
Enabled=1
Language=es_ES
Directory=./Audio
[Info]
Latitude=0.0
Longitude=0.0
Height=0
Location=DMR Gateway
Description=Multi-Mode DMRGateway
URL=https://github.com/hp3icc/emq-TE1ws
[XLX Network]
#DMRID 7 DIGIT ONLY
Id=1234567
Enabled=0
File=/opt/DMRGateway/XLXHosts.txt
Port=62030
Password=passw0rd
ReloadTime=60
# Local=3351
Slot=2
TG=6
Base=64000
Startup=744
Relink=10
Debug=0
#Allow user linking control using Private Calls
UserControl=1
#Override default module for startup reflector
Module=A
# BrandMeister
[DMR Network 1]
#Id=000000000
Enabled=0
Name=BrandMeister
Address=3021.master.brandmeister.network
Port=62031
TGRewrite0=2,1000001,2,1,999999
PCRewrite=2,1000001,2,1,999999
PassAllPC=1
PassAllPC=2
Password=passw0rd
Location=1
Debug=0
# FreeDMR
[DMR Network 2]
#Id=000000000
Enabled=0
Name=FreeDMR
TGRewrite0=2,2000001,2,1,999999
PCRewrite=2,2000001,2,1,999999
# Puede activar linea de options de selfcare y colocar su propia contraseña o
# utilizar linea de options con opciones de tg estaticos
Options="PASS=abc123"
#Options="TS2=714,7144;DIAL=0;VOICE=0;LANG=es_ES;SINGLE=1;TIMER=10;"
Address=198.211.36.245
Password=passw0rd
Port=62031
Location=0
Debug=0
# TGIF Network
[DMR Network 3]
#Id=000000000
Enabled=0
Name=TGIF_Network
TGRewrite0=2,3000001,2,1,999999
PCRewrite=2,3000001,2,1,999999
#Options=
Address=tgif.network
Password=passw0rd
Port=62031
Location=0
Debug=0
# DMR Central
[DMR Network 4]
#Id=000000000
Enabled=0
Name=DMR Central
Address=dmr.pa7lim.nl
Port=55555
TGRewrite0=2,4000001,2,1,999999
PCRewrite=2,4000001,2,1,999999
#Options=
Password=passw0rd
Location=0
Debug=0
# FreeStar Network
[DMR Network 5]
#Id=000000000
Enabled=0
Name=FreeStar
Address=es.freestar.network
Port=62031
TGRewrite0=2,5000001,2,1,999999
PCRewrite=2,5000001,2,1,999999
Options="TS2=7144;DIAL=0;VOICE=0;LANG=0;SINGLE=0;TIMER=10;"
Password=passw0rd
Location=0
Debug=0
[GPSD]
Enable=0
Address=127.0.0.1
Port=2947
[APRS]
Enable=0
Address=127.0.0.1
Port=8673
Description=APRS Description
Suffix=3
[Dynamic TG Control]
Enabled=1
Port=3769
[Remote Control]
Enable=0
Address=127.0.0.1
Port=7643
EOF
#########
cat > /opt/YSF2DMR/YSF2DMR.ini <<- "EOF"
[Info]
RXFrequency=438800000
TXFrequency=438800000
Power=1
Latitude=0.0
Longitude=0.0
Height=0
Location=YSF2DMR Link
Description=Multi-Mode
URL=www.google.co.uk
[YSF Network]
Callsign=HP3ICC
Suffix=ND
#Suffix=RPT
DstAddress=127.0.0.1
DstPort=42000
LocalAddress=127.0.0.1
#LocalPort=42013
EnableWiresX=0
RemoteGateway=0
HangTime=1000
WiresXMakeUpper=0
# RadioID=*****
# FICHCallsign=2
# FICHCallMode=0
# FICHBlockTotal=0
# FICHFrameTotal=6
# FICHMessageRoute=0
# FICHVOIP=0
# FICHDataType=2
# FICHSQLType=0
# FICHSQLCode=0
DT1=1,34,97,95,43,3,17,0,0,0
DT2=0,0,0,0,108,32,28,32,3,8
Daemon=0
[DMR Network]
Id=714000000
#XLXFile=/opt/DMRGateway/XLXHosts.txt
#XLXReflector=HP3
#XLXModule=D
StartupDstId=714
# For TG call: StartupPC=0
StartupPC=0
Address=127.0.0.1
Port=54102
Jitter=500
EnableUnlink=0
TGUnlink=4000
PCUnlink=0
# Local=62032
Password=passw@rd
# No active linea de Option para TG estaticos, si utiliza BM,TGIF,DMR-Central
# Puede activar linea de option de selfcare FDMR-Mon y colocar su propia contraseña o
# utilizar linea de options con opciones de tg estaticos
#Options=PASS=abc123
#Options=TS2=714;DIAL=0;VOICE=0;LANG=es_ES;SINGLE=0;TIMER=10;
TGListFile=/opt/YSF2DMRGW/TGList-DMR.txt
Debug=0
[DMR Id Lookup]
File=/opt/MMDVMHost/DMRIds.dat
Time=24
DropUnknown=0
[Log]
# Logging levels, 0=No logging
DisplayLevel=1
FileLevel=1
FilePath=/var/log/ysf2dmr/
FileRoot=YSF2DMR2
[aprs.fi]
Enable=0
AprsCallsign=HP3ICC
Server=noam.aprs2.net
#Server=euro.aprs2.net
Port=14580
Password=12345
APIKey=APIKey
Refresh=240
Description=APRS Description
EOF
###################
cat > /opt/YSF2DMRGW/YSF2DMR.ini <<- "EOF"
[Info]
RXFrequency=438800000
TXFrequency=438800000
Power=1
Latitude=0.0
Longitude=0.0
Height=0
Location=YSF2DMRGW
Description=Multi-Mode
URL=www.google.co.uk
[YSF Network]
Callsign=HP3ICC
Suffix=ND
#Suffix=RPT
DstAddress=127.0.0.1
DstPort=42400
LocalAddress=127.0.0.1
LocalPort=42018
EnableWiresX=1
RemoteGateway=0
HangTime=1000
WiresXMakeUpper=0
# RadioID=*****
# FICHCallsign=2
# FICHCallMode=0
# FICHBlockTotal=0
# FICHFrameTotal=6
# FICHMessageRoute=0
# FICHVOIP=0
# FICHDataType=2
# FICHSQLType=0
# FICHSQLCode=0
DT1=1,34,97,95,43,3,17,0,0,0
DT2=0,0,0,0,108,32,28,32,3,8
Daemon=0
[DMR Network]
Id=000000000
#XLXFile=/opt/DMRGateway/XLXHosts.txt
#XLXReflector=HP3
#XLXModule=D
StartupDstId=9
# For TG call: StartupPC=0
StartupPC=0
Address=198.211.36.245
Port=62031
Jitter=500
EnableUnlink=0
TGUnlink=4000
PCUnlink=0
# Local=62032
Password=passw0rd
# No active linea de Option para TG estaticos, si utiliza BM,TGIF,DMR-Central
# Puede activar linea de option de selfcare FDMR-Mon y colocar su propia contraseña o
# utilizar linea de options con opciones de tg estaticos
Options=PASS=abc123
#Options=TS2=714;DIAL=0;VOICE=0;LANG=es_ES;SINGLE=0;TIMER=10;
TGListFile=/opt/YSF2DMRGW/TGList-DMR.txt
Debug=0
[DMR Id Lookup]
File=/opt/MMDVMHost/DMRIds.dat
Time=24
DropUnknown=0
[Log]
# Logging levels, 0=No logging
DisplayLevel=1
FileLevel=1
FilePath=/var/log/ysf2dmr/
FileRoot=YSF2DMR
[aprs.fi]
Enable=0
AprsCallsign=HP3ICC
Server=noam.aprs2.net
#Server=euro.aprs2.net
Port=14580
Password=12345
APIKey=APIKey
Refresh=240
Description=APRS Description
EOF
###################
cat > /etc/pymultimonaprs.json <<- "EOF"
{
"callsign": "HP3ICC-10",
"passcode": "12345",
"gateway": ["igates.aprs.fi:14580","noam.aprs2.net:14580"],
"preferred_protocol": "any",
"append_callsign": true,
"source": "rtl",
"rtl": {
"freq": 144.390,
"ppm": 0,
"gain": 24,
"offset_tuning": false,
"device_index": 0
},
"alsa": {
"device": "default"
},
"beacon": {
"lat": 8.5212,
"lng": -80.3598,
"table": "/",
"symbol": "r",
"comment": "APRS RX-IGATE / Raspbian Proyect by hp3icc",
"status": {
"text": "",
"file": false
},
"weather": false,
"send_every": 300,
"ambiguity": 0
}
}
EOF
################################################################################################################################
cat > /opt/ionsphere/ionosphere-raspberry-pi/config/config.yml <<- "EOF"
rtl:
path: "rtl_fm"
frequency: "144.390M"
gain: "49.6"
ppm-error: "0"
squelch-level: "0"
sample-rate: "22050"
additional-flags: ""
multimon:
path: "multimon-ng"
additional-flags: ""
beacon:
enabled: false
call-sign: ""
interval: 30m
comment: ""
handlers:
- id: "4967ade5-7a97-416f-86bf-6e2ae8a5e581"
name: "stdout"
- id: "b67ac5d5-3612-4618-88a9-a63d36a1777c"
name: "aprsis"
options:
enabled: true
server: "igates.aprs.fi:14580"
call-sign: "HP3ICC-10"
passcode: "12345"
filter: ""
EOF
###########################################################################################################################
# noip
###########################################################################################################################
sudo mkdir /opt/noip
cd /opt/noip/
wget https://www.noip.com/client/linux/noip-duc-linux.tar.gz
tar vzxf noip-duc-linux.tar.gz
cd noip-2.1.9-1
sudo make
#####################################################################################################################
cd /opt/
git clone https://gitlab.com/hp3icc/D-APRS.git
#
sudo cat > /lib/systemd/system/daprs.service <<- "EOF"
[Unit]
Description=Data bridge APRS
After=network-online.target syslog.target
Wants=network-online.target
[Service]
StandardOutput=null
WorkingDirectory=/opt/D-APRS
RestartSec=3
ExecStart=/usr/bin/python3 /opt/D-APRS/gps_data.py
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOF
#
sudo cat > /lib/systemd/system/daprs-board.service <<- "EOF"
[Unit]
Description=Dashboard D-APRS
After=network-online.target syslog.target
Wants=network-online.target
[Service]
StandardOutput=null
WorkingDirectory=/opt/D-APRS/dashboard
RestartSec=3
ExecStart=/usr/bin/python3 /opt/D-APRS/dashboard/dashboard.py -c /opt/D-APRS/gps_data.cfg
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOF
###############################
cat > /opt/MMDVMHost/DMRIDUpdate.sh <<- "EOF"
#! /bin/bash
###############################################################################
#
# CONFIGURATION
#
# Full path to DMR ID file, without final slash
DMRIDPATH=/opt/MMDVMHost
DMRIDFILE=${DMRIDPATH}/DMRIds.dat
# DMR IDs now served by RadioID.net
DATABASEURL='https://ham-digital.org/status/users.csv'
#DATABASEURL='https://www.radioid.net/static/user.csv'
#
# How many DMR ID files do you want backed up (0 = do not keep backups)
DMRFILEBACKUP=1
#
# Command line to restart MMDVMHost
RESTARTCOMMAND="sudo systemctl restart mmdvmh.service && sudo systemctl restart dmrgw.service && sudo systemctl restart ysfgw.service && sudo systemctl restart ysf2dmrgw.service"
# RESTARTCOMMAND="killall MMDVMHost ; /path/to/MMDVMHost/executable/MMDVMHost /path/to/MMDVM/ini/file/MMDVM.ini"
###############################################################################
#
# Do not edit below here
#
###############################################################################
# Check we are root
if [ "$(id -u)" != "0" ]
then
echo "This script must be run as root" 1>&2
exit 1
fi
# Create backup of old file
if [ ${DMRFILEBACKUP} -ne 0 ]
then
cp ${DMRIDFILE} ${DMRIDFILE}.$(date +%d%m%y)
fi
# Prune backups
BACKUPCOUNT=$(ls ${DMRIDFILE}.* | wc -l)
BACKUPSTODELETE=$(expr ${BACKUPCOUNT} - ${DMRFILEBACKUP})
if [ ${BACKUPCOUNT} -gt ${DMRFILEBACKUP} ]
then
for f in $(ls -tr ${DMRIDFILE}.* | head -${BACKUPSTODELETE})
do
rm $f
done
fi
# Generate new file
sh /opt/XLXHostsupdate.sh
wget https://www.radioid.net/static/nxdn.csv -O /opt/MMDVMHost/NXDN.csv
wget http://www.pistar.uk/downloads/YSF_Hosts.txt -O /opt/YSFGateway2/YSF_Hosts.txt
wget http://www.pistar.uk/downloads/FCS_Hosts.txt -O /opt/YSFGateway2/FCS_Hosts.txt
wget http://freedmr-hp.ddns.net/downloads/TGList_BM.txt -O /opt/YSF2DMRGW/TGList-DMR.txt
curl ${DATABASEURL} 2>/dev/null | sed -e 's/\t//g' | awk -F"," '/,/{gsub(/ /, "", $2); printf "%s\t%s\t%s\n", $1, $2, $3}' | sed -e 's/\(.\) .*/\1/g' > ${DMRIDPATH}/DMRIds.tmp
NUMOFLINES=$(wc -l ${DMRIDPATH}/DMRIds.tmp | awk '{print $1}')
if [ $NUMOFLINES -gt 1 ]
then
mv ${DMRIDPATH}/DMRIds.tmp ${DMRIDFILE}
else
echo " ERROR during file update "
rm ${DMRIDPATH}/DMRIds.tmp
fi
# Restart ysf2dmr
eval ${RESTARTCOMMAND}
EOF
###
cat > /opt/XLXHostsupdate.sh <<- "EOF"
#! /bin/bash
###############################################################################
#
# XLXHostsupdate.sh
#
# Copyright (C) 2016 by Tony Corbett G0WFV
# Copyright (C) 2017 by Jonathan Naylor G4KLX
#
# Adapted to YSFHosts by Paul Nannery KC2VRJ on 6/28/2016 with all crdeit
# to G0WFV for the orignal script.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###############################################################################
#
# On a Linux based system, such as a Raspberry Pi, this script will perform all
# the steps required to maintain the XLXHosts.txt (or similar) file for you.
#
# It is designed to run from crontab and will download the XLXHosts from the
# master XLX DMR Master database and optionally keep a backup of previously
# created files for you.
#
# It will also prune the number of backup files according to a value specified
# by you in the configuration below.
#
# To install in root's crontab use the command ...
#
# sudo crontab -e
#
# ... and add the following line to the bottom of the file ...
#
# 0 0 * * * /path/to/script/XLXHostsupdate.sh /path/to/XLXHosts.txt 1>/dev/null 2>&1
#
# ... where:
# /path/to/script/ should be replaced by the path to this script.
# /path/to/XLXHosts.txt should be replaced by the path to XLX hosts file
#
###############################################################################
#
# CONFIGURATION
#
# first argument as path to XLXHosts.txt.
# default so script's directory if empty
if [ -n "$1" ] ; then
XLXHOSTS="$1"
else
XLXHOSTS="$(dirname $0)/DMRGateway/XLXHosts.txt"
fi
echo "Updating $XLXHOSTS ..."
# How many XLXHosts files do you want backed up (0 = do not keep backups)
XLXHOSTSFILEBACKUP=1
###############################################################################
#
# Do not edit below here
#
###############################################################################
# Check we are root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Create backup of old file
if [ ${XLXHOSTSFILEBACKUP} -ne 0 ]; then
cp ${XLXHOSTS} ${XLXHOSTS}.$(date +%d%m%y)
fi
# Prune backups
BACKUPCOUNT=$(ls ${XLXHOSTS}.* | wc -l)
BACKUPSTODELETE=$(expr ${BACKUPCOUNT} - ${XLXHOSTSFILEBACKUP})
if [ ${BACKUPCOUNT} -gt ${XLXHOSTSFILEBACKUP} ]; then
for f in $(ls -tr ${XLXHOSTS}.* | head -${BACKUPSTODELETE}); do
rm -f $f
done
fi
# Generate XLXHosts.txt file
curl http://xlxapi.rlx.lu/api.php?do=GetXLXDMRMaster | awk '
BEGIN {
print "# The format of this file is:"
print "# XLX Number;host;default"
}
/^XLX/ {
reflector=4004
if ($1 == "XLX004")
reflector=4001
if ($1 == "XLX235")
reflector=4001
if ($1 == "XLX268")
reflector=4005
if ($1 == "XLX284")
reflector=4002
if ($1 == "XLX313")
reflector=4001
if ($1 == "XLX359")
reflector=4002
if ($1 == "XLX389")
reflector=4017
if ($1 == "XLX518")
reflector=4006
if ($1 == "XLX755")
reflector=4011
if ($1 == "XLX886")
reflector=4003
if ($1 == "XLX950")
reflector=4005
printf "%s;%s;%d\n", substr($1,4), substr($2,1,length($2)-1), reflector
}' > ${XLXHOSTS}
exit 0
EOF
#
sudo chmod +x /opt/XLXHostsupdate.sh
###
cat > /opt/YSF2DMR/DMRIDUpdate.sh <<- "EOF"
#! /bin/bash
###############################################################################
#
# CONFIGURATION
#
# Full path to DMR ID file, without final slash
DMRIDPATH=/opt/MMDVMHost
DMRIDFILE=${DMRIDPATH}/DMRIds.dat
# DMR IDs now served by RadioID.net
DATABASEURL='https://ham-digital.org/status/users.csv'
#DATABASEURL='https://www.radioid.net/static/user.csv'
#
# How many DMR ID files do you want backed up (0 = do not keep backups)
DMRFILEBACKUP=1
#
# Command line to restart MMDVMHost
RESTARTCOMMAND="sudo systemctl restart ysf2dmr.service"
# RESTARTCOMMAND="killall MMDVMHost ; /path/to/MMDVMHost/executable/MMDVMHost /path/to/MMDVM/ini/file/MMDVM.ini"
###############################################################################
#
# Do not edit below here
#
###############################################################################
# Check we are root
if [ "$(id -u)" != "0" ]
then
echo "This script must be run as root" 1>&2
exit 1
fi
# Create backup of old file
if [ ${DMRFILEBACKUP} -ne 0 ]
then
cp ${DMRIDFILE} ${DMRIDFILE}.$(date +%d%m%y)
fi
# Prune backups
BACKUPCOUNT=$(ls ${DMRIDFILE}.* | wc -l)
BACKUPSTODELETE=$(expr ${BACKUPCOUNT} - ${DMRFILEBACKUP})
if [ ${BACKUPCOUNT} -gt ${DMRFILEBACKUP} ]
then
for f in $(ls -tr ${DMRIDFILE}.* | head -${BACKUPSTODELETE})
do
rm $f
done
fi
# Generate new file
sh /opt/XLXHostsupdate.sh
wget https://www.radioid.net/static/nxdn.csv -O /opt/MMDVMHost/NXDN.csv
wget http://freedmr-hp.ddns.net/downloads/TGList_BM.txt -O /opt/YSF2DMRGW/TGList-DMR.txt
sh /opt/XLXHostsupdate.sh
curl ${DATABASEURL} 2>/dev/null | sed -e 's/\t//g' | awk -F"," '/,/{gsub(/ /, "", $2); printf "%s\t%s\t%s\n", $1, $2, $3}' | sed -e 's/\(.\) .*/\1/g' > ${DMRIDPATH}/DMRIds.tmp
NUMOFLINES=$(wc -l ${DMRIDPATH}/DMRIds.tmp | awk '{print $1}')
if [ $NUMOFLINES -gt 1 ]
then
mv ${DMRIDPATH}/DMRIds.tmp ${DMRIDFILE}
else
echo " ERROR during file update "
rm ${DMRIDPATH}/DMRIds.tmp
fi
# Restart ysf2dmr
eval ${RESTARTCOMMAND}
EOF
###
cp /opt/MMDVMHost/DMRIDUpdate.sh /opt/MMDVMHost/DMRIDUpdate2.sh
sudo chmod +x /opt/MMDVMHost/DMRIDUpdate.sh
sudo chmod +x /opt/MMDVMHost/DMRIDUpdate2.sh
###
cp /opt/YSF2DMR/DMRIDUpdate.sh /opt/YSF2DMR/DMRIDUpdate2.sh
sudo chmod +x /opt/YSF2DMR/DMRIDUpdate.sh
sudo chmod +x /opt/YSF2DMR/DMRIDUpdate2.sh
#####################################################################################################################
mkdir /opt/YSFGateway2/
cp -r /opt/YSFGateway/* /opt/YSFGateway2/
cd /opt/YSFGateway2/
sudo chmod +x *
sudo sed -i "s/# YSF2DMRAddress=127.0.0.1/YSF2DMRAddress=127.0.0.1/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/# YSF2DMRPort=42013/YSF2DMRPort=42013/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/3230/3330/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/Suffix=RPT/# Suffix=RPT/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/# Suffix=ND/Suffix=ND/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/4230/4330/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/42013/42018/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/42500/42400/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/43001/44001/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/# YSF2DMRAddress=127.0.0.1/YSF2DMRAddress=127.0.0.1/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/# YSF2DMRPort=42013/YSF2DMRPort=42013/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/6073/6075/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/YSFGateway/YSFGateway2/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/Iceberg/Panama/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/DVSwitch/YSFGateway/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/# Startup=Alabama-Link/Startup=EUROPELINK/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/WiresXCommandPassthrough=0/WiresXCommandPassthrough=1/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/Enable=1/Enable=0/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/var\/lib\/mmdvm\/YSFHosts.txt/opt\/YSFGateway2\/YSF_Hosts.txt/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/var\/lib\/mmdvm\/FCSRooms.txt/opt\/YSFGateway2\/FCS_Hosts.txt/g" /opt/YSFGateway2/YSFGateway.ini
sudo sed -i "s/N0CALL/HP3ICC/g" /opt/YSFGateway2/YSFGateway.ini
###################
cat > /lib/systemd/system/ysfgw.service <<- "EOF"
[Unit]
Description=YSF Gateway 2 Service
# Description=Place this file in /lib/systemd/system
# Description=N4IRS 01/17/2020
#After=netcheck.service
#Requires=netcheck.service
[Service]
User=root
Type=simple
Restart=always
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/YSFGateway2
ExecStartPre=/bin/sh -c 'until ping -c1 noip.com; do sleep 1; done;'
ExecStart=/opt/YSFGateway2/YSFGateway /opt/YSFGateway2/YSFGateway.ini
[Install]
WantedBy=multi-user.target
EOF
######################################################################################################################
# Cronedit
######################################################################################################################
cat > /usr/local/bin/cronedit.sh <<- "EOF"
cronjob_editor () {
# usage: cronjob_editor '<interval>' '<command>' <add|remove>
if [[ -z "$1" ]] ;then printf " no interval specified\n" ;fi
if [[ -z "$2" ]] ;then printf " no command specified\n" ;fi
if [[ -z "$3" ]] ;then printf " no action specified\n" ;fi
if [[ "$3" == add ]] ;then
# add cronjob, no duplication:
( sudo crontab -l | grep -v -F -w "$2" ; echo "$1 $2" ) | sudo crontab -
elif [[ "$3" == remove ]] ;then
# remove cronjob:
( sudo crontab -l | grep -v -F -w "$2" ) | sudo crontab -
fi
}
cronjob_editor "$1" "$2" "$3"
EOF
sudo chmod +x /usr/local/bin/cronedit.sh
######################################################################################################################
# freedmr+
######################################################################################################################
sh -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/fdmr.sh)"
######################################################################################################################
# shell-aprs
######################################################################################################################
sh -c "$(curl -fsSL https://raw.githubusercontent.com/hp3icc/shell-aprs/main/shell.sh)"
######################################################################################################################
# gotty
######################################################################################################################
cd /tmp/
if [ "$(uname -m | grep '64')" != "" ]; then
# echo "ARCH: 64-bit"
wget -qO gotty.tar.gz https://github.com/yudai/gotty/releases/latest/download/gotty_linux_amd64.tar.gz
else
# echo "ARCH: 32-bit"
wget -qO gotty.tar.gz https://github.com/yudai/gotty/releases/latest/download/gotty_linux_arm.tar.gz
fi
sudo tar xf gotty.tar.gz -C /usr/local/bin
sudo chmod a+x /usr/local/bin/gotty
rm gotty.tar.gz
#
sudo cat > /lib/systemd/system/gotty.service <<- "EOF"
[Unit]
Description=GoTTY
After=multi-user.target
[Service]
User=root
Environment=TERM=xterm-256color
ExecStartPre=/bin/sleep 40
ExecStart=gotty -p "8022" -w -c "pi:Panama507" menu
[Install]
WantedBy=multi-user.target
EOF
############################################################################################################################
sudo timedatectl set-timezone America/Panama
#####
sudo cat > /boot/wpa_supplicant.conf <<- "EOF"
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=PA
##################################################################
# #
# Favor tomar como referencia, las dos redes wifi que aparecen #
# abajo, puede editar con los datos de su red wifi o agregar un #
# network nuevo, por cada red wifi nueva que quiera almacenar. #
# #
# Raspbian proyect by HP3ICC, 73. #
# #
##################################################################
network={
key_mgmt=NONE
}
network={
ssid="Coloque_aqui_nombre_de_red_wifi"
psk="Coloque_aqui_la_clave_wifi"
}
EOF
#############################################################################################################################
sudo chown -R mmdvm:mmdvm /opt/MMDVMHost/MMDVMHost
sudo chmod +777 /opt/*
sudo chmod +777 /opt/MMDVMHost-Websocketboard/*
sudo chmod +777 /opt/WSYSFDash/*
sudo chmod +777 /opt/direwolf/*
sudo chmod +777 /opt/direwolf/dw.conf
sudo chmod +777 /opt/direwolf/sdr.conf
sudo chmod +777 /opt/direwolf/src/*
sudo chmod +777 /opt/MMDVMHost/*
sudo chmod +777 /opt/MMDVMHost/MMDVM.ini
sudo chmod +777 /opt/YSF2DMR/*
sudo chmod +777 /opt/YSF2DMR/YSF2DMR.ini
sudo chmod +777 /opt/ionsphere/*
sudo chmod +777 /opt/ionsphere/ionosphere-raspberry-pi/config/config.yml
sudo chmod +777 /opt/pymultimonaprs/*
sudo chmod +777 /opt/multimon-ng/*
sudo chmod +777 /opt/kalibrate-rtl/*
sudo chmod +777 /opt/MMDVM_CM/*
sudo chmod +777 /opt/MMDVM_Bridge/*
sudo chmod +777 /opt/MMDVM_Bridge/MMDVM_Bridge.ini
sudo chmod +777 /etc/pymultimonaprs.json
sudo chmod +777 /opt/D-APRS/user_settings.txt
sudo chmod +x /opt/FDMR-Monitor/sysinfo/graph.sh
sudo chmod +x /opt/FDMR-Monitor/sysinfo/cpu.sh
sudo chmod +x /usr/bin/python3
sudo chmod +x /opt/YSF2DMR/DMRIDUpdate.sh
sudo chmod +x /opt/MMDVMHost/DMRIDUpdate.sh
sudo chmod +x /opt/D-APRS/*.py
sudo chmod +x /opt/D-APRS/dashboard/*.py
sudo chmod +x /usr/local/bin/rebooter1.sh
sudo chmod 755 /lib/systemd/system/daprs-board.service
sudo chmod 755 /lib/systemd/system/rebooter1.service
sudo chmod 755 /lib/systemd/system/gotty.service
sudo chmod 755 /usr/local/bin/rebooter1.sh
sudo chmod 755 /lib/systemd/system/daprs.service
sudo chmod 755 /lib/systemd/system/http.server-dvs.service
sudo chmod 755 /lib/systemd/system/freedmr.service
sudo chmod 755 /lib/systemd/system/proxy.service
sudo chmod 755 /lib/systemd/system/fdmr_mon.service
sudo chmod 755 /lib/systemd/system/YSFReflector.service
sudo chmod 755 /lib/systemd/system/monp.service
sudo chmod 755 /lib/systemd/system/dmrid-ysf2dmr.service
sudo chmod 755 /lib/systemd/system/dmrid-mmdvm.service
sudo chmod 755 /lib/systemd/system/mmdvmh.service
sudo chmod 755 /lib/systemd/system/direwolf.service
sudo chmod 755 /lib/systemd/system/direwolf-rtl.service
sudo chmod 755 /lib/systemd/system/multimon-rtl.service
sudo chmod 755 /lib/systemd/system/ionos.service
sudo chmod 755 /lib/systemd/system/ysf2dmr.service
sudo chmod 755 /lib/systemd/system/http.server-mmdvmh.service
sudo chmod 755 /lib/systemd/system/logtailer-mmdvmh.service
sudo chmod 755 /lib/systemd/system/http.server-ysf.service
sudo chmod 755 /lib/systemd/system/logtailer-ysf.service
sudo chmod 755 /lib/systemd/system/dmrgw.service
sudo systemctl daemon-reload
sudo systemctl stop mariadb.service
sudo systemctl disable mariadb.service
sudo systemctl enable monp.service
sudo systemctl stop rsyslog
sudo systemctl disable rsyslog
sudo systemctl stop webproxy.service
sudo systemctl disable webproxy.service
sudo systemctl enable gotty.service
sudo systemctl disable netcheck.service
sudo systemctl disable systemd-networkd-wait-online.service
sudo systemctl disable dphys-swapfile-back.service
mv /lib/systemd/system/dphys-swapfile.service /lib/systemd/system/dphys-swapfile-back.service
rm /var/log/syslog*
rm /var/log/*.log*
cd /tmp/
(crontab -l; echo "* */1 * * * sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1")|awk '!x[$0]++'|crontab -
#####
cat > /tmp/completado.sh <<- "EOF"
#!/bin/bash
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC Esteban Mackay 73." --menu " Precione enter (return o intro) para finalizar la instalacion y reiniciar" 11 85 3 \
1 " Iniciar Reinicio de equipo " 3>&1 1>&2 2>&3)
exitstatus=$?
#on recupere ce choix
#exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "Your chosen option:" $choix
else
echo "You chose cancel."; break;
fi
# case : action en fonction du choix
case $choix in
1)
sudo reboot
;;
esac
done
exit 0
EOF
###
sudo chmod +x /tmp/completado.sh
##
sudo update-rc.d dphys-swapfile remove
sudo chmod -x /etc/init.d/dphys-swapfile
sudo dphys-swapfile swapoff
sudo swapoff -a
sudo rm /var/swap
sudo dphys-swapfile uninstall
cd /etc/
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=0/' dphys-swapfile
##
history -c && history -w
sh /tmp/completado.sh