YSFReflector-debian-installer/YSFReflector-debian-installer

116 lines
4.5 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 8,9 and x64 cpu Arch. for now."
exit 0
fi
DIRDIR=$(pwd)
YSFREPO=https://github.com/g4klx/YSFClients.git
DEP="wget git build-essential"
YSFINSTDIR=/root/reflector-install-files/ysfreflector
YSFAPPDIR=/ysfreflector
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 "------------------------------------------------------------------------------"
echo "Installing required software... "
apt-get -y install $DEP
#Make Directories
echo ""
echo "Creating YSF directories... "
mkdir -p $YSFINSTDIR
mkdir -p $YSFAPPDIR
#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 $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
#Now the file should be there, if it compiled correctly.
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
#Copying over files.
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/ysfreflector.service /etc/systemd/system
systemctl daemon-reload
echo ""
echo ""
echo "******************************************************************************"
echo ""
echo " This concludes the install of YSFReflector..... "
echo ""
echo "******************************************************************************"
echo ""
echo "Remember to register your YSF Reflector at https://register.ysfreflector.de/register. "
echo ""
echo ""
echo " To start YSFReflector: 'systemctl start ysfreflector' "
echo ""
echo " To stop YSFReflector: 'systemctl stop ysfreflector' "
echo ""
echo "------------------------------------------------------------------------------"