website statistics Help - Perfect world installation Script issue | hrace009 Community ✅

Help Perfect world installation Script issue

Amith

New Member
I've been trying to install Perfect world installation Script on Digital Ocean CentOS vps

This script use for install Perfect World Private Server to your VPS / local development.

Installation
Copy & Paste this script, and put at your root user directory and execute it.

Usage
Bash:
./installpw.sh
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.

License
MIT

Link:

Home Page: hrace009 Personal Blog
Forum: hrace009 Forum

Code:
#!/usr/bin/env bash
# Program: Installation for Perfect World Private Server
# History:
# 29-04-2020 hrace009 First created.

clear
PW_VERSION="null"
PWFILE_URL="https://pwdatacore.hrace009.com/new/"
SERVER_PATH="/home"
PACKAGE_UPGRADE="yum -q -y upgrade"
PACKAGE_UPDATE="yum -q -y update"
PACKAGE_CLEAN="yum -q clean all"
PACKAGE_INSTALLER="yum -q -y install"
SOFTWARE_PCKG_1="redhat-lsb-core ntpdate MariaDB MariaDB-server httpd httpd-tools mod_fcgid fcgi mod_http2 mod_ssl php php-fpm php-mysqlnd php-gd php-imap php-ldap php-mcrypt php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-imagick php-soap php-pecl-zip php-pecl-rar php-pear php-intl php-ioncube-loader perl perl-Net-SSLeay openssl perl-IO-Tty"
SOFTWARE_PCKG_2="glibc.i686 glibc.x86_64 libxml2.i686 libxml2.x86_64 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64 libgcc.i686 libgcc.x86_64 pcre.i686 pcre.x86_64 java-1.6.0-openjdk wine p7zip perl-Digest-MD5 perl-Encode-Detect"
HOST_NAME="127.0.0.1   auth aumanager audb manager link1 game1 game2 game3 delivery database backup gmserver dbserver gamedbserver GAuth gdelivery GameDB GameDBClient providerserver6 providerserver7 providerserver8 providerserver9 linkip1 linkip2 linkip3 linkip4"
RPM_IMPORT="rpm --import"
RPM_INSTALL="rpm -ivh"
EPEL_FILE="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
EPEL_KEY="https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7"
REMI_FILE="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm"
WEBMIN_KEY="http://www.webmin.com/jcameron-key.asc"
WEBMIN_INSTALL="http://www.webmin.com/download/rpm/webmin-current.rpm"
REMI_KEY="http://rpms.remirepo.net/RPM-GPG-KEY-remi"
MARIADB_KEY="https://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
MARIADB_MIRROR="http://yum.mariadb.org/10.1/centos7-amd64"
LOGFILE=$(date +%Y-%m-%d_%H.%M.%S_hrace009_Personal_Cloud_install.log)
RED='\033[0;41;30m'
STD='\033[0;0;39m'

pause(){
  read -p "Press [Enter] key to continue..." fackEnterKey
}

server_131(){
    PW_VERSION="1.3.1"
}

server_136(){
    PW_VERSION="1.3.6"
}

server_145(){
    PW_VERSION="1.4.5"
}

server_146(){
    PW_VERSION="1.4.6"
}

server_147(){
    PW_VERSION="1.4.7"
}

server_151(){
    PW_VERSION="1.5.1"
}

server_153(){
    PW_VERSION="1.5.3"
}

server_155(){
    PW_VERSION="1.5.5"
}


show_menus() {
    clear
    echo "~~~~~~~~~~~~~~~~~~~~~"   
    echo " Chose Server Version"
    echo "~~~~~~~~~~~~~~~~~~~~~"
    echo "1. 1.3.1"
    echo "2. 1.3.6"
    echo "3. 1.4.5"
    echo "4. 1.4.6"
    echo "5. 1.4.7"
    echo "6. 1.5.1"
    echo "7. 1.5.3"
    echo "8. 1.5.5"
    echo "9. Exit"
}

read_options(){
    local choice
    read -p "Enter choice [ 1 - 9] " choice
    case $choice in
        1) server_131 ;;
        2) server_136 ;;
        3) server_145 ;;
        4) server_146 ;;
        5) server_147 ;;
        6) server_151 ;;
        7) server_153 ;;
        8) server_155 ;;
        9) exit 0;;
        *) echo -e "${RED}Error...${STD}" && sleep 2
    esac
}

touch "$LOGFILE"
exec > >(tee "$LOGFILE")
exec 2>&1

show_menus
read_options

if [ ! -d $SERVER_PATH ]; then
mkdir $SERVER_PATH
fi

#--- Display the 'welcome' splash/user warning info..
echo ""
echo "#############################################################################"
echo "#  Welcome to the Official hrace009 VPS PW Installer $PW_VERSION                  #"
echo "#  This Installer Only for CentOS 7.X, otherwise will not support.          #"
echo "#  Make sure this server is fresh install.                                  #"
echo "#  This application will install hrace009 Perfect World $PW_VERSION               #"
echo "#  For more information, please visit: https://www.hrace009.com             #"
echo "#############################################################################"
sleep 5

echo -e "\nChecking that minimal requirements are ok"

# Ensure the OS is compatible with the launcher
if [ -f /etc/centos-release ]; then
    OS="CentOs"
    VERFULL=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/centos-release)
    VER=${VERFULL:0:1} # return 6 or 7
fi
ARCH=$(uname -m)

echo "Detected : $OS $VER $ARCH"

if [[ "$OS" = "CentOs" && ("$VER" = "7") ]]; then
    echo "Your OS Good to go."
else
    echo "Sorry, this OS is not supported by hrace009."
    exit 1
fi

# Check if the user is 'root' before allowing installation to commence
if [ $UID -ne 0 ]; then
    echo "Install failed: you must be logged in as 'root' to install."
    echo "Use command 'sudo -i', then enter root password and then try again."
    exit 1
fi
echo ""
echo "Please wait a while, we collect some information first."
echo "======================================================="

$PACKAGE_INSTALLER wget bind-utils jwhois yum-priorities yum-utils curl iptables-services

# Flush iptables
iptables --flush
service iptables save
systemctl stop firewalld
systemctl disable firewalld.service

# service iptables stop
systemctl stop iptables.service

local_ip=$(ip addr show | awk '$1 == "inet" && $3 == "brd" { sub (/\/.*/,""); print $2 }')
extern_ip="$(wget -qO- http://api.sentora.org/ip.txt)"

while getopts d:i:t: opt; do
  case $opt in
  d)
      SVR_FQDN=$OPTARG
      PATCHER_FQDN=$OPTARG
      REGISTER_FQDN=$OPTARG
      INSTALL="auto"
      ;;
  i)
      PUBLIC_IP=$OPTARG
      if [[ "$PUBLIC_IP" == "local" ]] ; then
          PUBLIC_IP=$local_ip
      elif [[ "$PUBLIC_IP" == "public" ]] ; then
          PUBLIC_IP=$extern_ip
      fi
      ;;
  t)
      echo "$OPTARG" > /etc/timezone
      tz=$(cat /etc/timezone)
      ;;
  esac
done
if [[ ("$SVR_FQDN" != "" && "$PUBLIC_IP" == "") ||
      ("$SVR_FQDN" == "" && "$PUBLIC_IP" != "") ]] ; then
    echo "-d and -i must be both present or both absent."
    exit 2
fi

if [[ ("$PATCHER_FQDN" != "" && "$PUBLIC_IP" == "") ||
      ("$PATCHER_FQDN" == "" && "$PUBLIC_IP" != "") ]] ; then
    echo "-d and -i must be both present or both absent."
    exit 2
fi

if [[ ("$REGISTER_FQDN" != "" && "$PUBLIC_IP" == "") ||
      ("$REGISTER_FQDN" == "" && "$PUBLIC_IP" != "") ]] ; then
    echo "-d and -i must be both present or both absent."
    exit 2
fi
clear
if [[ "$tz" == "" && "$SVR_FQDN" == "" ]] ; then
    # Propose selection list for the time zone
    echo "Preparing to select timezone, please wait a few seconds..."
    $PACKAGE_INSTALLER tzdata
    # setup server timezone
        # make tzselect to save TZ in /etc/timezone
        echo "echo \$TZ > /etc/timezone" >> /usr/bin/tzselect
        tzselect
        tz=$(cat /etc/timezone)
fi
# clear timezone information to focus user on important notice
clear

