This repository has been archived on 2024-12-19. You can view files and clone it, but cannot push or open issues or pull requests.
MusicBot_Installer_Tools/AutostartEN_0.1.sh

177 lines
4.7 KiB
Bash

#!/bin/bash
function redMessage {
echo -e "\\033[36;1m${@}\033[0m"
}
function greenMessage {
echo -e "\\033[32;1m${@}\033[0m"
}
function kekMessage {
echo -e "\\033[36;1m${@}\033[0m"
}
function yellowMessage {
echo -e "\\033[33;1m${@}\033[0m"
}
clear
clear
clear
figlet Autostart | lolcat -a
echo ""
echo ""
echo ""
echo ""
echo ""
echo "1. Activate autostart" | lolcat
echo "2. Disable autostart" | lolcat
echo "3. Add SinusBot instance to Autostart" | lolcat
echo ""
read -p "Please enter a number: " autostart
if [ "$autostart" = "3" ]; then
if [ -f /etc/SinusAutostart/autostart -o -h /etc/SinusAutostart/autostart ]
then
greenMessage "Enter the SinusBot web interface port"
read webport
greenMessage "Enter a password for the selected instance"
echo "The password is then always used!" | lolcat
read pwfilee
echo "sleep 3
clear
rm -rf /tmp/.X11-unix/X40 /tmp/.sinusbot.lock
su SinusPort-$webport -c 'cd; screen -AmdS SinusPort-$webport ./sinusbot --override-password=$pwfilee'
clear" >> /etc/SinusAutostart/autostart
echo "The SinusBot instance has been entered in the autostart system!" | lolcat
else
echo "The autostart function is not activated!" | lolcat
sleep 1
yellowMessage "To use this function, the autostart function must be activated!"
sleep 1
fi
fi
if [ "$autostart" = "2" ]; then
echo "Autostart check..." | lolcat
autoactive=$(head -n1 MultiData/autostart.RAW|tail -n1)
if ! [ "$autoactive" = "active" ]; then
echo "The autostart function has already been deactivated!" | lolcat
sleep 1
echo "Exit Script..." | lolcat
sleep 1.5
fi
if [ "$autoactive" = "active" ]; then
greenMessage "Deactivate autostart..."
sleep 1
printf "NotActive" > MultiData/autostart.RAW
sleep 0.5
mv /etc/SinusAutostart/autostart /etc/SinusAutostart/autostart-NotActive
sleep 1
clear
clear
clear
echo "Autostart has been deactivated!" | lolcat
sleep 1.5
fi
fi
if [ "$autostart" = "1" ]; then
if ! [ -f MultiData/autostart.RAW -o -h MultiData/autostart.RAW ]
then
printf "NotActive" > MultiData/autostart.RAW
fi
autotesting=$(head -n1 MultiData/autostart.RAW|tail -n1)
if [ "$autotesting" = "active" ]; then
echo "The autostart function is already activated!" | lolcat
sleep 1.5
echo "Exit Script..." | lolcat
sleep 1
fi
if [ "$autotesting" = "NotActive" ]; then
greenMessage "############################################################"
echo " Autostart check" | lolcat
greenMessage "############################################################"
echo ""
echo ""
echo "Autostart is not active!"
echo ""
sleep 2.5
clear
clear
clear
echo "Should the autostart be activated?"
greenMessage "yes/no"
read -p "Enter an answer: " quest
if [ "$quest" = "yes" ]; then
clear
clear
clear
echo "Create data..."
sleep 1
autoactivee=$(head -n1 MultiData/autostart.RAW|tail -n1)
sudo mkdir -p /etc/SinusAutostart
printf "
echo "Created by RAW Networks"
" >> /etc/SinusAutostart/auto.dat
mv /etc/SinusAutostart/autostart-NotActive /etc/SinusAutostart/autostart
sleep 1
clear
clear
clear
printf "NotActive" > MultiData/autostart.RAW
sleep 1
if ! [ "$autoactivee" = "active" ]; then
printf "active" > MultiData/autostart.RAW
fi
sleep 0.5
clear
clear
clear
echo "Install packages..." | lolcat
sudo apt-get -qq install cron-apt screen -y >/dev/null
sleep 1
crontab -l; echo '@reboot su -c "screen -AmdS consol /etc/SinusAutostart/autostart" root'| crontab -
sleep 1
printf 'echo "SinusBot Autostart created by RAW Networks <3" ' >> /etc/SinusAutostart/autostart
sleep 1
chmod 777 /etc/SinusAutostart/autostart
clear
clear
clear
echo "The autostart function has been activated!" | lolcat
if [ -f MultiData/autostart.RAW -o -h MultiData/autostart.RAW ]
then
clear
clear
clear
echo "The autostart function has already been activated!" | lolcat
sleep 1.5
echo "Exit Script..." | lolcat
fi
if [ "$autostart" = "no" ]; then
echo "Script is terminated..." | lolcat
sleep 1.5
fi
fi
fi
fi