2018-11-30 10:15:31 -05:00
#!/bin/bash
# A tool to install xlxd, your own D-Star Reflector.
2019-05-11 17:33:31 -04:00
# For more information, please visit: https://n5amd.com
2018-11-30 10:15:31 -05:00
#Lets begin-------------------------------------------------------------------------------------------------
WHO = $( whoami)
if [ " $WHO " != "root" ]
then
echo ""
echo "You Must be root to run this script!!"
exit 0
fi
if [ ! -e "/etc/debian_version" ]
then
echo ""
2024-09-22 15:54:50 -04:00
echo "This script is only tested on Debian and x64 CPU Arch. but XLX will work on most ANY Linux distro. "
2018-11-30 10:15:31 -05:00
exit 0
fi
DIRDIR = $( pwd )
2024-09-22 15:54:50 -04:00
LOCAL_IP = $( hostname -I | awk '{print $1}' )
2019-05-11 17:33:31 -04:00
INFREF = https://n5amd.com/digital-radio-how-tos/create-xlx-xrf-d-star-reflector/
2018-12-13 21:12:26 -05:00
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
2021-12-04 18:53:23 -05:00
DEP = "wget git build-essential g++ apache2 php libapache2-mod-php php7.0-mbstring"
DEP2 = "wget git build-essential g++ apache2 php libapache2-mod-php php7.3-mbstring"
2022-10-06 21:04:22 -04:00
DEP3 = "wget git build-essential g++ apache2 php libapache2-mod-php php-curl php-json php-cgi php7.4-mbstring snapd figlet"
2024-09-22 16:11:52 -04:00
APPS = "git git-core apache2 php libapache2-mod-php php-cli php-xml php-mbstring php-curl build-essential snapd figlet"
2020-10-30 16:50:38 -04:00
VERSION = $( sed 's/\..*//' /etc/debian_version)
2018-11-30 10:15:31 -05:00
clear
echo ""
2021-12-04 18:23:27 -05:00
echo "XLX uses 3 digit numbers for its reflectors. For example: 248, 999, 099."
2018-11-30 10:15:31 -05:00
read -p "What 3 digit XRF number will you be using? " XRFDIGIT
2019-12-21 16:59:12 -05:00
XRFNUM = XLX$XRFDIGIT
2018-11-30 10:15:31 -05:00
echo ""
echo "--------------------------------------"
2021-12-04 18:23:27 -05:00
read -p "What is the FQDN of the XLX Reflector dashboard? Example: xlx999.domain.com. " XLXDOMAIN
2018-11-30 10:15:31 -05:00
echo ""
echo "--------------------------------------"
read -p "What E-Mail address can your users send questions to? " EMAIL
echo ""
echo "--------------------------------------"
read -p "What is the admins callsign? " CALLSIGN
2018-12-13 21:12:26 -05:00
echo ""
echo ""
2018-11-30 10:15:31 -05:00
echo "------------------------------------------------------------------------------"
echo "Making install directories and installing dependicies...."
2018-12-13 21:12:26 -05:00
echo "------------------------------------------------------------------------------"
mkdir -p $XLXINSTDIR
mkdir -p $WEBDIR
2024-09-22 15:54:50 -04:00
apt-get -y update
apt-get -y install $APPS
#if [ $VERSION = 9 ]
#then
# apt-get -y install $DEP
# a2enmod php7.0
#elif [ $VERSION = 10 ]
#then
# apt-get -y install $DEP2
#elif [ $VERSION = 11 ]
#then
# apt-get -y install $DEP3
#fi
2020-10-31 15:42:12 -04:00
2018-11-30 10:15:31 -05:00
echo "------------------------------------------------------------------------------"
2018-12-13 21:12:26 -05:00
if [ -e $XLXINSTDIR /xlxd/src/xlxd ]
2018-11-30 10:15:31 -05:00
then
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. "
2018-12-13 21:12:26 -05:00
exit 0
2018-11-30 10:15:31 -05:00
else
2021-12-04 19:35:19 -05:00
echo "Downloading and compiling LX4JL XLXD... "
2018-12-13 21:12:26 -05:00
echo "------------------------------------------------------------------------------"
cd $XLXINSTDIR
2021-12-04 20:04:55 -05:00
figlet "XLXD Like a PRO..."
2018-11-30 10:15:31 -05:00
git clone $XLXDREPO
2018-12-13 21:12:26 -05:00
cd $XLXINSTDIR /xlxd/src
2021-12-04 19:35:19 -05:00
sleep 5
echo "------------------------------------------------------------------------------"
echo "Edit your configuration"
sleep 5
2021-12-04 19:09:31 -05:00
nano main.h
2021-12-04 20:04:55 -05:00
make clean
2018-11-30 10:15:31 -05:00
make
make install
fi
2018-12-13 21:12:26 -05:00
if [ -e $XLXINSTDIR /xlxd/src/xlxd ]
2018-11-30 10:15:31 -05:00
then
2018-12-13 21:12:26 -05:00
echo ""
echo ""
2018-11-30 10:15:31 -05:00
echo "------------------------------------------------------------------------------"
echo "It looks like everything compiled successfully. There is a 'xlxd' application file. "
else
echo ""
echo "UH OH!! I dont see the xlxd application file after attempting to compile."
echo "The output above is the only indication as to why it might have failed. "
echo "Delete the directory '/root/reflector-install-files/xlxd' and run this script again. "
echo ""
exit 0
fi
echo "------------------------------------------------------------------------------"
2018-12-13 21:12:26 -05:00
echo "Getting the DMRID.dat file... "
echo "------------------------------------------------------------------------------"
wget -O /xlxd/dmrid.dat $DMRIDURL
echo "------------------------------------------------------------------------------"
echo "Copying web dashboard files and updating init script... "
cp -R $XLXINSTDIR /xlxd/dashboard/* /var/www/xlxd/
cp $XLXINSTDIR /xlxd/scripts/xlxd /etc/init.d/xlxd
2022-10-06 21:04:22 -04:00
sed -i " s/XLX248 192.168.1.240 127.0.0.1/ $XRFNUM $LOCAL_IP 127.0.0.1/g " /etc/init.d/xlxd
2018-11-30 10:15:31 -05:00
update-rc.d xlxd defaults
2019-05-12 13:43:57 -04:00
# Delaying startup time
2022-10-06 21:04:22 -04:00
# mv /etc/rc3.d/S01xlxd /etc/rc3.d/S10xlxd ##Disabling as its not really needed.
2018-12-13 21:12:26 -05:00
echo "Updating XLXD Config file... "
XLXCONFIG = /var/www/xlxd/pgs/config.inc.php
sed -i " s/your_email/ $EMAIL /g " $XLXCONFIG
sed -i " s/LX1IQ/ $CALLSIGN /g " $XLXCONFIG
2019-08-15 16:03:03 -04:00
sed -i " s/http:\/\/your_dashboard/http:\/\/ $XLXDOMAIN /g " $XLXCONFIG
2018-12-13 21:12:26 -05:00
sed -i "s/\/tmp\/callinghome.php/\/xlxd\/callinghome.php/g" $XLXCONFIG
echo "Copying directives and reloading apache... "
2018-11-30 10:15:31 -05:00
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
2019-08-10 17:19:57 -04:00
chown -R www-data:www-data /var/www/xlxd/
chown -R www-data:www-data /xlxd/
2018-11-30 10:15:31 -05:00
a2ensite $XLXDOMAIN
2024-09-22 15:54:50 -04:00
a2dissite 000-default
2022-01-11 14:01:45 -05:00
# revert certbot make this an option! for another day
#if [ $VERSION = 11 ]
#then
# snap install core
# snap refresh core
# snap install --classic certbot
# ln -s /snap/bin/certbot /usr/bin/certbot
# ufw allow http
# ufw allow https
# systemctl restart apache2
# certbot --apache
#else
# echo ""
# echo "Ahh! Somthing went wrong with the snapd cerbot app, your SSL certificate"
# echo "The output above is the only indication as to why it might have failed. "
# echo "Run certbot --apache again to restart certbot installation"
# echo ""
# exit 0
#fi
# end of certbot
2022-01-11 14:27:04 -05:00
# clear
2021-12-04 20:04:55 -05:00
echo "Starting XLXD....."
2021-12-04 19:35:19 -05:00
sleep 2
2021-12-04 19:47:18 -05:00
figlet "XLXD Reflector"
2018-12-13 21:12:26 -05:00
service xlxd start
2019-05-12 12:21:08 -04:00
systemctl restart apache2
2018-12-13 21:12:26 -05:00
echo "------------------------------------------------------------------------------"
echo ""
echo ""
echo "******************************************************************************"
echo ""
echo ""
2018-11-30 10:15:31 -05:00
echo "XLXD is finished installing and ready to be used. Please read the following..."
echo ""
2018-12-13 21:12:26 -05:00
echo ""
echo "******************************************************************************"
echo ""
echo " For Public Reflectors: "
2019-05-12 12:29:17 -04:00
echo "If your XLX number is not already taken, enabling callinghome is all you need to do "
echo "for your reflector to be added to all the host files automatically. It does take "
echo "about an hour for the change to reflect, if your reflector is accessible and working."
2019-08-09 15:16:20 -04:00
echo "Once activated, the callinghome hash to backup will be /xlxd/callinghome.php. "
2019-05-11 17:33:31 -04:00
echo " More Information: $INFREF "
2018-11-30 10:15:31 -05:00
echo ""
echo ""
2018-12-13 21:12:26 -05:00
echo " For test/private Reflectors: "
2018-11-30 10:15:31 -05:00
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 "There are many online tutorials on 'Editing pi-star host files'. "
echo ""
echo ""
2019-12-21 16:59:12 -05:00
echo " Your $XRFNUM dashboad should now be accessible... "
2018-12-13 21:12:26 -05:00
echo " http:// $XLXDOMAIN "
2018-11-30 10:15:31 -05:00
echo ""
echo ""
2018-12-13 21:12:26 -05:00
echo " You can make further customizations to the main config file $XLXCONFIG . "
2018-11-30 10:15:31 -05:00
echo "Be sure to thank the creators of xlxd for the ability to spin up "
echo "your very own D-Star reflector. "
echo ""
2018-12-13 21:12:26 -05:00
echo "------------------------------------------------------------------------------"