# Installer parameters
if [[ "$SVR_FQDN" == "" ]] ; then
    echo -e "\n\e[1;33m=== Informations required to build your server ===\e[0m"
    echo 'The installer requires 6 pieces of information:'
    echo ' 1) the GLINK Domain that you want to use for client access on port 29000,'
    echo '   - do not use your main domain (like domain.com)'
    echo '   - use a sub-domain, e.g pwserver.domain.com'
    echo '   - or use the server hostname, e.g server1.domain.com'
    echo '   - DNS must already be configured and pointing to the server IP'
    echo ' 2) the Patcher Domain that you want to use for Auto Patcher on port 80,'
    echo '   - do not use your main domain (like domain.com)'
    echo '   - use a sub-domain, e.g patcher.domain.com'
    echo '   - or use the server hostname, e.g server2.domain.com'
    echo '   - DNS must already be configured and pointing to the server IP'
    echo ' 3) the API Domain that you want to use for API communication on port 80,'
    echo '   - do not use your main domain (like domain.com)'
    echo '   - use a sub-domain, e.g api.domain.com'
    echo '   - or use the server hostname, e.g server1.domain.com'
    echo '   - DNS must already be configured and pointing to the server IP'
    echo ' 4) Special user for your PW Server.'
    echo ' 5) MySQL Admin User and Password for MySQL (DO NOT USE ROOT USER).'
    echo ' 6) The public IP of the server.'
    echo ''

    SVR_FQDN="$(/bin/hostname)"
    PUBLIC_IP=$extern_ip
    while true; do
        echo ""
        echo "Enter your GLINK Domain e.g game.mypw.com"
        read -e -p "GLINK Domain PW Server: " -i "$SVR_FQDN" SVR_FQDN
        echo "Enter your Patcher Domain e.g patcher.mypw.com"
        read -e -p "Patcher Domain PW Server: " -i "$PATCHER_FQDN" PATCHER_FQDN
        echo "Enter your API Domain e.g api.mypw.com"
        read -e -p "API Domain PW Server: " -i "$REGISTER_FQDN" REGISTER_FQDN

        if [[ "$PUBLIC_IP" != "$local_ip" ]]; then
          echo -e "\nThe public IP of the server is $PUBLIC_IP.\nThe local IP is $local_ip"
          echo "For a production server, the PUBLIC IP must be used."
          echo "For a development server, the LOCAL IP must be used."
        fi 
        read -e -p "Enter (or confirm) the public IP for this server: " -i "$PUBLIC_IP" PUBLIC_IP
        echo ""

        # Checks if the panel domain is a subdomain
        sub=$(echo "$SVR_FQDN" | sed -n 's|\(.*\)\..*\..*|\1|p')
        if [[ "$sub" == "" ]]; then
            echo -e "\e[1;31mWARNING: $SVR_FQDN is not a subdomain!\e[0m"
            confirm="true"
        fi
        sub2=$(echo "$PATCHER_FQDN" | sed -n 's|\(.*\)\..*\..*|\1|p')
        if [[ "$sub2" == "" ]]; then
            echo -e "\e[1;31mWARNING: $PATCHER_FQDN is not a subdomain!\e[0m"
            confirm="true"
        fi
        sub3=$(echo "$REGISTER_FQDN" | sed -n 's|\(.*\)\..*\..*|\1|p')
        if [[ "$sub3" == "" ]]; then
            echo -e "\e[1;31mWARNING: $REGISTER_FQDN is not a subdomain!\e[0m"
            confirm="true"
        fi

        # Checks if the panel domain is already assigned in DNS
        dns_panel_ip=$(host "$SVR_FQDN"|grep address|cut -d" " -f4)
        if [[ "$dns_panel_ip" == "" ]]; then
            echo -e "\e[1;31mWARNING: $SVR_FQDN is not defined in your DNS!\e[0m"
            echo "  You must add records in your DNS manager (and then wait until propagation is done)."
            echo "  If this is a production installation, set the DNS up as soon as possible."
            echo "  If this is a development installation, you can ignore this warning."
            confirm="true"
        else
            echo -e "\e[1;32mOK\e[0m: DNS successfully resolves $SVR_FQDN to $dns_panel_ip"

            # Check if panel domain matches public IP
            if [[ "$dns_panel_ip" != "$PUBLIC_IP" ]]; then
                echo -e -n "\e[1;31mWARNING: $SVR_FQDN DNS record does not point to $PUBLIC_IP!\e[0m"
                echo "  PW Server will not be reachable from http://$SVR_FQDN"
                echo "  For development use, just ignore this warning"
                confirm="true"
            fi
        fi

        dns_panel_ip2=$(host "$PATCHER_FQDN"|grep address|cut -d" " -f4)
        if [[ "$dns_panel_ip2" == "" ]]; then
            echo -e "\e[1;31mWARNING: $PATCHER_FQDN is not defined in your DNS!\e[0m"
            echo "  You must add records in your DNS manager (and then wait until propagation is done)."
            echo "  If this is a production installation, set the DNS up as soon as possible."
            echo "  If this is a development installation, you can ignore this warning."
            confirm="true"
        else
            echo -e "\e[1;32mOK\e[0m: DNS successfully resolves $PATCHER_FQDN to $dns_panel_ip2"

            # Check if panel domain matches public IP
            if [[ "$dns_panel_ip2" != "$PUBLIC_IP" ]]; then
                echo -e -n "\e[1;31mWARNING: $PATCHER_FQDN DNS record does not point to $PUBLIC_IP!\e[0m"
                echo "  PW Server will not be reachable from http://$PATCHER_FQDN"
                echo "  For development use, just ignore this warning"
                confirm="true"
            fi
        fi

        dns_panel_ip3=$(host "$REGISTER_FQDN"|grep address|cut -d" " -f4)
        if [[ "$dns_panel_ip3" == "" ]]; then
            echo -e "\e[1;31mWARNING: $REGISTER_FQDN is not defined in your DNS!\e[0m"
            echo "  You must add records in your DNS manager (and then wait until propagation is done)."
            echo "  If this is a production installation, set the DNS up as soon as possible."
            echo "  If this is a development installation, you can ignore this warning."
            confirm="true"
        else
            echo -e "\e[1;32mOK\e[0m: DNS successfully resolves $REGISTER_FQDN to $dns_panel_ip3"

            # Check if panel domain matches public IP
            if [[ "$dns_panel_ip3" != "$PUBLIC_IP" ]]; then
                echo -e -n "\e[1;31mWARNING: $REGISTER_FQDN DNS record does not point to $PUBLIC_IP!\e[0m"
                echo "  PW Server will not be reachable from http://$REGISTER_FQDN"
                echo "  For development use, just ignore this warning"
                confirm="true"
            fi
        fi

        if [[ "$PUBLIC_IP" != "$extern_ip" && "$PUBLIC_IP" != "$local_ip" ]]; then
            echo -e -n "\e[1;31mWARNING: $PUBLIC_IP does not match detected IP !\e[0m"
            echo "  PW Server will not work with this IP..."
            echo "  For development use, just ignore this warning"
                confirm="true"
        fi
     
        echo ""
        # if any warning, ask confirmation to continue or propose to change
        if [[ "$confirm" != "" ]] ; then
            echo "There are some warnings..."
            echo "Are you really sure that you want to setup PW Server with these parameters?"
            read -e -p "(y):Accept and install, (n):Change domain or IP, (q):Quit installer? " yn
            case $yn in
                [Yy]* ) break;;
                [Nn]* ) continue;;
                [Qq]* ) exit;;
            esac
        else
            read -e -p "All is ok. Do you want to install PW Server now (y/n)? " yn
            case $yn in
                [Yy]* ) break;;
                [Nn]* ) exit;;
            esac
        fi
    done
fi

# Function to disable a file by appending its name with _disabled
disable_file() {
    mv "$1" "$1_disabled_by_hrace009" &> /dev/null
}

#--- Some functions used many times below
# Random password generator function
passwordgen() {
    l=$1
    [ "$l" == "" ] && l=16
    tr -dc A-Za-z0-9 < /dev/urandom | head -c ${l} | xargs
}

# Random username generator function
usernamegen() {
    l=$1
    [ "$l" == "" ] && l=6
    tr -dc a-z < /dev/urandom | head -c ${l} | xargs
}
# Add first parameter in hosts file as local IP domain
add_local_domain() {
    if ! grep -q "127.0.0.1 $1" /etc/hosts; then
        echo "127.0.0.1 $1" >> /etc/hosts;
    fi
}

echo -e "\n\e[1;33m=== Special User Information ===\e[0m"
echo -e "NOTE: If empty user and pass, we will use random generate"
read -e -p "Enter OS Username: " -i "$CREATE_USER" CREATE_USER
read -e -p "Enter OS Password: " -i "$CREATE_USER_PASSWD" CREATE_USER_PASSWD
echo -e "\e[32;3m=== Thank You ===\e[0m"
echo -e "\n\e[1;33m=== MySQL Information ===\e[0m"
echo -e "NOTE: If empty user, pass and DBO, we will use random generate"
read -e -p "Enter MySQL Root Username: " -i "$MYSQL_USER" MYSQL_USER
read -e -p "Enter MySQL Root Password: " -i "$MYSQL_PASSWD" MYSQL_PASSWD
read -e -p "Enter MySQL DBO Name: " -i "$MYSQL_DBO_NAME" MYSQL_DBO_NAME
echo -e "\e[32;3m=== Thank You ===\e[0m"
echo -e "\n\e[1;33m=== Apache Tomcat Port ===\e[0m"
echo -e "NOTE: If empty port number, we will use 55555"
read -e -p "Enter Tomcat Port (e.g 8080): " -i "$TC_PORT" TC_PORT
echo -e "\e[32;3m=== Thank You ===\e[0m"

if [[ $CREATE_USER == "" ]]; then
    CREATE_USER=$(usernamegen);
    echo "Using SSH user \"$CREATE_USER\""
fi

if [[ "$CREATE_USER_PASSWD" == "" ]]; then
    CREATE_USER_PASSWD=$(passwordgen);
    echo "Using SSH password \"$CREATE_USER_PASSWD\""
fi

if [[ "$MYSQL_USER" == "" ]]; then
    MYSQL_USER=$(usernamegen);
    echo "Using mysql root user \"$MYSQL_USER\""
fi

if [[ "$MYSQL_PASSWD" == "" ]]; then
    MYSQL_PASSWD=$(passwordgen);
    echo "Using mysql password \"$MYSQL_PASSWD\""
fi

if [[ "$MYSQL_DBO_NAME" == "" ]]; then
    MYSQL_DBO_NAME=$(usernamegen);
    echo "Using DBO name \"$MYSQL_DBO_NAME\""
fi

if [[ "$TC_PORT" == "" ]]; then
    TC_PORT="55555";
    echo "Using Port 55555 for TOMCAT"
fi

echo -e "\nInstalling Perfect World \e[1;33m$PW_VERSION\n\e[0mServer Domain: \e[1;33mhttp://$SVR_FQDN\n\e[0mPatcher Domain: \e[1;33mhttp://$PATCHER_FQDN\n\e[0mRegister Domain: \e[1;33mhttp://$REGISTER_FQDN\n\e[0mIP: \e[1;33m$PUBLIC_IP\e[0m"
echo -e "OS: \e[1;33m$OS $VER\e[0m"

echo -e "\n\e[1;33m=== Please sit and take coffe break, let me install PW Server $PW_VERSION for you ===\e[0m"
sleep 5
#--- Adapt repositories and packages sources
echo -e "\n\e[1;33m=== Updating repositories and packages sources ===\e[0m"

#Add MariaDB Repo
{
    echo "# MariaDB 10.X CentOS7 repository list - created $(date +%Y-%m-%d_%H.%M.%S)"
    echo "# http://downloads.mariadb.org/mariadb/repositories/"
    echo "[mariadb]"
    echo "name = MariaDB"
    echo "baseurl = $MARIADB_MIRROR"
    echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
    echo "gpgcheck=1"
} >> /etc/yum.repos.d/MariaDB.repo

