mirror of
https://github.com/n5amd/NextionDriverInstaller.git
synced 2026-01-04 23:50:04 +01:00
First release
This commit is contained in:
commit
aeb66510c6
200
NextionDriver_ConvertConfig
Executable file
200
NextionDriver_ConvertConfig
Executable file
|
|
@ -0,0 +1,200 @@
|
|||
#!/bin/bash
|
||||
#########################################################
|
||||
# #
|
||||
# MMDVMHost configuration patcher #
|
||||
# #
|
||||
# (c)2018 by ON7LDS #
|
||||
# #
|
||||
# V1.01 #
|
||||
# #
|
||||
# This program changes the MMDVMHost configuration #
|
||||
# file to suit the needs of NextionDriver #
|
||||
# #
|
||||
#########################################################
|
||||
|
||||
#Where do we find the data files (groups and DMR is's)
|
||||
#for Pi-Star : /usr/local/etc/
|
||||
DATAFILES="/usr/local/etc/"
|
||||
|
||||
#########################################################
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
echo "You have to specify the config file !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MMDVMConfig=$1
|
||||
VERSION="1.01"
|
||||
echo ""
|
||||
#echo "Starting NextionDriver_ConvertConfig $VERSION"
|
||||
echo ""
|
||||
echo "NOTE: I tried to make this script as foolproof as possible."
|
||||
echo " There might still be situations where it does not work"
|
||||
echo " as expected."
|
||||
echo " If you should discover any bugs, please let me know."
|
||||
echo ""
|
||||
echo "Starting NextionDriver_ConvertConfig $VERSION"
|
||||
echo ""
|
||||
|
||||
if [[ -f "$MMDVMConfig" && -w "$MMDVMConfig" ]]; then
|
||||
echo "Processing ..."
|
||||
else
|
||||
echo "The file is not a regular file or writable !"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ -f "$MMDVMConfig.old" ]]; then
|
||||
echo "There already is a backup file $MMDVMConfig.old"
|
||||
echo " If you are sure to run the installer again, then Please remove it."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
if [ "$line" == "[NextionDriver]" ]; then
|
||||
echo "There already is a [NextionDriver] section."
|
||||
echo " I'm going to leave the file as is."
|
||||
echo " You'll have to change it by hand if necessary."
|
||||
exit 4
|
||||
fi
|
||||
done < "$MMDVMConfig"
|
||||
|
||||
# Ok, alles lijkt goed.
|
||||
mv "$MMDVMConfig" "$MMDVMConfig.old"
|
||||
|
||||
|
||||
NEXTIONPORT_IS_MODEM=""
|
||||
NEXTIONPORT_IS_DRIVER=""
|
||||
TRANSPARENT=""
|
||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
#sectie bepalen
|
||||
if [[ "${line:0:1}" == "[" ]]; then
|
||||
SECTION=${line:1:-1}
|
||||
fi
|
||||
#Port van Nextion zoeken,
|
||||
#we moeten weten of het modem is of niet
|
||||
if [[ "$SECTION" == "Nextion" && "$line" == "Port=modem" ]]; then
|
||||
NEXTIONPORT_IS_MODEM="1"
|
||||
echo "Info: Serial port for Nextion is modem."
|
||||
echo " We will have to enable Transparent Data!"
|
||||
fi
|
||||
if [[ "$SECTION" == "Nextion" && "$line" == "Port="*"ttyNextionDriver" ]]; then
|
||||
NEXTIONPORT_IS_DRIVER="1"
|
||||
echo "ERROR: The driver already seems to be installed,"
|
||||
echo " so I will not change the configuration."
|
||||
echo " If something is wrong, please correct it by hand."
|
||||
mv "$MMDVMConfig.old" "$MMDVMConfig"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$SECTION" == "Transparent Data" && "$TRANSPARENT" == "" ]]; then
|
||||
TRANSPARENT="1"
|
||||
echo "Info: Transparent Data section found."
|
||||
fi
|
||||
if [[ "$SECTION" == "Transparent Data" && "$TRANSPARENT" == "1" && "$line" == "SendFrameType="* ]]; then
|
||||
TRANSPARENT="2"
|
||||
echo "Info: SendFrameType option found."
|
||||
fi
|
||||
done < "$MMDVMConfig.old"
|
||||
|
||||
|
||||
|
||||
if [[ "$NEXTIONPORT_IS_MODEM" == "1" && "$TRANSPARENT" == "" ]]; then
|
||||
echo "Info: No Transparent Data section."
|
||||
echo " Will be inserted !"
|
||||
TRANSPARENT="3"
|
||||
fi
|
||||
|
||||
|
||||
echo "---> Creating new ini file..."
|
||||
SECTION=""
|
||||
SERIALPORT=""
|
||||
FOUND_NEXTION=""
|
||||
FOUND_MODEM=""
|
||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
#sectie bepalen
|
||||
if [[ "${line:0:1}" == "[" ]]; then
|
||||
SECTION=${line:1:-1}
|
||||
fi
|
||||
|
||||
#[Modem]
|
||||
if [[ "$SECTION" == "Modem" ]]; then
|
||||
FOUND_MODEM="1"
|
||||
fi
|
||||
|
||||
#[Transparent data]
|
||||
if [[ "$NEXTIONPORT_IS_MODEM" == "1" && "$SECTION" == "Transparent Data" ]]; then
|
||||
if [[ "${line:0:7}" == "Enable=" ]]; then
|
||||
TRANSPARENT_ENABLE=${line:7:1}
|
||||
echo "Info: Transparent data enable: $TRANSPARENT_ENABLE"
|
||||
if [[ "$TRANSPARENT_ENABLE" != "1" ]]; then
|
||||
echo " changing to 1"
|
||||
line="Enable=1"
|
||||
else
|
||||
echo " OK !"
|
||||
fi
|
||||
if [[ "$TRANSPARENT" == "1" ]]; then
|
||||
TRANSPARENT="x"
|
||||
echo "Info: Inserting SendFrameType=1"
|
||||
echo "$line" >> "$MMDVMConfig"
|
||||
line="SendFrameType=1"
|
||||
fi
|
||||
fi
|
||||
if [[ "$TRANSPARENT" == "2" && "${line:0:14}" == "SendFrameType=" ]]; then
|
||||
SENDFRAMETYPE=${line:14:1}
|
||||
echo "Info: SendFrameType: $SENDFRAMETYPE"
|
||||
if [[ "$SENDFRAMETYPE" != "1" ]]; then
|
||||
echo " changing to 1"
|
||||
line="SendFrameType=1"
|
||||
else
|
||||
echo " OK !"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#[Nextion]
|
||||
if [[ "$SECTION" == "Nextion" ]]; then
|
||||
FOUND_NEXTION="1"
|
||||
#Port van Nextion gevonden ?
|
||||
# bewaren welke dat is !
|
||||
if [[ "${line:0:5}" == "Port=" ]]; then
|
||||
SERIALPORT="${line:5}"
|
||||
echo "Info: Serial port for Nextion was $SERIALPORT"
|
||||
echo " changing to /dev/ttyNextionDriver"
|
||||
line="Port=/dev/ttyNextionDriver"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
#eerste sectie na [Nextion] gevonden ?
|
||||
# hier zetten we onze gegevens tussen
|
||||
if [[ "$SECTION" != "Nextion" && "$FOUND_NEXTION" == "1" && "${line:0:1}" == "[" ]]; then
|
||||
echo "Info: Inserting [NextionDriver] section"
|
||||
SECTION="[NextionDriver]\nPort=$SERIALPORT\nLogLevel=2\nDataFilesPath=$DATAFILES\nGroupsFile=groups.txt\nDMRidFile=stripped.csv\nremoveDim=0\n\n"
|
||||
echo -e "$SECTION" >> "$MMDVMConfig"
|
||||
echo -e "\n\nInserted section :"
|
||||
echo "------------------------------"
|
||||
echo -e "$SECTION"
|
||||
echo "------------------------------"
|
||||
echo ""
|
||||
FOUND_NEXTION=""
|
||||
if [ "$SERIALPORT" == "" ]; then
|
||||
echo -e "WARNING : no serial port for Nextion found. Check your $MMDVMConfig\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$SECTION" != "Modem" && "$FOUND_MODEM" == "1" && "${line:0:1}" == "[" && "$TRANSPARENT" == "3" ]]; then
|
||||
echo "Info: Inserting [Transparent Data] section"
|
||||
SECTION="[Transparent Data]\nEnable=1\nRemoteAddress=127.0.0.1\nRemotePort=40094\nLocalPort=40095\nSendFrameType=1\n\n"
|
||||
echo -e "$SECTION" >> "$MMDVMConfig"
|
||||
echo -e "\n\nInserted section :"
|
||||
echo "------------------------------"
|
||||
echo -e "$SECTION"
|
||||
echo "------------------------------"
|
||||
echo ""
|
||||
FOUND_MODEM=""
|
||||
fi
|
||||
|
||||
|
||||
echo "$line" >> "$MMDVMConfig"
|
||||
|
||||
done < "$MMDVMConfig.old"
|
||||
|
||||
43
README.md
Normal file
43
README.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
NextionDriverInstaller
|
||||
======================
|
||||
|
||||
This is the installer program for NextionDriver for those who do
|
||||
not want to do it theirselves.
|
||||
|
||||
This is the first release. I have tested it on some hotspots
|
||||
but there are always much more situations and combinations than
|
||||
the ones I tested :-)
|
||||
|
||||
This repository also includes the cofiguration convertor program
|
||||
for automatically converting the MMDVM.ini file to incorporate
|
||||
NextionDriver.
|
||||
You could just run it (NextionDriver_ConvertConfig) if you installed
|
||||
NextionDriver by hand, but it also will be called when you run the
|
||||
installer !
|
||||
|
||||
|
||||
Please let me know if you have any problem.
|
||||
|
||||
|
||||
|
||||
##Installing NextionDriver (on Pi-Star)
|
||||
|
||||
log in to your Pi-Star with SSH
|
||||
|
||||
* use PuTTY
|
||||
* or go to your dashboard -> configuration -> expert -> SSH access (http://pi-star.local/admin/expert/ssh_access.php)
|
||||
|
||||
go to the /tmp directory
|
||||
```
|
||||
cd /tmp
|
||||
```
|
||||
|
||||
get the installer
|
||||
```
|
||||
git clone https://github.com/on7lds/NextionDriverInstaller.git
|
||||
```
|
||||
|
||||
go !
|
||||
```
|
||||
./install.sh
|
||||
```
|
||||
1294
groups.txt
Normal file
1294
groups.txt
Normal file
File diff suppressed because it is too large
Load diff
162
install.sh
Executable file
162
install.sh
Executable file
|
|
@ -0,0 +1,162 @@
|
|||
#!/bin/bash
|
||||
#########################################################
|
||||
# #
|
||||
# NextionDriver installer #
|
||||
# #
|
||||
# (c)2018 by ON7LDS #
|
||||
# #
|
||||
# V1.00 #
|
||||
# #
|
||||
#########################################################
|
||||
|
||||
if [ "$(which gcc)" = "" ]; then echo "- I need gcc. Please install it." exit; fi
|
||||
if [ "$(which git)" = "" ]; then echo "- I need git. Please install it." exit; fi
|
||||
|
||||
echo "+ Getting NextionDriver ..."
|
||||
cd /tmp
|
||||
rm -rf /tmp/NextionDriver
|
||||
git clone https://github.com/on7lds/NextionDriver.git;
|
||||
cd /tmp/NextionDriver
|
||||
if [ "$(pwd)" != "/tmp/NextionDriver" ]; then echo "- Getting NextionDriver failed. Cannot continue."; exit; fi
|
||||
|
||||
|
||||
#########################################################
|
||||
|
||||
THISVERSION=$(cat NextionDriver.h | grep VERSION | sed "s/.*VERSION //" | sed 's/"//g')
|
||||
TV=$(echo $THISVERSION | sed 's/\.//')
|
||||
ND=$(which NextionDriver)
|
||||
PISTAR=$(if [ -f /etc/pistar-release ];then echo "OK"; fi)
|
||||
MMDVM=$(which MMDVMHost)
|
||||
BINDIR=$(echo "$MMDVM" | sed "s/MMDVMHost//")
|
||||
CONFIGFILE="MMDVM.ini"
|
||||
CONFIGDIR="/etc"
|
||||
MMDVMSTART="service mmdvmhost restart"
|
||||
|
||||
#########################################################
|
||||
|
||||
compileer () {
|
||||
echo "+ Compiling ..."
|
||||
make &>> /tmp/compileer.log
|
||||
RESULT=$?
|
||||
if [ "$RESULT" != "0" ]; then
|
||||
echo ""
|
||||
echo "-------------------------------"
|
||||
echo "Compiling NextionDriver failed."
|
||||
echo " (you could check errorlog"
|
||||
echo " /tmp/compileer.log)"
|
||||
echo "Cannot continue ..."
|
||||
echo " S O R R Y"
|
||||
echo "-------------------------------"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
checkversion () {
|
||||
NV=$(NextionDriver -V | grep version | sed 's/^.*version //' | sed 's/\.//')
|
||||
if [ "$NV" != "$TV" ]; then
|
||||
echo ""
|
||||
echo "- It seems we failed."
|
||||
echo "- ($NV != $V)"
|
||||
echo "- Sorry."
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
}
|
||||
helpfiles () {
|
||||
echo "+ Copying groups and users files"
|
||||
cp /tmp/NextionDriverInstaller/groups.txt $CONFIGDIR
|
||||
cp /tmp/NextionDriverInstaller/stripped.csv $CONFIGDIR
|
||||
}
|
||||
herstart () {
|
||||
echo -e "\n+ To test if it all works as expected,"
|
||||
echo -n "+ we will reboot this hotspot, OK (Y,n) ? "
|
||||
x=""
|
||||
while [ "$x" != "n" ]; do
|
||||
read -n 1 x; while read -n 1 -t .1 y; do x="$x$y"; done
|
||||
# echo -n "[$x]"
|
||||
if [ "$x" = "" ]; then reboot; fi
|
||||
if [ "$x" = "y" ]; then reboot; fi
|
||||
if [ "$x" = "Y" ]; then reboot; fi
|
||||
if [ "$x" = "N" ]; then x="n"; fi
|
||||
done
|
||||
echo -e "\n\n+ OK, not rebooting. Trying to start mmdvmhost.\n\n"
|
||||
$MMDVMSTART
|
||||
}
|
||||
|
||||
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then echo "- Please run as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ "$PISTAR" = "OK" ]; then
|
||||
sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot
|
||||
CONFIGFILE="mmdvmhost"
|
||||
CONFIGDIR="/etc/"
|
||||
MMDVMSTART="service mmdvmhost restart"
|
||||
else
|
||||
echo ""
|
||||
echo "- This is not a Pi-Star."
|
||||
echo "- At this moment, I cannot yet automaticly install NextionDriver"
|
||||
echo ""
|
||||
echo "- Sorry."
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ "$MMDVM" = "" ]; then
|
||||
echo ""
|
||||
echo "- No MMDVMHost found,"
|
||||
echo "- so why would you install NextionDriver ?"
|
||||
echo "- Cannot continue"
|
||||
echo ""
|
||||
echo "- Sorry."
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
########## Check for Install ##########
|
||||
if [ "$ND" = "" ]; then
|
||||
echo "+ No NextionDriver found, trying to install one."
|
||||
compileer
|
||||
service mmdvmhost stop
|
||||
killall -q -I MMDVMHost
|
||||
cp NextionDriver $BINDIR
|
||||
echo "+ Check version :"
|
||||
NextionDriver -V
|
||||
checkversion
|
||||
helpfiles
|
||||
echo -e "+ NextionDriver installed\n"
|
||||
echo -e "+ -----------------------------------------------"
|
||||
echo -e "+ We will now start the configuration program ...\n"
|
||||
./NextionDriver_ConvertConfig $CONFIGDIR$CONFIGFILE
|
||||
herstart
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
########## Check for Update ##########
|
||||
VERSIE=$($ND -V | grep version | sed "s/^.*version //")
|
||||
V=$(echo $VERSIE | sed 's/\.//')
|
||||
echo "+ NextionDriver $VERSIE found at $ND"
|
||||
echo "+ We are version $THISVERSION"
|
||||
|
||||
if [ $TV -gt $V ]; then
|
||||
echo "+ Start Update"
|
||||
compileer
|
||||
service mmdvmhost stop
|
||||
killall -q -I MMDVMHost
|
||||
cp NextionDriver $BINDIR
|
||||
echo -e "\n+ Check version"
|
||||
NextionDriver -V
|
||||
checkversion
|
||||
helpfiles
|
||||
echo -e "\n+ NextionDriver updated\n"
|
||||
herstart
|
||||
else
|
||||
echo -e "\n- No need to update.\n"
|
||||
exit
|
||||
fi
|
||||
119
mmdvmhost.service.pistar
Executable file
119
mmdvmhost.service.pistar
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
#!/bin/bash
|
||||
#########################################################
|
||||
# #
|
||||
# MMDVMHost Service Handler #
|
||||
# #
|
||||
# Written for Pi-Star (http://www.mw0mwz.co.uk/pi-star) #
|
||||
# By Andy Taylor (MW0MWZ) #
|
||||
# #
|
||||
# Version 1.1 #
|
||||
# #
|
||||
# Adapted by ON7LDS to start NextionDriver before #
|
||||
# mmdvmhost (and stop it after mmdvmhost has stopped) #
|
||||
# #
|
||||
#########################################################
|
||||
|
||||
# Service Config
|
||||
DAEMON=MMDVMHost
|
||||
DAEMON_HELPER=NextionDriver
|
||||
DAEMON_PATH=/usr/local/bin/
|
||||
CONFIG=/etc/mmdvmhost
|
||||
DAEMON_OPTS=$CONFIG
|
||||
DAEMON_HELPER_OPTS="-c /etc/mmdvmhost"
|
||||
PGREP=/usr/bin/pgrep
|
||||
KILL=/bin/kill
|
||||
SLEEP=/bin/sleep
|
||||
USER=root
|
||||
GROUP=root
|
||||
LOGDIR=/var/log/pi-star
|
||||
ipVar=`hostname -I | cut -d' ' -f1`
|
||||
|
||||
# Pre-flight checks...
|
||||
test -x ${DAEMON_PATH}${DAEMON} || exit 1
|
||||
test -x ${DAEMON_PATH}${DAEMON_HELPER} || exit 1
|
||||
test -r $CONFIG || exit 1
|
||||
|
||||
# if dstarrepeater is configured or running, dont start this daemon!
|
||||
! test -r /etc/dstar-radio.dstarrepeater || exit 1
|
||||
test -r /etc/dstar-radio.mmdvmhost || exit 1
|
||||
|
||||
# check if dstarrepeaterd is running, dont start MMDVMHost if it is.
|
||||
if [ `$PGREP "dstarrepeaterd"` ]; then
|
||||
echo "Service 'dstarrepeaterd' is already running, cannot start $DAEMON"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Verify the logging directory exists, if not create it and setup the ownership / permissions
|
||||
if [ ! -d $LOGDIR ]; then
|
||||
mkdir -p $LOGDIR
|
||||
chown ${USER}:${GROUP} $LOGDIR
|
||||
chmod 775 $LOGDIR
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ `${PGREP} ${DAEMON}` ]; then
|
||||
echo -e "$DAEMON is already running as PID "`$PGREP $DAEMON`
|
||||
exit 1;
|
||||
else
|
||||
# Wait for an IP address
|
||||
until [ $ipVar != " " ]; do
|
||||
sleep 10
|
||||
ipVar=`hostname -I`
|
||||
done
|
||||
|
||||
nice -n -10 ${DAEMON_PATH}${DAEMON_HELPER} ${DAEMON_HELPER_OPTS}
|
||||
nextiondriver=`$PGREP $DAEMON_HELPER`
|
||||
sleep 1
|
||||
if [ "$nextiondriver" == "" ]; then
|
||||
echo -e "$DAEMON_HELPER failed to start. So I cannot start mmdvmhost ..."
|
||||
exit 1;
|
||||
fi
|
||||
echo -e "$DAEMON_HELPER started as PID "`$PGREP $DAEMON_HELPER`
|
||||
|
||||
nice -n -10 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
|
||||
echo -e "$DAEMON started as PID "`$PGREP $DAEMON`
|
||||
exit 0;
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
if [ `${PGREP} ${DAEMON}` ]; then
|
||||
echo -e "Killing $DAEMON PID "`$PGREP $DAEMON`
|
||||
$KILL `${PGREP} ${DAEMON}`
|
||||
else
|
||||
echo -e "$DAEMON is not running"
|
||||
fi
|
||||
if [ `${PGREP} ${DAEMON_HELPER}` ]; then
|
||||
echo -e "Killing $DAEMON_HELPER PID "`$PGREP $DAEMON_HELPER`
|
||||
$KILL `${PGREP} ${DAEMON_HELPER}`
|
||||
exit 0;
|
||||
else
|
||||
echo -e "$DAEMON_HELPER is not running"
|
||||
exit 1;
|
||||
fi
|
||||
;;
|
||||
|
||||
restart)
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
;;
|
||||
|
||||
status)
|
||||
if [ `${PGREP} ${DAEMON_HELPER}` ]; then
|
||||
echo -e "$DAEMON_HELPER is running as PID "`${PGREP} ${DAEMON_HELPER}`
|
||||
else
|
||||
echo -e "$DAEMON_HELPER is not running"
|
||||
fi
|
||||
if [ `${PGREP} ${DAEMON}` ]; then
|
||||
echo -e "$DAEMON is running as PID "`${PGREP} ${DAEMON}`
|
||||
else
|
||||
echo -e "$DAEMON is not running"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
esac
|
||||
109365
stripped.csv
Normal file
109365
stripped.csv
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue