YSFReflector-debian-installer/YSFReflector-debian-installer

141 lines
5.7 KiB
Bash
Executable File

#!/bin/bash
#A tool to install YSFReflector.
#This is essentially a scripted version of:
#https://register.ysfreflector.de/installation
#Step 1: Install Debian 9 and make sure it is up to date.
#Step 2: Run this script
#Step 3: Use systemd to control the service
# systemctl status ysfreflector
#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 ""
echo "This script is only tested in Debian/Ubuntu 8,9,10 and x64 cpu Arch. for now."
exit 0
fi
DIRDIR=$(pwd)
YSFREPO=https://github.com/g4klx/YSFClients.git
YSFDASHREPO=https://github.com/dg9vh/YSFReflector-Dashboard.git
DEP="wget git build-essential g++ apache2 php libapache2-mod-php"
YSFINSTDIR=/root/reflector-install-files/ysfreflector
YSFAPPDIR=/ysfreflector
YSFDASDIR=/root/reflector-install-files/ysfdash
YSFWEBDIR=/var/www/ysf
echo ""
echo "------------------------------------------------------------------------------"
read -p "What will the name of your reflector be? 16 Characters MAX, this includes spaces. " YSFNAME
YSFNAMEC=$(expr length "$YSFNAME")
until [ $YSFNAMEC -le 16 ]
do
read -p "What will the name of your reflector be? 16 Characters MAX, this includes spaces. " YSFNAME
YSFNAMEC=$(expr length "$YSFNAME")
done
echo "------------------------------------------------------------------------------"
echo ""
read -p "What is the description? 14 Characters MAX, this includes spaces. " YSFDESC
YSFDESCC=$(expr length "$YSFDESC")
until [ $YSFDESCC -le 14 ]
do
read -p "What is the description? 14 Characters MAX, this includes spaces. " YSFDESC
YSFDESCC=$(expr length "$YSFDESC")
done
echo "------------------------------------------------------------------------------"
echo ""
read -p "What is the FQDN of the YSF Reflector dashboard? Example: ysf.domain.com " YSFDOMAIN
echo ""
echo "------------------------------------------------------------------------------"
echo "Installing required software... "
apt-get -y install $DEP
echo ""
echo "Creating YSF directories... "
mkdir -p $YSFINSTDIR
mkdir -p $YSFAPPDIR
mkdir -p $YSFWEBDIR
mkdir -p $YSFDASDIR
if [ -e $YSFINSTDIR/YSFClients/YSFReflector/YSFReflector ]
then
echo ""
echo "It looks like you have already compiled YSFReflector. If you want to install it again, delete the directory '/root/YSFReflector-install-files' and run this script again. "
exit 0
else
echo ""
echo "------------------------------------------------------------------------------"
echo "Downloading and compiling YSFReflector... "
echo "------------------------------------------------------------------------------"
cd $YSFINSTDIR
git clone $YSFREPO
cd $YSFINSTDIR/YSFClients/YSFReflector
make clean all
fi
if [ -e $YSFINSTDIR/YSFClients/YSFReflector/YSFReflector ]
then
echo ""
echo "It looks like everything compiled successfully. There is a 'YSFReflector' application file. "
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. To Try again Remove '/root/reflector-install-files'. "
exit 0
fi
echo ""
echo "Copying files over to the executable directory...... "
cp $YSFINSTDIR/YSFClients/YSFReflector/YSFReflector $YSFAPPDIR
cp $YSFINSTDIR/YSFClients/YSFReflector/YSFReflector.ini $YSFAPPDIR
echo "Updating ini file in /YSFReflector...... "
sed -i "s/16[ ]*characters[ ]*max/$YSFNAME/g" $YSFAPPDIR/YSFReflector.ini
sed -i "s/14[ ]*characters[ ]*max/$YSFDESC/g" $YSFAPPDIR/YSFReflector.ini
sed -i "s/FilePath=./FilePath=\/var\/log\/YSFReflector\//g" $YSFAPPDIR/YSFReflector.ini
groupadd mmdvm
useradd mmdvm -g mmdvm -s /sbin/nologin
mkdir -p /var/log/YSFReflector
chown mmdvm: /var/log/YSFReflector
echo "Copying ysfrelfector to systemd...... "
cp $DIRDIR/templates/ysf.service /etc/systemd/system
systemctl daemon-reload
systemctl enable ysf
echo "------------------------------------------------------------------------------"
echo "Installing the YSF Dashboard and configuring apache... "
echo "------------------------------------------------------------------------------"
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
#Copy apache vhost files over for ysf
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
chown -R www-data: $YSFWEBDIR
a2ensite $YSFDOMAIN
a2enmod php7.4
systemctl start ysf
systemctl restart apache2
echo ""
echo ""
echo "******************************************************************************"
echo ""
echo " This concludes the install of YSFReflector and Dashboard..... "
echo ""
echo "******************************************************************************"
echo ""
echo "Remember to register your YSF Reflector at https://register.ysfreflector.de/register. "
echo ""
echo ""
echo " To restart YSFReflector: 'systemctl restart ysf' "
echo ""
echo " To stop YSFReflector: 'systemctl stop ysf' "
echo ""
echo " Your web dashboard can be found at: "
echo " http://$YSFDOMAIN "
echo ""
echo "------------------------------------------------------------------------------"