{
    echo "[CodeIT]"
    echo "name=CodeIT repo"
    echo "baseurl=https://repo.codeit.guru/packages/centos/7/\$basearch"
    echo "enabled=1"
    echo "gpgkey=https://repo.codeit.guru/RPM-GPG-KEY-codeit"
    echo "gpgcheck=1"
} >> /etc/yum.repos.d/codeit.el7.repo

{
    echo "[CityFan]"
    echo "name=City Fan Repo"
    echo "baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel\$releasever/\$basearch/"
    echo "enabled=0"
    echo "gpgcheck=0"
} >> /etc/yum.repos.d/cityfan.repo

$RPM_INSTALL $EPEL_FILE
$RPM_INSTALL $REMI_FILE
#$RPM_IMPORT $WEBMIN_KEY
$RPM_IMPORT $EPEL_KEY
$RPM_IMPORT $REMI_KEY
$RPM_IMPORT $MARIADB_KEY
yum-config-manager --enable remi-php72 epel codeit cityfan

#Give Priority EPEL Repo
sed -i -e 's/\]$/\]\npriority=10/g' "/etc/yum.repos.d/"epel*
sed -i 's|priority=[0-9]\+|priority=10|' "/etc/yum.repos.d/"epel*

#Give Priority Remi
sed -i -e 's/\]$/\]\npriority=10/g' "/etc/yum.repos.d/"remi*
sed -i 's|priority=[0-9]\+|priority=10|' "/etc/yum.repos.d/"remi*

#Give Priority MariaDB
sed -i -e 's/\]$/\]\npriority=10/g' "/etc/yum.repos.d/"MariaDB*
sed -i 's|priority=[0-9]\+|priority=10|' "/etc/yum.repos.d/"MariaDB*

#Give Priority CodeIT Repo
sed -i -e 's/\]$/\]\npriority=10/g' "/etc/yum.repos.d/"codeit*
sed -i 's|priority=[0-9]\+|priority=10|' "/etc/yum.repos.d/"codeit*

#Give Priority CityFan Repo
sed -i -e 's/\]$/\]\npriority=10/g' "/etc/yum.repos.d/"cityfan*
sed -i 's|priority=[0-9]\+|priority=10|' "/etc/yum.repos.d/"cityfan*

# We need to disable SELinux...
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

#--- List all already installed packages (may help to debug)
echo -e "\n\e[1;33mListing of all packages installed:\e[0m"
rpm -qa | sort

#--- Ensures that all packages are up to date
echo -e "\n\e[1;33mUpdating+upgrading system, it may take some time...\e[0m"

$PACKAGE_CLEAN
$PACKAGE_UPGRADE
$PACKAGE_UPDATE

