Installer 1.02 updated for better integration with Pi-Star

This commit is contained in:
root 2019-02-03 15:20:00 +01:00
parent f94ea799e3
commit 9bd47fa8b2
10 changed files with 121436 additions and 109053 deletions

View file

@ -8,6 +8,14 @@ NextionDriver when you do not want to do it by hand:
using NextionDriver (this is called by the installer program)
* a program to check the installation
This is installer version 1.02 ( 03 feb 2019 )
-----
__Please use this installer to update your system if your installation is
older than this date. Even if the NextionDriver was recently updated__
-----
### install.sh

View file

@ -3,9 +3,9 @@
# #
# NextionDriver installer #
# #
# (c)2018 by ON7LDS #
# (c)2018-2019 by ON7LDS #
# #
# V1.01 #
# V1.02 #
# #
#########################################################
@ -39,7 +39,8 @@ CONFIGDIR="/etc/"
SYSTEMCTL="systemctl daemon-reload"
MMDVMSTOP="service mmdvmhost stop"
MMDVMSTART="service mmdvmhost start"
NDSTOP="service nextion-helper stop"
NDOUDSTOP="service nextion-helper stop 2>/dev/null"
NDSTOP="service nextiondriver"
#######################################################################################
@ -140,30 +141,48 @@ if [ "$MMDVM" = "" ]; then
fi
########## Check for older installation ##########
if [ $(cat /usr/local/sbin/mmdvmhost.service | grep extion | wc -l) -gt 0 ]; then
echo -e "I older installation found, removing ..."
ND=""
fi
########## Check for Install ##########
if [ "$ND" = "" ]; then
echo "+ No NextionDriver found, trying to install one."
compileer
$SYSTEMCTL
$NDOUDSTOP 2>/dev/null
$NDSTOP
$MMDVMSTOP
killall -q -I MMDVMHost
killall -9 -q -I MMDVMHost
systemctl disable mmdvmhost
systemctl disable nextion-helper 2>/dev/null
systemctl disable nextiondriver
if [ "$CHECK" = "PISTAR" ]; then
cp $DIR"/mmdvmhost.service.pistar" /usr/local/sbin/mmdvmhost.service
echo "+ found PISTAR"
cp $DIR"/nextiondriver.service.binary.pistar" /usr/local/sbin/nextiondriver.service
if [ $(cat /usr/local/sbin/mmdvmhost.service | grep extion | wc -l) -gt 0 ]; then
echo "+ Restoring mmdvmhost.service binary"
rm /usr/local/sbin/mmdvmhost.service
git --work-tree=/usr/local/sbin/ --git-dir=/usr/local/sbin/.git checkout mmdvmhost.service
fi
echo "+ Installing services"
cp $DIR"/mmdvmhost.service.pistar" /lib/systemd/system/mmdvmhost.service
cp $DIR"/nextiondriver.service.pistar" /lib/systemd/system/nextiondriver.service
fi
if [ "$CHECK" = "JESSIE" ]; then
cp $DIR"/mmdvmhost.service.jessie" /lib/systemd/system/mmdvmhost.service
cp $DIR"/mmdvmhost.timer.jessie" /lib/systemd/system/mmdvmhost.timer
cp $DIR"/nextion-helper.service.jessie" /lib/systemd/system/nextion-helper.service
if [ -e /etc/systemd/system/nextion-helper.service ]; then
echo "+ there is already a link /etc/systemd/system/nextion-helper.service"
echo "+ I'll leave it like that."
else
ln -s /lib/systemd/system/nextion-helper.service /etc/systemd/system/nextion-helper.service
fi
rm -f /lib/systemd/system/nextion-helper.service
cp $DIR"/nextiondriver.service.jessie" /lib/systemd/system/nextiondriver.service
fi
cp NextionDriver $BINDIR
systemctl enable mmdvmhost
systemctl enable nextiondriver
echo "+ Check version :"
NextionDriver -V
checkversion

View file

