Cleaned script up

This commit is contained in:
Ben Fogt 2018-12-21 01:07:33 -06:00
parent 834315d6df
commit 0486f4fa17

View file

@ -12,23 +12,19 @@
# Stay tuned... # Stay tuned...
#Lets begin------------------------------------------------------------------------------------------------- #Lets begin-------------------------------------------------------------------------------------------------
#Sanity checks
WHO=$(whoami) WHO=$(whoami)
#Have to be ROOT to run this script
if [ "$WHO" != "root" ] if [ "$WHO" != "root" ]
then then
echo "" echo ""
echo "You Must be root to run this script!!" echo "You Must be root to run this script!!"
exit 0 exit 0
fi fi
#Has to be a Debian variant.
if [ ! -e "/etc/debian_version" ] if [ ! -e "/etc/debian_version" ]
then then
echo "" echo ""
echo "This script is only tested in Debian 9 and x64 cpu Arch. " echo "This script is only tested in Debian 9 and x64 cpu Arch. "
exit 0 exit 0
fi fi
#Gather variables.
DIRDIR=$(pwd) DIRDIR=$(pwd)
XLXDREPO=https://github.com/LX3JL/xlxd.git XLXDREPO=https://github.com/LX3JL/xlxd.git
YSF2DMRREPO=https://github.com/juribeparada/MMDVM_CM.git YSF2DMRREPO=https://github.com/juribeparada/MMDVM_CM.git
@ -43,7 +39,6 @@ YSFDASDIR=/root/reflector-install-files/ysfdash
XLXWEBDIR=/var/www/xlxd XLXWEBDIR=/var/www/xlxd
YSFWEBDIR=/var/www/ysf YSFWEBDIR=/var/www/ysf
DEP="git build-essential apache2 php libapache2-mod-php php7.0-mbstring screen wget" DEP="git build-essential apache2 php libapache2-mod-php php7.0-mbstring screen wget"
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
echo "" echo ""
echo "XLX uses 3 digits numbers for its reflectors. For example: 032, 723, 099" 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 "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
#Gather dependicies #Gather dependicies
echo "" echo ""
echo "Installing dependicies..........."
echo "" 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 update
apt -y install $DEP apt -y install $DEP
a2enmod php7.0 a2enmod php7.0
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
#Create the install directory and app directories #Create the install directory and app directories
echo "Making directories...."
mkdir -p $XLXINTDIR mkdir -p $XLXINTDIR
mkdir -p $YSFINTDIR mkdir -p $YSFINTDIR
mkdir -p $YSF2INTDIR mkdir -p $YSF2INTDIR
@ -90,16 +85,17 @@ mkdir -p $XLXWEBDIR
mkdir -p $YSFWEBDIR mkdir -p $YSFWEBDIR
mkdir -p /ysfreflector mkdir -p /ysfreflector
mkdir -p /ysf2dmr mkdir -p /ysf2dmr
echo "------------------------------------------------------------------------------"
#Install xlxd #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 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 ] if [ -e $XLXINTDIR/xlxd/src/xlxd ]
then then
echo "" 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 exit 0
else else
echo "Downloading and compiling xlxd... " echo "Downloading and compiling xlxd... "
echo "------------------------------------------------------------------------------"
cd $XLXINTDIR cd $XLXINTDIR
git clone $XLXDREPO git clone $XLXDREPO
cd $XLXINTDIR/xlxd/src cd $XLXINTDIR/xlxd/src
@ -110,8 +106,9 @@ fi
#Now the file should be there, if it compiled correctly. #Now the file should be there, if it compiled correctly.
if [ -e $XLXINTDIR/xlxd/src/xlxd ] if [ -e $XLXINTDIR/xlxd/src/xlxd ]
then then
echo "------------------------------------------------------------------------------" echo "--------------------------------------"
echo "It looks like everything compiled successfully. There is a 'xlxd' application file. " echo "It looks like XLXD compiled successfully!! "
echo "--------------------------------------"
else else
echo "" 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. " 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/ rm -rf /root/reflector-install-files/
exit 0 exit 0
fi fi
#get DMR files echo "------------------------------------------------------------------------------"
echo "Getting DMRID.dat file... "
echo "------------------------------------------------------------------------------"
wget -O /xlxd/dmrid.dat $XLXDMRIDURL wget -O /xlxd/dmrid.dat $XLXDMRIDURL
#Copy files over
cd $XLXINTDIR/ cd $XLXINTDIR/
cp -R $XLXINTDIR/xlxd/dashboard/* $XLXWEBDIR/ cp -R $XLXINTDIR/xlxd/dashboard/* $XLXWEBDIR/
cp $XLXINTDIR/xlxd/scripts/xlxd /etc/init.d/xlxd 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 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 update-rc.d xlxd defaults
echo "XLXD is finished installing and ready to be configured. Moving onto YSF....." echo "--------------------------------------"
#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 "XLXD is finished installing."
echo "--------------------------------------"
if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ] if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ]
then then
echo "" echo ""
@ -138,16 +136,17 @@ then
else else
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
echo "Downloading and compiling YSFReflector... " echo "Downloading and compiling YSFReflector... "
echo "------------------------------------------------------------------------------"
cd $YSFINTDIR cd $YSFINTDIR
git clone https://github.com/g4klx/YSFClients.git git clone https://github.com/g4klx/YSFClients.git
cd $YSFINTDIR/YSFClients/YSFReflector cd $YSFINTDIR/YSFClients/YSFReflector
make clean all make clean all
fi fi
#Now the file should be there, if it compiled correctly.
if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ] if [ -e $YSFINTDIR/YSFClients/YSFReflector/YSFReflector ]
then then
echo "------------------------------------------------------------------------------" echo "--------------------------------------"
echo "It looks like everything compiled successfully. There is a 'YSFReflector' application file. " echo "It looks like YSFReflector compiled successfully. "
echo "--------------------------------------"
else else
echo "" 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... " 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 rm -rf /root/reflector-install-files
exit 0 exit 0
fi fi
echo "------------------------------------------------------------------------------"
#Copying over files. #Copying over files.
echo ""
echo "Copying files over to the executable directory.... "
cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector /ysfreflector cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector /ysfreflector
cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector.ini /ysfreflector cp $YSFINTDIR/YSFClients/YSFReflector/YSFReflector.ini /ysfreflector
#Updating the ini file #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/16[ ]*characters[ ]*max/$YSFNAME/g" /ysfreflector/YSFReflector.ini
sed -i "s/14[ ]*characters[ ]*max/$YSFDESC/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 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. #Creating mmdvm user that is apparently required for this to run.
groupadd mmdvm groupadd mmdvm
useradd mmdvm -g mmdvm -s /sbin/nologin useradd mmdvm -g mmdvm -s /sbin/nologin
mkdir -p /var/log/YSFReflector mkdir -p /var/log/YSFReflector
chown mmdvm: /var/log/YSFReflector chown mmdvm: /var/log/YSFReflector
echo "------------------------------------------------------------------------------" cp $DIRDIR/templates/ysfreflector.service /etc/systemd/system
echo "Installing YSF2DMR... " systemctl daemon-reload
echo ""
echo "--------------------------------------"
echo "YSFReflector is finished installing."
echo "--------------------------------------"
echo ""
if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ] if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ]
then then
echo "" 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. " 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 else
echo "" echo "------------------------------------------------------------------------------"
echo "Downloading and compiling YSFReflector... " echo "Installing YSF2DMR... "
echo "------------------------------------------------------------------------------"
cd $YSF2INTDIR cd $YSF2INTDIR
git clone $YSF2DMRREPO git clone $YSF2DMRREPO
cd $YSF2INTDIR/MMDVM_CM/YSF2DMR/ cd $YSF2INTDIR/MMDVM_CM/YSF2DMR/
@ -195,8 +190,9 @@ fi
#Now the file should be there, if it compiled correctly. #Now the file should be there, if it compiled correctly.
if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ] if [ -e $YSF2INTDIR/MMDVM_CM/YSF2DMR/YSF2DMR ]
then then
echo "------------------------------------------------------------------------------" echo "--------------------------------------"
echo "It looks like everything compiled successfully. There is a 'YSF2DMR' application file. " echo "It looks like YSF2DMR compiled successfully. "
echo "--------------------------------------"
else else
echo "" 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. " 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 YSF2DMR.ini /ysf2dmr/
cp DMRIds.dat /ysf2dmr/ cp DMRIds.dat /ysf2dmr/
cp XLXHosts.txt /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 "------------------------------------------------------------------------------"
echo "Installing the YSF Dashboard... "
cd $YSFDASDIR cd $YSFDASDIR
git clone $YSFDASHREPO git clone $YSFDASHREPO
cp -R $YSFDASDIR/YSFReflector-Dashboard/* $YSFWEBDIR/ cp -R $YSFDASDIR/YSFReflector-Dashboard/* $YSFWEBDIR/
mkdir $YSFWEBDIR/config mkdir $YSFWEBDIR/config
cp $DIRDIR/templates/config.php $YSFWEBDIR/config/ cp $DIRDIR/templates/config.php $YSFWEBDIR/config/
mv $YSFWEBDIR/setup.php $YSFDASDIR/original-setup.php mv $YSFWEBDIR/setup.php $YSFDASDIR/original-setup.php
echo "------------------------------------------------------------------------------"
#Copy apache vhost directives #Copy apache vhost directives
echo "Copying apache directives....."
cp $DIRDIR/templates/apache.tbd.conf /etc/apache2/sites-available/$XLXDOMAIN.conf 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/apache.tbd/$XLXDOMAIN/g" /etc/apache2/sites-available/$XLXDOMAIN.conf
sed -i "s/ysf-xlxd/xlxd/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 #Copy apache vhost files over for ysf
echo "Updating apache directives....."
cp $DIRDIR/templates/apache.tbd.conf /etc/apache2/sites-available/$YSFDOMAIN.conf 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/apache.tbd/$YSFDOMAIN/g" /etc/apache2/sites-available/$YSFDOMAIN.conf
sed -i "s/ysf-xlxd/ysf/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 "Enabling $XLXDOMAIN and $YSFDOMAIN... "
echo "--------------------------------------"
#Enable the sites #Enable the sites
a2ensite $XLXDOMAIN a2ensite $XLXDOMAIN
a2ensite $YSFDOMAIN a2ensite $YSFDOMAIN
echo "--------------------------------------"
echo "Reloading apace2."
echo "--------------------------------------"
service apache2 restart service apache2 restart
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
#Copy ysfservice echo "Starting xlxd and YSFReflector... "
echo "Copying ysfrelfector to systemd... " echo "------------------------------------------------------------------------------"
cp $DIRDIR/templates/ysfreflector.service /etc/systemd/system
systemctl daemon-reload
service xlxd start service xlxd start
service ysfreflector 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 ""