echo -e "\n\e[1;33m=== Installing Software Depedency ===\e[0m"
$PACKAGE_INSTALLER $SOFTWARE_PCKG_1
$PACKAGE_INSTALLER $SOFTWARE_PCKG_2
$RPM_INSTALL $WEBMIN_INSTALL
systemctl enable mariadb.service
systemctl enable httpd.service
systemctl enable php-fpm.service
chkconfig webmin on
systemctl start mariadb.service
systemctl start httpd.service
systemctl start php-fpm.service
/etc/init.d/webmin start
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Creating Special Linux Users ===\e[0m"
CREATE_USER_ENC=$(perl -e 'print crypt($ARGV[0], "password")' "$CREATE_USER_PASSWD")
useradd -m -p "$CREATE_USER_ENC" $CREATE_USER
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Extracting PW Server Package ===\e[0m"
until wget -q -O /usr/local/src/Core."$PW_VERSION".7z "$PWFILE_URL"Core."$PW_VERSION".7z; do
echo "Transfer failed, retrying in 10 seconds..."
sleep 10
done
7za x /usr/local/src/Core."$PW_VERSION".7z -o$SERVER_PATH/$CREATE_USER -y > $SERVER_PATH/$CREATE_USER/pwserver.log
rm $SERVER_PATH/$CREATE_USER/pwserver.log
rm /usr/local/src/Core."$PW_VERSION".7z
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Linking Lib ===\e[0m"
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/pkcs11.cfg /etc/pkcs11.cfg
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/authd.conf /etc/authd.conf
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/GMserver.conf /etc/GMserver.conf
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/iweb.conf /etc/iweb.conf
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/gmopgen.xml /etc/gmopgen.xml
ln -s $SERVER_PATH/$CREATE_USER/Core/etc/table.xml /etc/table.xml
ln -s $SERVER_PATH/$CREATE_USER/Core/ssl/private /etc/ssl/private
ln -s $SERVER_PATH/$CREATE_USER/Core/ssl/world2_java_gamemanager.keystore /etc/ssl/world2_java_gamemanager.keystore
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so.2 /lib/libtask.so.2
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so /lib/libtask.so
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libstdc++.so.5 /lib/libstdc++.so.5
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so /lib64/libtask.so
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so.2 /lib64/libtask.so.2
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libstdc++.so.5 /lib64/libstdc++.so.5
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libpcre.so.0 /usr/lib/libpcre.so.0
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so.2 /usr/lib/libtask.so.2
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so /usr/lib/libtask.so
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libpcre.so.0 /usr/lib64/libpcre.so.0
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so.2 /usr/lib64/libtask.so.2
ln -s $SERVER_PATH/$CREATE_USER/Core/lib/libtask.so /usr/lib64/libtask.so
sleep 1
echo -e "\n\e[32;3m=== DONE ===\e[0m"
sleep 5

#--- Prepare hostname
# In file hostname
echo "$SVR_FQDN" > /etc/hostname
old_hostname=$(cat /etc/hostname)

# In file hosts
sed -i "/127.0.1.1[\t ]*$old_hostname/d" /etc/hosts
sed -i "s|$old_hostname|$SVR_FQDN|" /etc/hosts
echo "$HOST_NAME" >> /etc/hosts

# For current session
hostname "$SVR_FQDN"

# In network file
{
    echo "NETWORKING=yes"
    echo "HOSTNAME=$SVR_FQDN"
} >> /etc/sysconfig/network
systemctl restart network.service

echo -e "\n\e[1;33m=== Configure Web Server ===\e[0m"
mkdir -p /opt/Website/conf
disable_file /etc/httpd/conf.modules.d/01-cgi.conf
disable_file /etc/httpd/conf.modules.d/00-lua.conf
disable_file /etc/httpd/conf.modules.d/00-dav.conf
sed -i -e "/LoadModule mpm_prefork_module/ s/^#*/# /" "/etc/httpd/conf.modules.d/00-mpm.conf"
sed -i -e "/#LoadModule mpm_event_module/ s/^#*//" "/etc/httpd/conf.modules.d/00-mpm.conf"
echo -e "\nInclude /opt/Website/conf/vHost.conf" >> /etc/httpd/conf/httpd.conf
sed -i -e "/Listen 80/ s/^#*/# /" "/etc/httpd/conf/httpd.conf"
sed -i -e "/AddType text\/html .php/ s/^#*/# /" "/etc/httpd/conf.d/php.conf"
sed -i -e "/DirectoryIndex index.php/q" "/etc/httpd/conf.d/php.conf"
echo -e "\n<FilesMatch \.php$>
     SetHandler \"proxy:unix:$SERVER_PATH/$CREATE_USER/run/$CREATE_USER-php56-fpm.sock|fcgi://localhost/\"
</FilesMatch>" >> /etc/httpd/conf.d/php.conf

#Add Default VHost
{
    echo "######### Default VHOST ##########"
    echo "ServerName localhost"
    echo "User $CREATE_USER"
    echo "Group $CREATE_USER"
    echo "<Directory $SERVER_PATH/$CREATE_USER/Website/html/default>"
    echo "    Options +FollowSymLinks"
    echo "    DirectoryIndex index.php"
    echo "    deny from all"
    echo "    <IfModule mod_php5.c>"
    echo "        AddType application/x-httpd-php .php"
    echo "        php_flag magic_quotes_gpc Off"
    echo "        php_flag track_vars On"
    echo "        php_flag register_globals Off"
    echo "        php_admin_value upload_tmp_dir $SERVER_PATH/$CREATE_USER/Website/temp"
    echo "    </IfModule>"
    echo "</Directory>"
    echo ""
    echo "ServerTokens Prod"
    echo "Include /opt/Website/conf/AllVhost.conf"
} >> /opt/Website/conf/vHost.conf

#Add VHost
{
    echo "######### Default VHOST $SVR_FQDN ##########"
    echo "NameVirtualHost *:80"
    echo "Listen 80"
    echo "<VirtualHost *:80>"
    echo "ServerAdmin [email protected]$SVR_FQDN"
    echo "DocumentRoot \"$SERVER_PATH/$CREATE_USER/Website/html/default\""
    echo "ServerName $SVR_FQDN"
    echo "ErrorLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$SVR_FQDN-error.log\""
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$SVR_FQDN-access.log\" combined"
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$SVR_FQDN-bandwidth.log\" common"
    echo "AddType application/x-httpd-php .php"
    echo "<Directory \"$SERVER_PATH/$CREATE_USER/Website/html/default\">"
    echo "Options +FollowSymLinks -Indexes"
    echo "    AllowOverride All"
    echo "    Order allow,deny"
    echo "    Allow from all"
    echo "    Require all granted"
    echo "</Directory>"
    echo "</VirtualHost>"
    echo ""
    echo "######### Default VHOST $REGISTER_FQDN ##########"
    echo "<virtualhost *:80>"
    echo "ServerName $REGISTER_FQDN"
    echo "ServerAdmin [email protected]$REGISTER_FQDN"
    echo "DocumentRoot \"$SERVER_PATH/$CREATE_USER/Website/html/server\""
    echo "php_admin_value open_basedir \"$SERVER_PATH/$CREATE_USER/Website/html/server:$SERVER_PATH/$CREATE_USER/Website/temp/\""
    echo "php_admin_value suhosin.executor.func.blacklist \"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\""
    echo "ErrorLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$REGISTER_FQDN-error.log\""
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$REGISTER_FQDN-access.log\" combined"
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$REGISTER_FQDN-bandwidth.log\" common"
    echo "<Directory \"$SERVER_PATH/$CREATE_USER/Website/html/server\">"
    echo "  Options +FollowSymLinks -Indexes"
    echo "  AllowOverride All"
    echo "  Order Allow,Deny"
    echo "  Allow from all"
    echo "  Require all granted"
    echo "</Directory>"
    echo "AddType application/x-httpd-php .php3 .php"
    echo "DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm"
    echo "</virtualhost>"
    echo ""
    echo "######### Default VHOST $PATCHER_FQDN ##########"
    echo "<virtualhost *:80>"
    echo "ServerName $PATCHER_FQDN"
    echo "ServerAdmin [email protected]$PATCHER_FQDN"
    echo "DocumentRoot \"$SERVER_PATH/$CREATE_USER/Website/html/patcher\""
    echo "php_admin_value open_basedir \"$SERVER_PATH/$CREATE_USER/Website/html/patcher:$SERVER_PATH/$CREATE_USER/Website/temp/\""
    echo "php_admin_value suhosin.executor.func.blacklist \"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\""
    echo "ErrorLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$PATCHER_FQDN-error.log\""
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$PATCHER_FQDN-access.log\" combined"
    echo "CustomLog \"$SERVER_PATH/$CREATE_USER/Website/logs/$PATCHER_FQDN-bandwidth.log\" common"
    echo "<Directory \"$SERVER_PATH/$CREATE_USER/Website/html/patcher\">"
    echo "  Options +FollowSymLinks -Indexes"
    echo "  AllowOverride All"
    echo "  Order Allow,Deny"
    echo "  Allow from all"
    echo "  Require all granted"
    echo "</Directory>"
    echo "AddType application/x-httpd-php .php3 .php"
    echo "DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm"
    echo "</virtualhost>"
} >> /opt/Website/conf/AllVhost.conf

#Configure FPM
rm /etc/php-fpm.d/www.conf
mkdir -p /home/$CREATE_USER/run/
chown -R $CREATE_USER:$CREATE_USER $SERVER_PATH/$CREATE_USER/run
{
    echo "[$CREATE_USER]"
    echo "user = $CREATE_USER"
    echo "group = $CREATE_USER"
    echo "listen = $SERVER_PATH/$CREATE_USER/run/$CREATE_USER-php56-fpm.sock"
    echo "listen.owner = $CREATE_USER"
    echo "listen.group = $CREATE_USER"
    echo "listen.allowed_clients = 127.0.0.1"
    echo "pm = dynamic"
    echo "pm.max_children = 5"
    echo "pm.start_servers = 2"
    echo "pm.min_spare_servers = 2"
    echo "pm.max_spare_servers = 4"
    echo "pm.max_requests = 200"
    echo "slowlog = $SERVER_PATH/$CREATE_USER/Website/logs/fpm-slow.log"
    echo "php_admin_value[error_log] = $SERVER_PATH/$CREATE_USER/Website/logs/fpm-error.log"
    echo "php_admin_flag[log_errors] = on"
    echo "php_value[session.save_handler] = files"
    echo "php_value[session.save_path]    = $SERVER_PATH/$CREATE_USER/Website/session"
    echo "php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache"
} >> /etc/php-fpm.d/$CREATE_USER.conf

sed -i "s|SERVER_NAME|$SVR_FQDN|g" "/opt/Website/conf/AllVhost.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "/opt/Website/conf/AllVhost.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "/opt/Website/conf/vHost.conf"
sed -i "s|REGISTRATION_DOMAIN|$REGISTER_FQDN|g" "/opt/Website/conf/AllVhost.conf"
sed -i "s|PATCHER_DOMAIN|$PATCHER_FQDN|g" "/opt/Website/conf/AllVhost.conf"
chown -R $CREATE_USER:$CREATE_USER $SERVER_PATH/$CREATE_USER/Website
systemctl stop mariadb.service
systemctl start mariadb.service
systemctl stop httpd.service
systemctl start httpd.service
systemctl stop php-fpm.service
systemctl start php-fpm.service
/etc/init.d/webmin start
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Setup MySQL Data Base ===\e[0m"
MY_CNF_PATH="/etc/my.cnf.d/server.cnf"
DBO_PATH="$SERVER_PATH/$CREATE_USER/MySQL/hrace009_dbo.sql"
sed -i "s|hrace009|$MYSQL_USER|g" $DBO_PATH
mysqlpassword=$(passwordgen);
mysql_dbo_user="dbo"
mysql_dbo_pass=$(passwordgen);

# setup mysql root password
mysqladmin -u root password "$mysqlpassword"

# small cleaning of mysql access
mysql -u root -p"$mysqlpassword" -e "DELETE FROM mysql.user WHERE User='root' AND Host != 'localhost'";
mysql -u root -p"$mysqlpassword" -e "DELETE FROM mysql.user WHERE User=''";
mysql -u root -p"$mysqlpassword" -e "FLUSH PRIVILEGES";

# remove test table that is no longer used
mysql -u root -p"$mysqlpassword" -e "DROP DATABASE IF EXISTS test";

# secure SELECT "hacker-code" INTO OUTFILE
sed -i "s|\[mysqld\]|&\nsecure-file-priv = /var/tmp|" $MY_CNF_PATH
sed -i "s|\[mariadb\]|&\nsecure-file-priv = /var/tmp|" "/etc/my.cnf.d/server.cnf"
sed -i "s|\[mariadb-10.1\]|&\nsecure-file-priv = /var/tmp|" "/etc/my.cnf.d/server.cnf"

#setup DBO
mysql -u root -p"$mysqlpassword" -e "CREATE DATABASE $MYSQL_DBO_NAME"
mysql -u root -p"$mysqlpassword" "$MYSQL_DBO_NAME" < "$DBO_PATH"
rm -R $SERVER_PATH/$CREATE_USER/MySQL

#Create MYSQL ADMIN USER and Grant All Access like root from all Host
mysql -u root -p"$mysqlpassword" -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWD'";
mysql -u root -p"$mysqlpassword" -e "GRANT GRANT OPTION ON *.* TO '$MYSQL_USER'@'%'";
mysql -u root -p"$mysqlpassword" -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO '$MYSQL_USER'@'%'";
mysql -u root -p"$mysqlpassword" -e "FLUSH PRIVILEGES";

#Create MYSQL DBO Perfect World
mysql -u root -p"$mysqlpassword" -e "CREATE USER '$mysql_dbo_user'@'localhost' IDENTIFIED BY '$mysql_dbo_pass'";
mysql -u root -p"$mysqlpassword" -e "GRANT SELECT ON *.* TO '$mysql_dbo_user'@'localhost'";
mysql -u root -p"$mysqlpassword" -e "GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, TRIGGER, CREATE VIEW, SHOW VIEW, EXECUTE, ALTER ROUTINE, CREATE ROUTINE, CREATE TEMPORARY TABLES, LOCK TABLES, EVENT ON $MYSQL_DBO_NAME.* TO '$mysql_dbo_user'@'localhost'";
mysql -u root -p"$mysqlpassword" -e "GRANT GRANT OPTION ON $MYSQL_DBO_NAME.* TO '$mysql_dbo_user'@'localhost'";
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Configure PW Admin ===\e[0m"
hashpassword=$(echo -n "$CREATE_USER_PASSWD"| md5sum | awk '{print $1}')
sed -i "s|DB_HOST|localhost|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|DB_USER|$mysql_dbo_user|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|DB_PASSWORD|$mysql_dbo_pass|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|DB_NAME|$MYSQL_DBO_NAME|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|PW_PATH|$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|MD5_PASSWORD|$hashpassword|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp"
sed -i "s|PWCATALINA|$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/tomcat"
sed -i "s|USER_PROCES_PW|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/serverctrl.jsp"
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Configure Apache Tomcat ===\e[0m"
sed -i "s|TC_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/conf/tomcat-users.xml"
sed -i "s|TC_PASSWORD|$CREATE_USER_PASSWD|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/conf/tomcat-users.xml"
sed -i "s|TC_PORT|$TC_PORT|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/conf/server.xml"
chmod 750 $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/tomcat
ln -s $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/apache-tomcat-7.0.32/tomcat /etc/init.d/tomcat
chkconfig tomcat on
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Configure AUTH ===\e[0m"
sed -i "s|DB_HOST|localhost|g" "$SERVER_PATH/$CREATE_USER/Core/etc/table.xml"
sed -i "s|DB_NAME|$MYSQL_DBO_NAME|g" "$SERVER_PATH/$CREATE_USER/Core/etc/table.xml"
sed -i "s|DB_USER|$mysql_dbo_user|g" "$SERVER_PATH/$CREATE_USER/Core/etc/table.xml"
sed -i "s|DB_PASSWORD|$mysql_dbo_pass|g" "$SERVER_PATH/$CREATE_USER/Core/etc/table.xml"
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Configure PW Path ===\e[0m"
sed -i "s|USER_PROCESS|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start"
sed -i "s|USER_GROUP|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start_Mini"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Stop"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/authd/build/authd"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamed/gs.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamed/gs_rollback.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamed/gsalias.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamedbd/cashstat.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamedbd/fix.sh"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamedbd/gamesys.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gdeliveryd/gamesys.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gfactiond/gamesys.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gfactiond/gamesys.conf.central"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/glinkd/gamesys.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/logservice/logservice.conf"
sed -i "s|CREATE_USER|$CREATE_USER|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/uniquenamed/gamesys.conf"
if  [[ "$VER" = "7" ]]; then
    sed -i "s|COMMAND_HTTPD|\"systemctl start httpd.service\"|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start"
    sed -i "s|COMMAND_HTTPD|\"systemctl stop httpd.service\"|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Stop"
else
    sed -i "s|COMMAND_HTTPD|\"/etc/init.d/httpd start\"|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Start"
    sed -i "s|COMMAND_HTTPD|\"/etc/init.d/httpd stop\"|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/Stop"
fi
echo -e "\n\e[32;3m=== DONE ===\e[0m"

echo -e "\n\e[1;33m=== Configure GLINKD ===\e[0m"
sed -i "s|PUBLIC_IP|$PUBLIC_IP|g" "$SERVER_PATH/$CREATE_USER/Core/Wanmei2015/glinkd/gamesys.conf"
echo -e "\n\e[32;3m=== DONE ===\e[0m"

if  [[ "$VER" = "7" ]]; then
    systemctl stop mariadb.service
    systemctl start mariadb.service
    systemctl stop php-fpm.service
    systemctl start php-fpm.service
    systemctl stop httpd.service
    systemctl start httpd.service
else
    /etc/init.d/mysql restart
    /etc/init.d/php-fpm restart
    /etc/init.d/httpd restart
fi
/etc/init.d/webmin restart

echo -e "\n\e[1;33m=== Setup Firewall ===\e[0m"
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 10000 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 29000 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport $TC_PORT -m state --state NEW -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -j DROP
iptables -A FORWARD -j REJECT --reject-with icmp-host-prohibited
service iptables save
systemctl stop iptables.service
systemctl start iptables.service
systemctl enable iptables.service
echo -e "\n\e[32;3m=== DONE ===\e[0m"
echo ""
echo -e "\n\e[1;33m=== Setup File Permision ===\e[0m"
chmod -R 750 /home/$CREATE_USER/Core
chmod -R 750 /home/$CREATE_USER/Website
chown -R $CREATE_USER:$CREATE_USER /home/$CREATE_USER
echo -e "\n\e[32;3m=== DONE ===\e[0m"
echo ""
#--- Store the passwords for user reference
{
    echo "Please Visit: https://www.hrace009.com for more information"
    echo ""
    echo "Common Details"
    echo "=============="
    echo "Server IP address: $PUBLIC_IP"
    echo "Server URL: http://$SVR_FQDN"
    echo "Patcher URL: http://$PATCHER_FQDN"
    echo "Register URL: http://$REGISTER_FQDN"
    echo "Webmin URL: https://$SVR_FQDN:10000"
    echo ""
    echo "Database Details"
    echo "================"
    echo "MySQL Root User: $MYSQL_USER"
    echo "MySQL Root Password: $MYSQL_PASSWD"
    echo "MySQL PW DB User: $mysql_dbo_user"
    echo "MySQL PW DB Password: $mysql_dbo_pass"
    echo "MySQL Remote Port: 3306"
    echo ""
    echo "SSH Details"
    echo "==========="
    echo "SSH User: $CREATE_USER"
    echo "SSH User Password: $CREATE_USER_PASSWD"
    echo ""
    echo "PW Admin Details"
    echo "================"
    echo "PW Admin Password: $CREATE_USER_PASSWD"
    echo "PW Admin URL: http://$PUBLIC_IP:$TC_PORT/Admin_Control1/"
    echo ""
    echo "iWeb Details"
    echo "============"
    echo "Iweb URL: http://$PUBLIC_IP:$TC_PORT/iweb/"
    echo "iWeb User Name: $CREATE_USER-iweb"
    echo "iWeb Password: $CREATE_USER_PASSWD"
    echo ""
    echo "Developer Information"
    echo "====================="
    echo "Root PW Server Path: $SERVER_PATH/$CREATE_USER"
    echo "PW Server Path: $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/"
    echo "All Element data path: $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamed/config/ELEMENTS"
    echo ""
    echo "Website Development Information"
    echo "==============================="
    echo "Default Path: $SERVER_PATH/$CREATE_USER/Website/default"
    echo "Patcher Path: $SERVER_PATH/$CREATE_USER/Website/patcher"
    echo "API/Register Path: $SERVER_PATH/$CREATE_USER/Website/server"
} >> /root/Installation_Document.txt

#--- Advise the admin that PW SERVER is now installed and accessible.
{
echo "###########################################################"
echo " Congratulations hrace009 Perfect World $PW_VERSION"
echo " has now been installed on your server. "
echo " Please review the log file left in /root/ for "
echo " any errors encountered during installation."
echo "###########################################################"
echo "Please Visit: https://www.hrace009.com for more information"
echo "###########################################################"
echo ""
echo -e "\e[1;33mCommon Details\e[0m"
echo -e "\e[1;33m==============\e[0m"
echo "Server IP address: $PUBLIC_IP"
echo "Server URL: http://$SVR_FQDN"
echo "Patcher URL: http://$PATCHER_FQDN"
echo "Register URL: http://$REGISTER_FQDN"
echo "Webmin URL: https://$SVR_FQDN:10000"
echo ""
echo -e "\e[1;33mDatabase Details\e[0m"
echo -e "\e[1;33m================\e[0m"
echo "MySQL Root User: $MYSQL_USER"
echo "MySQL Root Password: $MYSQL_PASSWD"
echo "MySQL PW DB User: $mysql_dbo_user"
echo "MySQL PW DB Password: $mysql_dbo_pass"
echo "MySQL Remote Port: 3306"
echo ""
echo -e "\e[1;33mSSH Details\e[0m"
echo -e "\e[1;33m===========\e[0m"
echo "SSH User: $CREATE_USER"
echo "SSH User Password: $CREATE_USER_PASSWD"
echo ""
echo -e "\e[1;33mPW Admin Details\e[0m"
echo -e "\e[1;33m================\e[0m"
echo "PW Admin Password: $CREATE_USER_PASSWD"
echo "PW Admin URL: http://$PUBLIC_IP:$TC_PORT/Admin_Control1/"
echo ""
echo -e "\e[1;33miWeb Details\e[0m"
echo -e "\e[1;33m============\e[0m"
echo "Iweb URL: http://$PUBLIC_IP:$TC_PORT/iweb/"
echo "iWeb User Name: $CREATE_USER-iweb"
echo "iWeb Password: $CREATE_USER_PASSWD"
echo ""
echo -e "\e[1;33mDeveloper Information\e[0m"
echo -e "\e[1;33m=====================\e[0m"
echo "Root PW Server Path: $SERVER_PATH/$CREATE_USER"
echo "PW Server Path: $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/"
echo "All Element data path: $SERVER_PATH/$CREATE_USER/Core/Wanmei2015/gamed/config/ELEMENTS"
echo ""
echo -e "\e[1;33mWebsite Development Information\e[0m"
echo -e "\e[1;33m===============================\e[0m"
echo "Default Path: $SERVER_PATH/$CREATE_USER/Website/default"
echo "Patcher Path: $SERVER_PATH/$CREATE_USER/Website/patcher"
echo "API/Register Path: $SERVER_PATH/$CREATE_USER/Website/server"
echo ""
echo -e "\e[1;33m#####################################################################\e[0m"
echo -e "\e[1;33m (theses documentation are saved in /root/Installation_Document.txt)\e[0m"
echo -e "\e[1;33m#####################################################################\e[0m"
echo ""
} &>/dev/tty
shutdown -r now[/C
Seems like after the installation i'm unable to access to any services
  1. pwAdmin
  2. iWeb
  3. Webmin
  4. MySql
Installation Document is as bellow

Code:
Please Visit: https://www.hrace009.com for more information

Common Details
==============
Server IP address: 134.x.x.x
Server URL: http://game.testx0x0xpw.ml
Patcher URL: http://patcher.testx0x0xpw.ml
Register URL: http://api.testx0x0xpw.com
Webmin URL: https://game.testx0x0xpw.ml:10000

Database Details
================
MySQL Root User: sqluser
MySQL Root Password: [email protected]
MySQL PW DB User: dbo
MySQL PW DB Password: MbASDf5lASDo4ASASDA
MySQL Remote Port: 3306

SSH Details
===========
SSH User: Amith
SSH User Password: [email protected]

PW Admin Details
================
PW Admin Password: [email protected]
PW Admin URL: http://134.x.x.x:55555/Admin_Control1/

iWeb Details
============
Iweb URL: http://134.x.x.x:55555/iweb/
iWeb User Name: amith-iweb
iWeb Password: [email protected]

Developer Information
=====================
Root PW Server Path: /home/amith
PW Server Path: /home/roman/Core/Wanmei2015/
All Element data path: /home/amith/Core/Wanmei2015/gamed/config/ELEMENTS

Website Development Information
===============================
Default Path: /home/amith/Website/default
Patcher Path: /home/amith/Website/patcher
API/Register Path: /home/amith/Website/server
Installation Log

Code:
Preparing to select timezone, please wait a few seconds...


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan           18) Israel                35) Palestine
 2) Armenia               19) Japan                 36) Philippines
 3) Azerbaijan            20) Jordan                37) Qatar
 4) Bahrain               21) Kazakhstan            38) Russia
 5) Bangladesh            22) Korea (North)         39) Saudi Arabia
 6) Bhutan                23) Korea (South)         40) Singapore
 7) Brunei                24) Kuwait                41) Sri Lanka
 8) Cambodia              25) Kyrgyzstan            42) Syria
 9) China                 26) Laos                  43) Taiwan
