cleaned script up to be more readable

This commit is contained in:
Ben Fogt 2018-12-13 20:12:26 -06:00
parent 675e2091a0
commit a94b90d518
1 changed files with 53 additions and 50 deletions

View File

@ -1,31 +1,28 @@
#!/bin/bash #!/bin/bash
# A tool to install xlxd, your own D-Star Reflector. # A tool to install xlxd, your own D-Star Reflector.
# For more information, please visit: https://sadigitalradio.com # For more information, please visit: https://sadigitalradio.com
#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.
XLXDREPO=https://github.com/LX3JL/xlxd.git
DIRDIR=$(pwd) DIRDIR=$(pwd)
LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}')
SADREF=https://sadigitalradio.com/digital-radio-how-tos/create-xlx-xrf-d-star-reflector/ SADREF=https://sadigitalradio.com/digital-radio-how-tos/create-xlx-xrf-d-star-reflector/
XLXDREPO=https://github.com/LX3JL/xlxd.git
DMRIDURL=http://xlxapi.rlx.lu/api/exportdmr.php
WEBDIR=/var/www/xlxd
XLXINSTDIR=/root/reflector-install-files/xlxd
DEP="git build-essential apache2 php libapache2-mod-php php7.0-mbstring"
clear clear
echo "" echo ""
echo "XLX uses 3 digit numbers for its reflectors. For example: 032, 999, 099." echo "XLX uses 3 digit numbers for its reflectors. For example: 032, 999, 099."
@ -40,37 +37,36 @@ read -p "What E-Mail address can your users send questions to? " EMAIL
echo "" echo ""
echo "--------------------------------------" echo "--------------------------------------"
read -p "What is the admins callsign? " CALLSIGN read -p "What is the admins callsign? " CALLSIGN
echo ""
echo ""
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
echo "Making install directories and installing dependicies...." echo "Making install directories and installing dependicies...."
mkdir -p /root/reflector-install-files
mkdir -p /root/reflector-install-files/xlxd
mkdir -p /var/www/xlxd
#Install dependicies
apt-get update
apt-get -y install git build-essential apache2 php libapache2-mod-php php7.0-mbstring
a2enmod php7.0
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
#Install xlxd mkdir -p $XLXINSTDIR
#If the file is here already, then we dont need to compile on top of it. Remove the git clone directory and start over. mkdir -p $WEBDIR
if [ -e /root/reflector-install-files/xlxd/xlxd/src/xlxd ] apt-get update
apt-get -y install $DEP
a2enmod php7.0
echo "------------------------------------------------------------------------------"
if [ -e $XLXINSTDIR/xlxd/src/xlxd ]
then then
echo "" echo ""
echo "It looks like you have already compiled XLXD. If you want to install/complile xlxd again, delete the directory '/root/reflector-install-files/xlxd' and run this script again. " echo "It looks like you have already compiled XLXD. If you want to install/complile xlxd again, delete the directory '/root/reflector-install-files/xlxd' and run this script again. "
exit 0
else else
echo "Downloading and compiling xlxd... " echo "Downloading and compiling xlxd... "
cd /root/reflector-install-files/xlxd echo "------------------------------------------------------------------------------"
cd $XLXINSTDIR
git clone $XLXDREPO git clone $XLXDREPO
cd /root/reflector-install-files/xlxd/xlxd/src cd $XLXINSTDIR/xlxd/src
make clean make clean
make make
make install make install
fi fi
#Now the file should be there, if it compiled correctly. if [ -e $XLXINSTDIR/xlxd/src/xlxd ]
if [ -e /root/reflector-install-files/xlxd/xlxd/src/xlxd ]
then then
echo ""
echo ""
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
echo "It looks like everything compiled successfully. There is a 'xlxd' application file. " echo "It looks like everything compiled successfully. There is a 'xlxd' application file. "
else else
@ -82,52 +78,59 @@ else
exit 0 exit 0
fi fi
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
echo "Finishing install..." echo "Getting the DMRID.dat file... "
echo "" echo "------------------------------------------------------------------------------"
echo "" wget -O /xlxd/dmrid.dat $DMRIDURL
#get DMR files echo "------------------------------------------------------------------------------"
wget -O /xlxd/dmrid.dat http://xlxapi.rlx.lu/api/exportdmr.php echo "Copying web dashboard files and updating init script... "
#Copy files over cp -R $XLXINSTDIR/xlxd/dashboard/* /var/www/xlxd/
cp -R /root/reflector-install-files/xlxd/xlxd/dashboard/* /var/www/xlxd/ cp $XLXINSTDIR/xlxd/scripts/xlxd /etc/init.d/xlxd
cp /root/reflector-install-files/xlxd/xlxd/scripts/xlxd /etc/init.d/xlxd
#Update the startup script
sed -i "s/ARGUMENTS=\"XLX270 158.64.26.132\"/ARGUMENTS=\"XLX$XRFDIGIT $LOCAL_IP 127.0.0.1\"/g" /etc/init.d/xlxd sed -i "s/ARGUMENTS=\"XLX270 158.64.26.132\"/ARGUMENTS=\"XLX$XRFDIGIT $LOCAL_IP 127.0.0.1\"/g" /etc/init.d/xlxd
update-rc.d xlxd defaults update-rc.d xlxd defaults
echo "Updating XLXD Config file... "
echo "Updating config file" XLXCONFIG=/var/www/xlxd/pgs/config.inc.php
XLXCONFIGDIR=/var/www/xlxd/pgs/config.inc.php sed -i "s/your_email/$EMAIL/g" $XLXCONFIG
sed -i "s/your_email/$EMAIL/g" $XLXCONFIGDIR sed -i "s/LX1IQ/$CALLSIGN/g" $XLXCONFIG
sed -i "s/LX1IQ/$CALLSIGN/g" $XLXCONFIGDIR sed -i "s/http:\/\/your_dashboard/$XLXDOMAIN/g" $XLXCONFIG
sed -i "s/http:\/\/your_dashboard/$XLXDOMAIN/g" $XLXCONFIGDIR sed -i "s/\/tmp\/callinghome.php/\/xlxd\/callinghome.php/g" $XLXCONFIG
sed -i "s/\/tmp\/callinghome.php/\/xlxd\/callinghome.php/g" $XLXCONFIGDIR echo "Copying directives and reloading apache... "
echo "------------------------------------------------------------------------------"
#Copy apache vhost directives
echo "Copying directives and reloading apache....."
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
a2ensite $XLXDOMAIN a2ensite $XLXDOMAIN
systemctl reload apache2 systemctl reload apache2
service xlxd start
echo "------------------------------------------------------------------------------"
echo ""
echo ""
echo "******************************************************************************"
echo ""
echo ""
echo "XLXD is finished installing and ready to be used. Please read the following..." echo "XLXD is finished installing and ready to be used. Please read the following..."
echo "" echo ""
echo "------------------------------------------------------------------------------" echo ""
echo "******************************************************************************"
echo ""
echo " For Public Reflectors: "
echo "If you are requesting this reflector be added to all the pi-star host files as" echo "If you are requesting this reflector be added to all the pi-star host files as"
echo "a full time searchable reflector, you will need to request it on the xref forum boards." echo "a full time searchable reflector, you will need to request it on the xref forum"
echo "boards."
echo "Once activated, the callinghome hash to backup will be in /xlxd/callinghome.php" echo "Once activated, the callinghome hash to backup will be in /xlxd/callinghome.php"
echo "More Information: $SADREF" echo "More Information: $SADREF"
echo "" echo ""
echo "" echo ""
echo " For test/private Reflectors: "
echo "If you are using this reflector as a test or for offline access you will " echo "If you are using this reflector as a test or for offline access you will "
echo "need to configure the host files of the devices connecting to this server." echo "need to configure the host files of the devices connecting to this server."
echo "There are many online tutorials on 'Editing pi-star host files'. " echo "There are many online tutorials on 'Editing pi-star host files'. "
echo "" echo ""
echo "" echo ""
echo " Your $XFRNUM dashboad should now be accessible at... " echo " Your $XFRNUM dashboad should now be accessible... "
echo " http://$XLXDOMAIN or http://$LOCAL_IP " echo " http://$XLXDOMAIN "
echo "" echo ""
echo "" echo ""
echo "You can make further customizations to the main config file $XLXCONFIGDIR." echo "You can make further customizations to the main config file $XLXCONFIG."
echo "Be sure to thank the creators of xlxd for the ability to spin up " echo "Be sure to thank the creators of xlxd for the ability to spin up "
echo "your very own D-Star reflector. " echo "your very own D-Star reflector. "
echo "" echo ""
echo "------------------------------------------------------------------------------"