@ -1,7 +1,7 @@
[Unit]
Description=MMDVM Host Service
Description=MMDVMHost Radio Service
After=syslog.target network.target
BindsTo=nextion-helper.service
BindsTo=nextiondriver.service
[Service]
User=root

View file

@ -1,119 +1,13 @@
#!/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) #
# #
#########################################################
[Unit]
Description=MMDVMHost Radio Service
After=syslog.target network.target
Requires=nextiondriver.service
# 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`
[Service]
Type=forking
ExecStart=/usr/local/sbin/mmdvmhost.service start
ExecStop=/usr/local/sbin/mmdvmhost.service stop
ExecReload=/usr/local/sbin/mmdvmhost.service restart
# 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
[Install]
WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Timer]
OnStartupSec=60
OnStartupSec=30
[Install]
WantedBy=multi-user.target

View file

@ -1,15 +0,0 @@
[Unit]
Description=Nextion Helper Service Service
After=syslog.target network.target
Before= mmdvmhost.service
[Service]
User=root
WorkingDirectory=/opt/MMDVMHost
Type=forking
ExecStart=/opt/MMDVMHost/NextionDriver -c /opt/MMDVM.ini -vvvv
ExecStop=/usr/bin/killall NextionDriver
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,92 @@
#!/bin/bash
#########################################################
# #
# NextionDriver Service Handler #
# #
# Written for Pi-Star (http://www.mw0mwz.co.uk/pi-star) #
# #
# By Lieven De Samblanx (ON7LDS) #
# #
# based on work of Andy Taylor (MW0MWZ) #
# #
# Version 1.0 #
# #
#########################################################
# Service Config
DAEMON=NextionDriver
DAEMON_PATH=/usr/local/bin/
CONFIG=/etc/mmdvmhost
DAEMON_OPTS="-c $CONFIG -i"
PGREP=/usr/bin/pgrep
KILL=/bin/kill
SLEEP=/bin/sleep
USER=root
GROUP=mmdvm
LOGDIR=/var/log/pi-star
# Pre-flight checks...
test -x ${DAEMON_PATH}${DAEMON} || exit 1
test -r $CONFIG || exit 1
#We start very early in the bootprocess, so we
# 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
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}`
if [ `${PGREP} ${DAEMON}` ]; then killall ${DAEMON}; fi
exit 0;
else
echo -e "$DAEMON is not running"
exit 1;
fi
;;
restart)
if [ `$PGREP $DAEMON` ]; then
echo -e "Killing $DAEMON PID "`$PGREP $DAEMON`
$KILL `${PGREP} ${DAEMON}`
$SLEEP 3
nice -n -10 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
echo -e "$DAEMON re-started as PID "`${PGREP} ${DAEMON}`
exit 0;
else
echo -e "$DAEMON is not running"
nice -n -10 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
echo -e "$DAEMON started as PID "`${PGREP} ${DAEMON}`
exit 0;
fi
;;
status)
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

View file

@ -0,0 +1,17 @@
[Unit]
Description=NextionDriver service
DefaultDependencies=no
After=local-fs.target syslog.target network.target
Before=timers.target
[Service]
User=root
Type=forking
WorkingDirectory=/usr/local/etc/
ExecStart=/opt/MMDVMHost/NextionDriver -c /opt/MMDVM.ini -vvvv
ExecStop=/usr/bin/killall NextionDriver
[Install]
WantedBy=multi-user.target
WantedBy=network-online.target
RequiredBy=mmdvmhost.service

View file

@ -0,0 +1,18 @@
[Unit]
Description=NextionDriver service
DefaultDependencies=no
After=local-fs.target wifi-country.service
Before=timers.target
[Service]
User=root
Type=forking
WorkingDirectory=/usr/local/etc/
ExecStart=/usr/local/bin/NextionDriver -c /etc/mmdvmhost -i
ExecStop=/usr/bin/killall NextionDriver
[Install]
WantedBy=multi-user.target
WantedBy=network-online.target
RequiredBy=mmdvmhost.service

230164
stripped.csv

File diff suppressed because it is too large Load diff