10) Cyprus                27) Lebanon               44) Tajikistan
11) East Timor            28) Macau                 45) Thailand
12) Georgia               29) Malaysia              46) Turkmenistan
13) Hong Kong             30) Mongolia              47) United Arab Emirates
14) India                 31) Myanmar (Burma)       48) Uzbekistan
15) Indonesia             32) Nepal                 49) Vietnam
16) Iran                  33) Oman                  50) Yemen
17) Iraq                  34) Pakistan
#? 41

The following information has been given:

        Sri Lanka

Therefore TZ='Asia/Colombo' will be used.
Local time is now:      Sun May 10 15:15:53 +0530 2020.
Universal Time is now:  Sun May 10 09:45:53 UTC 2020.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
        TZ='Asia/Colombo'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Colombo

=== Informations required to build your server ===
The installer requires 6 pieces of information:
 1) the GLINK Domain that you want to use for client access on port 29000,
   - do not use your main domain (like domain.com)
   - use a sub-domain, e.g pwserver.domain.com
   - or use the server hostname, e.g server1.domain.com
   - DNS must already be configured and pointing to the server IP
 2) the Patcher Domain that you want to use for Auto Patcher on port 80,
   - do not use your main domain (like domain.com)
   - use a sub-domain, e.g patcher.domain.com
   - or use the server hostname, e.g server2.domain.com
   - DNS must already be configured and pointing to the server IP
 3) the API Domain that you want to use for API communication on port 80,
   - do not use your main domain (like domain.com)
   - use a sub-domain, e.g api.domain.com
   - or use the server hostname, e.g server1.domain.com
   - DNS must already be configured and pointing to the server IP
 4) Special user for your PW Server.
 5) MySQL Admin User and Password for MySQL (DO NOT USE ROOT USER).
 6) The public IP of the server.


