From 0486f4fa177de15a01b950ff33aa89595f6bf6eb Mon Sep 17 00:00:00 2001 From: Ben Fogt Date: Fri, 21 Dec 2018 01:07:33 -0600 Subject: [PATCH] Cleaned script up --- Multi-Reflector-Installer.sh | 112 +++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/Multi-Reflector-Installer.sh b/Multi-Reflector-Installer.sh index f3047ac..6879939 100755 --- a/Multi-Reflector-Installer.sh +++ b/Multi-Reflector-Installer.sh @@ -12,23 +12,19 @@ # Stay tuned... #Lets begin------------------------------------------------------------------------------------------------- -#Sanity checks WHO=$(whoami) -#Have to be ROOT to run this script if [ "$WHO" != "root" ] then echo "" echo "You Must be root to run this script!!" exit 0 fi -#Has to be a Debian variant. if [ ! -e "/etc/debian_version" ] then echo "" echo "This script is only tested in Debian 9 and x64 cpu Arch. " exit 0 fi -#Gather variables. DIRDIR=$(pwd) XLXDREPO=https://github.com/LX3JL/xlxd.git YSF2DMRREPO=https://github.com/juribeparada/MMDVM_CM.git @@ -43,7 +39,6 @@ YSFDASDIR=/root/reflector-install-files/ysfdash XLXWEBDIR=/var/www/xlxd YSFWEBDIR=/var/www/ysf DEP="git build-essential apache2 php libapache2-mod-php php7.0-mbstring screen wget" - echo "------------------------------------------------------------------------------" echo "" echo "XLX uses 3 digits numbers for its reflectors. For example: 032, 723, 099" @@ -73,15 +68,15 @@ read -p "What is the FQDN of the YSF Reflector dashboard? Example: ysf.domain.co echo "------------------------------------------------------------------------------" #Gather dependicies echo "" -echo "Installing dependicies..........." echo "" -#echo "deb http://ftp.debian.org/debian stretch-backports main" >> /etc/apt/sources.list #Required when SSL gets added, not yet though. +echo "------------------------------------------------------------------------------" +echo "Installing dependicies..........." +echo "------------------------------------------------------------------------------" apt update apt -y install $DEP a2enmod php7.0 echo "------------------------------------------------------------------------------" #Create the install directory and app directories -echo "Making directories...." mkdir -p $XLXINTDIR mkdir -p $YSFINTDIR mkdir -p $YSF2INTDIR @@ -90,16 +85,17 @@ mkdir -p $XLXWEBDIR mkdir -p $YSFWEBDIR mkdir -p /ysfreflector mkdir -p /ysf2dmr -echo "------------------------------------------------------------------------------" + #Install xlxd #If the file is here already, then we dont need to compile on top of it. Remove the git clone directory and start over. if [ -e $XLXINTDIR/xlxd/src/xlxd ] then echo "" - echo "It looks like you have already compiled XLX. If you want to install it again, delete the directory '/root/reflector-install-files' and run this script again. " + echo "It looks like you have already compiled XLX. If you want to install it again, delete the directory '/root/reflector-install-files/' and run this script again. " exit 0 else echo "Downloading and compiling xlxd... " + echo "------------------------------------------------------------------------------" cd $XLXINTDIR git clone $XLXDREPO cd $XLXINTDIR/xlxd/src @@ -110,8 +106,9 @@ fi #Now the file should be there, if it compiled correctly. if [ -e $XLXINTDIR/xlxd/src/xlxd ] then - echo "------------------------------------------------------------------------------" - echo "It looks like everything compiled successfully. There is a 'xlxd' application file. " + echo "--------------------------------------" + echo "It looks like XLXD compiled successfully!! " + echo "--------------------------------------" else echo "" echo "UH OH!! I dont see the xlxd application file after attempting to compile. The output above is the only indication as to why it might have failed. Removing install files and directories. " @@ -119,17 +116,18 @@ else rm -rf /root/reflector-install-files/ exit 0 fi -#get DMR files +echo "------------------------------------------------------------------------------" +echo "Getting DMRID.dat file... " +echo "------------------------------------------------------------------------------" wget -O /xlxd/dmrid.dat $XLXDMRIDURL -#Copy files over cd $XLXINTDIR/ cp -R $XLXINTDIR/xlxd/dashboard/* $XLXWEBDIR/ cp $XLXINTDIR/xlxd/scripts/xlxd /etc/init.d/xlxd -#Update up the startup script sed -i "s/ARGUMENTS=\"XLX270 158.64.26.132\"/ARGUMENTS=\"$XFRNUM $LOCAL_IP 127.0.0.1\"/g" /etc/init.d/xlxd update-rc.d xlxd defaults -echo "XLXD is finished installing and ready to be configured. Moving onto YSF....." -#If the file is here already, then we dont need to compile on top of it. Remove the git clone directory and start over. +echo "--------------------------------------" +echo "XLXD is finished installing." +echo "--------------------------------------" if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ] then echo "" @@ -138,16 +136,17 @@ then else echo "------------------------------------------------------------------------------" echo "Downloading and compiling YSFReflector... " + echo "------------------------------------------------------------------------------" cd $YSFINTDIR git clone https://github.com/g4klx/YSFClients.git cd $YSFINTDIR/YSFClients/YSFReflector make clean all fi -#Now the file should be there, if it compiled correctly. if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ] then - echo "------------------------------------------------------------------------------" - echo "It looks like everything compiled successfully. There is a 'YSFReflector' application file. " + echo "--------------------------------------" + echo "It looks like YSFReflector compiled successfully. " + echo "--------------------------------------" else echo "" echo "UH OH!! I dont see the YSFReflector application file after attempting to compile. The output above is the only indication as to why it might have failed. Removing install files... " @@ -155,38 +154,34 @@ else rm -rf /root/reflector-install-files exit 0 fi -echo "------------------------------------------------------------------------------" #Copying over files. -echo "" -echo "Copying files over to the executable directory.... " cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector /ysfreflector cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector.ini /ysfreflector - - #Updating the ini file -echo "------------------------------------------------------------------------------" -echo "" -echo "Updating ini file in /YSFReflector. " sed -i "s/16[ ]*characters[ ]*max/$YSFNAME/g" /ysfreflector/YSFReflector.ini sed -i "s/14[ ]*characters[ ]*max/$YSFDESC/g" /ysfreflector/YSFReflector.ini sed -i "s/FilePath=./FilePath=\/var\/log\/YSFReflector\//g" /ysfreflector/YSFReflector.ini -echo "------------------------------------------------------------------------------" -echo "Creating mmdvm user and setting properties... " #Creating mmdvm user that is apparently required for this to run. groupadd mmdvm useradd mmdvm -g mmdvm -s /sbin/nologin mkdir -p /var/log/YSFReflector chown mmdvm: /var/log/YSFReflector -echo "------------------------------------------------------------------------------" -echo "Installing YSF2DMR... " +cp $DIRDIR/templates/ysfreflector.service /etc/systemd/system +systemctl daemon-reload +echo "" +echo "--------------------------------------" +echo "YSFReflector is finished installing." +echo "--------------------------------------" +echo "" if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ] then echo "" echo "It looks like you have already compiled YSFReflector. If you want to install it again, delete the directory '/root/reflector-install-files' and run this script again. " - exit 0 + #exit 0 else - echo "" - echo "Downloading and compiling YSFReflector... " + echo "------------------------------------------------------------------------------" + echo "Installing YSF2DMR... " + echo "------------------------------------------------------------------------------" cd $YSF2INTDIR git clone $YSF2DMRREPO cd $YSF2INTDIR/MMDVM_CM/YSF2DMR/ @@ -195,8 +190,9 @@ fi #Now the file should be there, if it compiled correctly. if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ] then - echo "------------------------------------------------------------------------------" - echo "It looks like everything compiled successfully. There is a 'YSF2DMR' application file. " + echo "--------------------------------------" + echo "It looks like YSF2DMR compiled successfully. " + echo "--------------------------------------" else echo "" echo "UH OH!! I dont see the YSF2DMR application file after attempting to compile. The output above is the only indication as to why it might have failed. Removing install files and directories. " @@ -208,40 +204,56 @@ cp YSF2DMR /ysf2dmr/ cp YSF2DMR.ini /ysf2dmr/ cp DMRIds.dat /ysf2dmr/ cp XLXHosts.txt /ysf2dmr/ - +echo "" +echo "--------------------------------------" +echo "YSF2DMR is finished installing." +echo "--------------------------------------" +echo "" +echo "------------------------------------------------------------------------------" +echo "Installing the YSF Dashboard and configuring apache... " echo "------------------------------------------------------------------------------" -echo "Installing the YSF Dashboard... " cd $YSFDASDIR git clone $YSFDASHREPO cp -R $YSFDASDIR/YSFReflector-Dashboard/* $YSFWEBDIR/ mkdir $YSFWEBDIR/config cp $DIRDIR/templates/config.php $YSFWEBDIR/config/ mv $YSFWEBDIR/setup.php $YSFDASDIR/original-setup.php - -echo "------------------------------------------------------------------------------" #Copy apache vhost directives -echo "Copying apache directives....." cp $DIRDIR/templates/apache.tbd.conf /etc/apache2/sites-available/$XLXDOMAIN.conf sed -i "s/apache.tbd/$XLXDOMAIN/g" /etc/apache2/sites-available/$XLXDOMAIN.conf sed -i "s/ysf-xlxd/xlxd/g" /etc/apache2/sites-available/$XLXDOMAIN.conf -echo "------------------------------------------------------------------------------" #Copy apache vhost files over for ysf -echo "Updating apache directives....." cp $DIRDIR/templates/apache.tbd.conf /etc/apache2/sites-available/$YSFDOMAIN.conf sed -i "s/apache.tbd/$YSFDOMAIN/g" /etc/apache2/sites-available/$YSFDOMAIN.conf sed -i "s/ysf-xlxd/ysf/g" /etc/apache2/sites-available/$YSFDOMAIN.conf -echo "------------------------------------------------------------------------------" +echo "--------------------------------------" echo "Enabling $XLXDOMAIN and $YSFDOMAIN... " +echo "--------------------------------------" #Enable the sites a2ensite $XLXDOMAIN a2ensite $YSFDOMAIN +echo "--------------------------------------" +echo "Reloading apace2." +echo "--------------------------------------" service apache2 restart - echo "------------------------------------------------------------------------------" -#Copy ysfservice -echo "Copying ysfrelfector to systemd... " -cp $DIRDIR/templates/ysfreflector.service /etc/systemd/system -systemctl daemon-reload +echo "Starting xlxd and YSFReflector... " +echo "------------------------------------------------------------------------------" service xlxd start service ysfreflector start +echo "" +echo "" +echo "***********************************************************************************" +echo "" +echo " Your 3-in-1 Reflector is finished installing. " +echo " At this time, you have a D-Star and YSF Server installed and running!! " +echo " There is still more configuration to be done..." +echo " Please visit https://github.com/n5amd/Multi-Reflector-Installer For more info.. " +echo "" +echo " Your 2 web dashboards can be found at: " +echo " http://$XLXDOMAIN " +echo " http://$YSFDOMAIN " +echo "" +echo "***********************************************************************************" +echo ""