Debian 9

I made another script specifically for Debian 9 x64. This is designed to be run on a new install of Debian on a VPS. There may be some xrdp/LXDE crashes after opening the bot and I’m not sure what the cause is. The same may occur on Ubuntu.

Run this command:

wget -q https://cdn.projecthax.com/debian_9 && bash debian_9

Script contents:

#!/bin/bash

if [[ $EUID -ne 0 ]]; then
    echo 'In order for this script to run correctly, it must be run as root'
    exit 1
fi

read -r -p "This script is intended to be run on a fresh install of Debian 9 x64, do you wish to proceed? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then

    if [ `which sudo` == "" ]; then
        echo '> Installing sudo'
        apt update && apt install -y sudo
    fi

    # Update the system
    echo '> Updating the system'
    sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt install -y unattended-upgrades fail2ban p7zip-full apt-transport-https

    # Wine repository
    echo '> Adding the Wine repository'
    wget -nc https://repos.wine-staging.com/wine/Release.key
    sudo apt-key add Release.key
    sudo echo 'deb https://dl.winehq.org/wine-builds/debian/ stretch main' > /etc/apt/sources.list.d/winehq.list
    rm -f Release.key

    # Wine
    echo '> Installing wine and desktop environment'
    sudo dpkg --add-architecture i386 && sudo apt update && sudo apt install -y winehq-staging winetricks lxde-core lxterminal xrdp tigervnc-standalone-server

    # Add the phBot user
    echo '> Adding the phBot user'
    sudo useradd phBot -s /bin/bash -m -G users,sudo
    sudo passwd phBot

    # Change the X session for xrdp
    sudo -H -u phBot echo lxsession -s LXDE -e LXDE > /home/phBot/.xsession
    sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n lxsession \n' /etc/xrdp/startwm.sh

    # vcrun2013
    echo '> Installing vcrun2013 / corefonts'
    sudo -H -u phBot winetricks -q vcrun2013 corefonts

    # Stable
    echo '> Downloading phBot stable'
    BOT_VERSION=`curl -L http://cdn.phbot.org/stable/update.txt | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["phBot.exe"]["version"])'`
    sudo -H -u phBot curl -L http://cdn.phbot.org/stable/$BOT_VERSION.zip > /home/phBot/stable.zip
    sudo -H -u phBot mkdir -p /home/phBot/Desktop/stable/
    sudo -H -u phBot 7za -y x /home/phBot/stable.zip -o/home/phBot/Desktop/stable/
    rm -f /home/phBot/stable.zip

    # Testing
    echo '> Downloading phBot testing'
    BOT_VERSION=`curl -L http://cdn.phbot.org/testing/update.txt | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["phBot.exe"]["version"])'`
    sudo -H -u phBot curl -L http://cdn.phbot.org/testing/$BOT_VERSION.zip > /home/phBot/testing.zip
    sudo -H -u phBot mkdir -p /home/phBot/Desktop/testing/
    sudo -H -u phBot 7za -y x /home/phBot/testing.zip -o/home/phBot/Desktop/testing/
    rm -f /home/phBot/testing.zip

    # Swap less often
    sudo echo 'vm.swappiness=1' >> /etc/sysctl.conf

    echo '> After the reboot connect to the server through Remote Desktop Connection (select Xvnc) with the username phBot and the password you have chosen'
    echo '> Open the stable or testing folder on the desktop and run phBot.exe like normal'

    reboot
else
    exit 1
fi

If you have problems with small fonts, run winecfg and increase the DPI to 120.