Enter your GLINK Domain e.g game.mypw.com
GLINK Domain PW Server: game.testx0x0xpw.ml
Enter your Patcher Domain e.g patcher.mypw.com
Patcher Domain PW Server: patcher.testx0x0xpw.ml
Enter your API Domain e.g api.mypw.com
API Domain PW Server: api.testx0x0xpw.com

The public IP of the server is 134.x.x.x.
The local IP is 134.x.x.x
10.47.0.5
For a production server, the PUBLIC IP must be used.
For a development server, the LOCAL IP must be used.
Enter (or confirm) the public IP for this server: 134.x.x.x

./1.sh: line 280: host: command not found
WARNING: game.testx0x0xpw.ml is not defined in your DNS!
  You must add records in your DNS manager (and then wait until propagation is done).
  If this is a production installation, set the DNS up as soon as possible.
  If this is a development installation, you can ignore this warning.
./1.sh: line 299: host: command not found
WARNING: patcher.testx0x0xpw.ml is not defined in your DNS!
  You must add records in your DNS manager (and then wait until propagation is done).
  If this is a production installation, set the DNS up as soon as possible.
  If this is a development installation, you can ignore this warning.
./1.sh: line 318: host: command not found
WARNING: api.testx0x0xpw.com is not defined in your DNS!
  You must add records in your DNS manager (and then wait until propagation is done).
  If this is a production installation, set the DNS up as soon as possible.
  If this is a development installation, you can ignore this warning.

There are some warnings...
Are you really sure that you want to setup PW Server with these parameters?
(y):Accept and install, (n):Change domain or IP, (q):Quit installer? y

=== Special User Information ===
NOTE: If empty user and pass, we will use random generate
Enter OS Username: amith
Enter OS Password: [email protected]
=== Thank You ===

=== MySQL Information ===
NOTE: If empty user, pass and DBO, we will use random generate
Enter MySQL Root Username: sqluser
Enter MySQL Root Password: [email protected]
Enter MySQL DBO Name: amith
=== Thank You ===

=== Apache Tomcat Port ===
NOTE: If empty port number, we will use 55555
Enter Tomcat Port (e.g 8080): 55555
=== Thank You ===

Installing Perfect World 1.5.5
Server Domain: http://game.testx0x0xpw.ml
Patcher Domain: http://patcher.testx0x0xpw.ml
Register Domain: http://api.testx0x0xpw.com
IP: 134.x.x.x
OS: CentOs 7

=== Please sit and take coffe break, let me install PW Server 1.5.5 for you ===

=== Updating repositories and packages sources ===
warning: /var/tmp/rpm-tmp.J6ttkj: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Preparing...                          ########################################
Updating / installing...
epel-release-7-12                     ########################################
warning: /var/tmp/rpm-tmp.VSDBUq: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Preparing...                          ########################################
Updating / installing...
remi-release-7.7-2.el7.remi           ########################################
Loaded plugins: fastestmirror
Traceback (most recent call last):
  File "/usr/bin/yum-config-manager", line 180, in <module>
    repos = yb.repos.findRepos(','.join(args),
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1071, in <lambda>
    repos = property(fget=lambda self: self._getRepos(),
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 694, in _getRepos
    self.getReposFromConfig()
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 567, in getReposFromConfig
    self.getReposFromConfigFile(repofn, repo_age=thisrepo_age)
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 465, in getReposFromConfigFile
    raise Errors.ConfigError(exception2msg(e))
yum.Errors.ConfigError: File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'

Listing of all packages installed:
acl-2.2.51-15.el7.x86_64
audit-2.8.5-4.el7.x86_64
audit-libs-2.8.5-4.el7.x86_64
audit-libs-python-2.8.5-4.el7.x86_64
authconfig-6.2.8-30.el7.x86_64
basesystem-10.0-7.el7.centos.noarch
bash-4.2.46-34.el7.x86_64
bind-export-libs-9.11.4-16.P2.el7_8.2.x86_64
bind-libs-lite-9.11.4-16.P2.el7_8.2.x86_64
bind-license-9.11.4-16.P2.el7_8.2.noarch
binutils-2.27-43.base.el7.x86_64
btrfs-progs-4.9.1-1.el7.x86_64
bzip2-libs-1.0.6-13.el7.x86_64
ca-certificates-2019.2.32-76.el7_7.noarch
centos-release-7-8.2003.0.el7.centos.x86_64
checkpolicy-2.5-8.el7.x86_64
chkconfig-1.7.4-1.el7.x86_64
chrony-3.4-1.el7.x86_64
cloud-init-18.5-6.el7.centos.x86_64
cloud-utils-growpart-0.29-5.el7.noarch
coreutils-8.22-24.el7.x86_64
cpio-2.11-27.el7.x86_64
cracklib-2.9.0-11.el7.x86_64
cracklib-dicts-2.9.0-11.el7.x86_64
cronie-1.4.11-23.el7.x86_64
cronie-anacron-1.4.11-23.el7.x86_64
crontabs-1.11-6.20121102git.el7.noarch
cryptsetup-libs-2.0.3-6.el7.x86_64
curl-7.29.0-57.el7.x86_64
cyrus-sasl-lib-2.1.26-23.el7.x86_64
dbus-1.10.24-13.el7_6.x86_64
dbus-glib-0.100-7.el7.x86_64
dbus-libs-1.10.24-13.el7_6.x86_64
dbus-python-1.1.1-9.el7.x86_64
device-mapper-1.02.164-7.el7_8.1.x86_64
device-mapper-libs-1.02.164-7.el7_8.1.x86_64
dhclient-4.2.5-79.el7.centos.x86_64
dhcp-common-4.2.5-79.el7.centos.x86_64
dhcp-libs-4.2.5-79.el7.centos.x86_64
diffutils-3.3-5.el7.x86_64
dmidecode-3.2-3.el7.x86_64
do-agent-3.5.6-1.x86_64
dracut-033-568.el7.x86_64
dracut-config-generic-033-568.el7.x86_64
dracut-config-rescue-033-568.el7.x86_64
dracut-network-033-568.el7.x86_64
e2fsprogs-1.42.9-17.el7.x86_64
e2fsprogs-libs-1.42.9-17.el7.x86_64
elfutils-default-yama-scope-0.176-4.el7.noarch
elfutils-libelf-0.176-4.el7.x86_64
elfutils-libs-0.176-4.el7.x86_64
epel-release-7-12.noarch
ethtool-4.8-10.el7.x86_64
expat-2.1.0-11.el7.x86_64
file-5.11-36.el7.x86_64
file-libs-5.11-36.el7.x86_64
filesystem-3.2-25.el7.x86_64
findutils-4.5.11-6.el7.x86_64
fipscheck-1.4.1-6.el7.x86_64
fipscheck-lib-1.4.1-6.el7.x86_64
freetype-2.8-14.el7.x86_64
gawk-4.0.2-4.el7_3.1.x86_64
gdbm-1.10-8.el7.x86_64
GeoIP-1.5.0-14.el7.x86_64
geoipupdate-2.5.0-1.el7.x86_64
gettext-0.19.8.1-3.el7.x86_64
gettext-libs-0.19.8.1-3.el7.x86_64
glib2-2.56.1-5.el7.x86_64
glibc-2.17-307.el7.1.x86_64
glibc-common-2.17-307.el7.1.x86_64
gmp-6.0.0-15.el7.x86_64
gnupg2-2.0.22-5.el7_5.x86_64
gobject-introspection-1.56.1-1.el7.x86_64
gpgme-1.3.2-5.el7.x86_64
gpg-pubkey-00f97f56-467e318a
gpg-pubkey-11f63c51-3c7dc11d
gpg-pubkey-1bb943db-511147a9
gpg-pubkey-352c64e5-52ae6884
gpg-pubkey-a4c6383f-56c4b467
gpg-pubkey-f4a80eb5-53a7ff4b
grep-2.20-3.el7.x86_64
groff-base-1.22.2-8.el7.x86_64
grub2-2.02-0.81.el7.centos.x86_64
grub2-common-2.02-0.81.el7.centos.noarch
grub2-pc-2.02-0.81.el7.centos.x86_64
grub2-pc-modules-2.02-0.81.el7.centos.noarch
grub2-tools-2.02-0.81.el7.centos.x86_64
grub2-tools-extra-2.02-0.81.el7.centos.x86_64
grub2-tools-minimal-2.02-0.81.el7.centos.x86_64
grubby-8.28-26.el7.x86_64
gssproxy-0.7.0-28.el7.x86_64
gzip-1.5-10.el7.x86_64
hardlink-1.0-19.el7.x86_64
hostname-3.13-3.el7_7.1.x86_64
hwdata-0.252-9.5.el7.x86_64
info-5.1-5.el7.x86_64
initscripts-9.49.49-1.el7.x86_64
iproute-4.11.0-25.el7_7.2.x86_64
iptables-1.4.21-34.el7.x86_64
iputils-20160308-10.el7.x86_64
irqbalance-1.0.7-12.el7.x86_64
iwl7260-firmware-25.30.13.0-76.el7.noarch
jansson-2.10-1.el7.x86_64
json-c-0.11-4.el7_0.x86_64
kbd-1.15.5-15.el7.x86_64
kbd-legacy-1.15.5-15.el7.noarch
kbd-misc-1.15.5-15.el7.noarch
kernel-3.10.0-1127.el7.x86_64
kernel-3.10.0-957.27.2.el7.x86_64
kernel-tools-3.10.0-1127.el7.x86_64
kernel-tools-libs-3.10.0-1127.el7.x86_64
kexec-tools-2.0.15-43.el7.x86_64
keyutils-1.5.8-3.el7.x86_64
keyutils-libs-1.5.8-3.el7.x86_64
kmod-20-28.el7.x86_64
kmod-libs-20-28.el7.x86_64
kpartx-0.4.9-131.el7.x86_64
krb5-libs-1.15.1-46.el7.x86_64
less-458-9.el7.x86_64
libacl-2.2.51-15.el7.x86_64
libassuan-2.1.0-3.el7.x86_64
libattr-2.4.46-13.el7.x86_64
libbasicobjects-0.1.1-32.el7.x86_64
libblkid-2.23.2-63.el7.x86_64
libcap-2.22-11.el7.x86_64
libcap-ng-0.7.5-4.el7.x86_64
libcgroup-0.41-21.el7.x86_64
libcollection-0.7.0-32.el7.x86_64
libcom_err-1.42.9-17.el7.x86_64
libcroco-0.6.12-4.el7.x86_64
libcurl-7.29.0-57.el7.x86_64
libdaemon-0.14-7.el7.x86_64
libdb-5.3.21-25.el7.x86_64
libdb-utils-5.3.21-25.el7.x86_64
libedit-3.0-12.20121213cvs.el7.x86_64
libestr-0.1.9-2.el7.x86_64
libevent-2.0.21-4.el7.x86_64
libfastjson-0.99.4-3.el7.x86_64
libffi-3.0.13-19.el7.x86_64
libgcc-4.8.5-39.el7.x86_64
libgcrypt-1.5.3-14.el7.x86_64
libgomp-4.8.5-39.el7.x86_64
libgpg-error-1.12-3.el7.x86_64
libidn-1.28-4.el7.x86_64
libini_config-1.3.1-32.el7.x86_64
libmnl-1.0.3-7.el7.x86_64
libmount-2.23.2-63.el7.x86_64
libndp-1.2-9.el7.x86_64
libnetfilter_conntrack-1.0.6-1.el7_3.x86_64
libnfnetlink-1.0.1-4.el7.x86_64
libnfsidmap-0.25-19.el7.x86_64
libnl3-3.2.28-4.el7.x86_64
libnl3-cli-3.2.28-4.el7.x86_64
libpath_utils-0.2.1-32.el7.x86_64
libpipeline-1.2.3-3.el7.x86_64
libpng-1.5.13-7.el7_2.x86_64
libpwquality-1.2.3-5.el7.x86_64
libref_array-0.1.5-32.el7.x86_64
libseccomp-2.3.1-4.el7.x86_64
libselinux-2.5-15.el7.x86_64
libselinux-python-2.5-15.el7.x86_64
libselinux-utils-2.5-15.el7.x86_64
libsemanage-2.5-14.el7.x86_64
libsemanage-python-2.5-14.el7.x86_64
libsepol-2.5-10.el7.x86_64
libsmartcols-2.23.2-63.el7.x86_64
libss-1.42.9-17.el7.x86_64
libssh2-1.8.0-3.el7.x86_64
libstdc++-4.8.5-39.el7.x86_64
libsysfs-2.1.0-16.el7.x86_64
libtasn1-4.10-1.el7.x86_64
libteam-1.29-1.el7.x86_64
libtirpc-0.2.4-0.16.el7.x86_64
libunistring-0.9.3-9.el7.x86_64
libuser-0.60-9.el7.x86_64
libutempter-1.1.6-4.el7.x86_64
libuuid-2.23.2-63.el7.x86_64
libverto-0.2.5-4.el7.x86_64
libverto-libevent-0.2.5-4.el7.x86_64
libxml2-2.9.1-6.el7.4.x86_64
libxml2-python-2.9.1-6.el7.4.x86_64
libyaml-0.1.4-11.el7_0.x86_64
linux-firmware-20191203-76.gite8a0f4c.el7.noarch
logrotate-3.8.6-19.el7.x86_64
lshw-B.02.18-14.el7.x86_64
lua-5.1.4-15.el7.x86_64
lz4-1.7.5-3.el7.x86_64
lzo-2.06-8.el7.x86_64
make-3.82-24.el7.x86_64
man-db-2.6.3-11.el7.x86_64
mariadb-libs-5.5.65-1.el7.x86_64
microcode_ctl-2.1-61.el7.x86_64
mozjs17-17.0.0-20.el7.x86_64
ncurses-5.9-14.20130511.el7_4.x86_64
ncurses-base-5.9-14.20130511.el7_4.noarch
ncurses-libs-5.9-14.20130511.el7_4.x86_64
net-tools-2.0-0.25.20131004git.el7.x86_64
newt-0.52.15-4.el7.x86_64
newt-python-0.52.15-4.el7.x86_64
nfs-utils-1.3.0-0.66.el7.x86_64
nspr-4.21.0-1.el7.x86_64
nss-3.44.0-7.el7_7.x86_64
nss-pem-1.0.3-7.el7.x86_64
nss-softokn-3.44.0-8.el7_7.x86_64
nss-softokn-freebl-3.44.0-8.el7_7.x86_64
nss-sysinit-3.44.0-7.el7_7.x86_64
nss-tools-3.44.0-7.el7_7.x86_64
nss-util-3.44.0-4.el7_7.x86_64
numactl-libs-2.0.12-5.el7.x86_64
openldap-2.4.44-21.el7_6.x86_64
openssh-7.4p1-21.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
openssl-1.0.2k-19.el7.x86_64
openssl-libs-1.0.2k-19.el7.x86_64
os-prober-1.58-9.el7.x86_64
p11-kit-0.23.5-3.el7.x86_64
p11-kit-trust-0.23.5-3.el7.x86_64
pam-1.1.8-23.el7.x86_64
parted-3.1-32.el7.x86_64
passwd-0.79-6.el7.x86_64
pciutils-libs-3.5.1-3.el7.x86_64
pcre-8.32-17.el7.x86_64
perl-5.16.3-295.el7.x86_64
perl-Carp-1.26-244.el7.noarch
perl-constant-1.27-2.el7.noarch
perl-Encode-2.51-7.el7.x86_64
perl-Exporter-5.68-3.el7.noarch
perl-File-Path-2.09-2.el7.noarch
perl-File-Temp-0.23.01-3.el7.noarch
perl-Filter-1.49-3.el7.x86_64
perl-Getopt-Long-2.40-3.el7.noarch
perl-HTTP-Tiny-0.033-3.el7.noarch
perl-IO-Tty-1.10-11.el7.x86_64
perl-libs-5.16.3-295.el7.x86_64
perl-macros-5.16.3-295.el7.x86_64
perl-Net-SSLeay-1.55-6.el7.x86_64
perl-parent-0.225-244.el7.noarch
perl-PathTools-3.40-5.el7.x86_64
perl-Pod-Escapes-1.04-295.el7.noarch
perl-podlators-2.5.1-3.el7.noarch
perl-Pod-Perldoc-3.20-4.el7.noarch
perl-Pod-Simple-3.28-4.el7.noarch
perl-Pod-Usage-1.63-3.el7.noarch
perl-Scalar-List-Utils-1.27-248.el7.x86_64
perl-Socket-2.010-5.el7.x86_64
perl-Storable-2.45-3.el7.x86_64
perl-Text-ParseWords-3.29-4.el7.noarch
perl-threads-1.87-4.el7.x86_64
perl-threads-shared-1.43-6.el7.x86_64
perl-Time-HiRes-1.9725-3.el7.x86_64
perl-Time-Local-1.2300-2.el7.noarch
pinentry-0.8.1-17.el7.x86_64
pkgconfig-0.27.1-4.el7.x86_64
policycoreutils-2.5-34.el7.x86_64
policycoreutils-python-2.5-34.el7.x86_64
polkit-0.112-26.el7.x86_64
polkit-pkla-compat-0.1-4.el7.x86_64
popt-1.13-16.el7.x86_64
postfix-2.10.1-9.el7.x86_64
procps-ng-3.3.10-27.el7.x86_64
pth-2.0.7-23.el7.x86_64
pygpgme-0.3-9.el7.x86_64
pyliblzma-0.5.3-11.el7.x86_64
pyserial-2.6-6.el7.noarch
python-2.7.5-88.el7.x86_64
python-babel-0.9.6-8.el7.noarch
python-backports-1.0-8.el7.x86_64
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
python-chardet-2.2.1-3.el7.noarch
python-configobj-4.7.2-7.el7.noarch
python-decorator-3.4.0-3.el7.noarch
python-gobject-base-3.22.0-1.el7_4.1.x86_64
python-iniparse-0.4-9.el7.noarch
python-ipaddress-1.0.16-2.el7.noarch
python-IPy-0.75-6.el7.noarch
python-jinja2-2.7.2-4.el7.noarch
python-jsonpatch-1.2-4.el7.noarch
python-jsonpointer-1.9-2.el7.noarch
python-kitchen-1.1.1-5.el7.noarch
python-libs-2.7.5-88.el7.x86_64
python-linux-procfs-0.4.11-4.el7.noarch
python-markupsafe-0.11-10.el7.x86_64
python-perf-3.10.0-1127.el7.x86_64
python-prettytable-0.7.2-3.el7.noarch
python-pycurl-7.19.0-19.el7.x86_64
python-pyudev-0.15-9.el7.noarch
python-requests-2.6.0-9.el7_8.noarch
python-schedutils-0.4-6.el7.x86_64
python-setuptools-0.9.8-7.el7.noarch
python-six-1.9.0-2.el7.noarch
python-urlgrabber-3.10-10.el7.noarch
python-urllib3-1.10.2-7.el7.noarch
pyxattr-0.5.1-5.el7.x86_64
PyYAML-3.10-11.el7.x86_64
qemu-guest-agent-2.12.0-3.el7.x86_64
qrencode-libs-3.4.1-3.el7.x86_64
quota-4.01-19.el7.x86_64
quota-nls-4.01-19.el7.noarch
readline-6.2-11.el7.x86_64
remi-release-7.7-2.el7.remi.noarch
rootfiles-8.1-11.el7.noarch
rpcbind-0.2.0-49.el7.x86_64
rpm-4.11.3-43.el7.x86_64
rpm-build-libs-4.11.3-43.el7.x86_64
rpm-libs-4.11.3-43.el7.x86_64
rpm-python-4.11.3-43.el7.x86_64
rsync-3.1.2-10.el7.x86_64
rsyslog-8.24.0-52.el7.x86_64
sed-4.2.2-6.el7.x86_64
selinux-policy-3.13.1-266.el7.noarch
selinux-policy-targeted-3.13.1-266.el7.noarch
setools-libs-3.3.8-4.el7.x86_64
setup-2.8.71-11.el7.noarch
sg3_utils-1.37-19.el7.x86_64
sg3_utils-libs-1.37-19.el7.x86_64
shadow-utils-4.6-5.el7.x86_64
shared-mime-info-1.8-5.el7.x86_64
slang-2.2.4-11.el7.x86_64
snappy-1.1.0-3.el7.x86_64
sqlite-3.7.17-8.el7_7.1.x86_64
sudo-1.8.23-9.el7.x86_64
systemd-219-73.el7_8.5.x86_64
systemd-libs-219-73.el7_8.5.x86_64
systemd-sysv-219-73.el7_8.5.x86_64
sysvinit-tools-2.88-14.dsf.el7.x86_64
tar-1.26-35.el7.x86_64
tcp_wrappers-7.6-77.el7.x86_64
tcp_wrappers-libs-7.6-77.el7.x86_64
teamd-1.29-1.el7.x86_64
tuned-2.11.0-8.el7.noarch
tzdata-2020a-1.el7.noarch
ustr-1.0.4-16.el7.x86_64
util-linux-2.23.2-63.el7.x86_64
vim-minimal-7.4.629-6.el7.x86_64
virt-what-1.18-4.el7.x86_64
webmin-1.941-1.noarch
wget-1.14-18.el7_6.1.x86_64
which-2.20-7.el7.x86_64
wpa_supplicant-2.6-12.el7.x86_64
xfsprogs-4.5.0-20.el7.x86_64
xz-5.2.2-1.el7.x86_64
xz-libs-5.2.2-1.el7.x86_64
yum-3.4.3-167.el7.centos.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-53.el7.noarch
yum-utils-1.1.31-53.el7.noarch
zlib-1.2.7-18.el7.x86_64

Updating+upgrading system, it may take some time...


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'

=== Installing Software Depedency ===


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'


File contains no section headers.
file: file:///etc/yum.repos.d/webmin.repo, line: 1
'me=Webmin Distribution Neutral\n'
error: Failed dependencies:
        perl(Encode::Detect) is needed by webmin-1.941-1.noarch
        perl(Data::Dumper) is needed by webmin-1.941-1.noarch
        unzip is needed by webmin-1.941-1.noarch
Retrieving http://www.webmin.com/download/rpm/webmin-current.rpm
Failed to execute operation: No such file or directory
Failed to execute operation: No such file or directory
Failed to execute operation: No such file or directory
Failed to start mariadb.service: Unit not found.
Failed to start httpd.service: Unit not found.
Failed to start php-fpm.service: Unit not found.

=== DONE ===

=== Creating Special Linux Users ===

=== DONE ===

=== Extracting PW Server Package ===
./1.sh: line 540: 7za: command not found

=== DONE ===

=== Linking Lib ===
ln: failed to create symbolic link ‘/usr/lib/libtask.so.2’: File exists
ln: failed to create symbolic link ‘/usr/lib/libtask.so’: File exists
ln: failed to create symbolic link ‘/usr/lib64/libtask.so.2’: File exists
ln: failed to create symbolic link ‘/usr/lib64/libtask.so’: File exists

=== DONE ===

=== Configure Web Server ===
sed: can't read /etc/httpd/conf.modules.d/00-mpm.conf: No such file or directory
sed: can't read /etc/httpd/conf.modules.d/00-mpm.conf: No such file or directory
./1.sh: line 597: /etc/httpd/conf/httpd.conf: No such file or directory
sed: can't read /etc/httpd/conf/httpd.conf: No such file or directory
sed: can't read /etc/httpd/conf.d/php.conf: No such file or directory
sed: can't read /etc/httpd/conf.d/php.conf: No such file or directory
./1.sh: line 601: /etc/httpd/conf.d/php.conf: No such file or directory
rm: cannot remove ‘/etc/php-fpm.d/www.conf’: No such file or directory
./1.sh: line 717: /etc/php-fpm.d/amith.conf: No such file or directory
chown: cannot access ‘/home/amith/Website’: No such file or directory
Failed to stop mariadb.service: Unit mariadb.service not loaded.
Failed to start mariadb.service: Unit not found.
Failed to stop httpd.service: Unit httpd.service not loaded.
Failed to start httpd.service: Unit not found.
Failed to stop php-fpm.service: Unit php-fpm.service not loaded.
Failed to start php-fpm.service: Unit not found.

=== DONE ===

=== Setup MySQL Data Base ===
sed: can't read /home/amith/MySQL/hrace009_dbo.sql: No such file or directory
./1.sh: line 743: mysqladmin: command not found
./1.sh: line 746: mysql: command not found
./1.sh: line 747: mysql: command not found
./1.sh: line 748: mysql: command not found
./1.sh: line 751: mysql: command not found
sed: can't read /etc/my.cnf.d/server.cnf: No such file or directory
sed: can't read /etc/my.cnf.d/server.cnf: No such file or directory
sed: can't read /etc/my.cnf.d/server.cnf: No such file or directory
./1.sh: line 759: mysql: command not found
./1.sh: line 760: /home/amith/MySQL/hrace009_dbo.sql: No such file or directory
rm: cannot remove ‘/home/amith/MySQL’: No such file or directory
./1.sh: line 764: mysql: command not found
./1.sh: line 765: mysql: command not found
./1.sh: line 766: mysql: command not found
./1.sh: line 767: mysql: command not found
./1.sh: line 770: mysql: command not found
./1.sh: line 771: mysql: command not found
./1.sh: line 772: mysql: command not found
./1.sh: line 773: mysql: command not found

=== DONE ===

=== Configure PW Admin ===
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/WEB-INF/.pwadminconf.jsp: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/tomcat: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/webapps/Admin_Control1/serverctrl.jsp: No such file or directory

=== DONE ===

=== Configure Apache Tomcat ===
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/conf/tomcat-users.xml: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/conf/tomcat-users.xml: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/conf/server.xml: No such file or directory
chmod: cannot access ‘/home/amith/Core/Wanmei2015/apache-tomcat-7.0.32/tomcat’: No such file or directory
error reading information on service tomcat: No such file or directory

=== DONE ===

=== Configure AUTH ===
sed: can't read /home/amith/Core/etc/table.xml: No such file or directory
sed: can't read /home/amith/Core/etc/table.xml: No such file or directory
sed: can't read /home/amith/Core/etc/table.xml: No such file or directory
sed: can't read /home/amith/Core/etc/table.xml: No such file or directory

=== DONE ===

=== Configure PW Path ===
sed: can't read /home/amith/Core/Wanmei2015/Start: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Start: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Start: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Start_Mini: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Stop: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/authd/build/authd: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamed/gs.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamed/gs_rollback.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamed/gsalias.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamedbd/cashstat.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamedbd/fix.sh: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gamedbd/gamesys.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gdeliveryd/gamesys.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gfactiond/gamesys.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/gfactiond/gamesys.conf.central: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/glinkd/gamesys.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/logservice/logservice.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/uniquenamed/gamesys.conf: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Start: No such file or directory
sed: can't read /home/amith/Core/Wanmei2015/Stop: No such file or directory

=== DONE ===

=== Configure GLINKD ===
sed: can't read /home/amith/Core/Wanmei2015/glinkd/gamesys.conf: No such file or directory

=== DONE ===
Failed to stop mariadb.service: Unit mariadb.service not loaded.
Failed to start mariadb.service: Unit not found.
Failed to stop php-fpm.service: Unit php-fpm.service not loaded.
Failed to start php-fpm.service: Unit not found.
Failed to stop httpd.service: Unit httpd.service not loaded.
Failed to start httpd.service: Unit not found.
Stopping Webmin server in /usr/libexec/webmin
Starting Webmin server in /usr/libexec/webmin

=== Setup Firewall ===
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
Failed to stop iptables.service: Unit iptables.service not loaded.
Failed to start iptables.service: Unit not found.
Failed to execute operation: No such file or directory

=== DONE ===


=== Setup File Permision ===
chmod: cannot access ‘/home/amith/Core’: No such file or directory
chmod: cannot access ‘/home/amith/Website’: No such file or directory

=== DONE ===

###########################################################
 Congratulations hrace009 Perfect World 1.5.5
 has now been installed on your server.
 Please review the log file left in /root/ for
 any errors encountered during installation.
###########################################################
Please Visit: https://www.hrace009.com for more information
###########################################################

Common Details
==============
Server IP address: 134.x.x.x
Server URL: http://game.testx0x0xpw.ml
Patcher URL: http://patcher.testx0x0xpw.ml
Register URL: http://api.testx0x0xpw.com
Webmin URL: https://game.testx0x0xpw.ml:10000

Database Details
================
MySQL Root User: amithsql
MySQL Root Password: [email protected]
MySQL PW DB User: dbo
MySQL PW DB Password: Mbhf5lBHco4NBWPa
MySQL Remote Port: 3306

SSH Details
===========
SSH User: amith
SSH User Password: [email protected]

PW Admin Details
================
PW Admin Password: [email protected]
PW Admin URL: http://134.x.x.x:55555/Admin_Control1/

iWeb Details
============
Iweb URL: http://134.x.x.x:55555/iweb/
iWeb User Name: amith-iweb
iWeb Password: [email protected]

Developer Information
=====================
Root PW Server Path: /home/amith
PW Server Path: /home/amith/Core/Wanmei2015/
All Element data path: /home/amith/Core/Wanmei2015/gamed/config/ELEMENTS

Website Development Information
===============================
Default Path: /home/amith/Website/default
Patcher Path: /home/amith/Website/patcher
API/Register Path: /home/amith/Website/server

#####################################################################
 (theses documentation are saved in /root/Installation_Document.txt)
#####################################################################
 

hrace009

Administrator
Staff member
I've been trying to install Perfect world installation Script on Digital Ocean CentOS vps



Seems like after the installation i'm unable to access to any services
  1. pwAdmin
  2. iWeb
  3. Webmin
  4. MySql
Installation Document is as bellow
you got so many warning and error on your logs.

please use CentOS 7
 
Top