248 lines
8.5 KiB
Bash
Executable File
248 lines
8.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source /dev/stdin <<< "$(curl -sL https://scity.xyz/colorsinc)"
|
|
source /dev/stdin <<< "$(curl -sL https://scity.xyz/defaultinc)"
|
|
|
|
|
|
# Install: lsb-release
|
|
${APTFUNC} -y install lsb-release curl ntpdate
|
|
/usr/sbin/ntpdate -u pool.ntp.org
|
|
|
|
# Get Public Interface
|
|
IFACE="$(/sbin/route | grep '^default' | grep -o '[^ ]*$')"
|
|
|
|
# Get Public IP
|
|
IP="$(curl -4 icanhazip.com)"
|
|
|
|
# Password Generator
|
|
# MySQL, Multicraft Daemon, Multicraft Panel, Multicraft Admin, phpMyAdmin BlowFish Secret
|
|
export MySQLPWD=`cat /dev/urandom | tr -dc A-Za-z0-9 | dd bs=25 count=1 2>/dev/null`
|
|
export DaemonPassword=`cat /dev/urandom | tr -dc A-Za-z0-9 | dd bs=25 count=1 2>/dev/null`
|
|
export AdminPassword=`cat /dev/urandom | tr -dc A-Za-z0-9 | dd bs=25 count=1 2>/dev/null`
|
|
export BlowFish=`cat /dev/urandom | tr -dc A-Za-z0-9 | dd bs=32 count=1 2>/dev/null`
|
|
|
|
MYSQLPARAM='mysql -h 10.5.10.56 -P 3307 -u root -pDc$@54115'
|
|
|
|
${APTFUNC} -y purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
|
|
${APTFUNC} install -y language-pack-en-base
|
|
export LC_ALL=en_US.UTF-8
|
|
export LANG=en_US.UTF-8
|
|
${APTFUNC} install -y software-properties-common
|
|
add-apt-repository -y ppa:ondrej/php
|
|
${APTFUNC} update
|
|
${APTFUNC} -y upgrade
|
|
export DEBIAN_FRONTEND="noninteractive"
|
|
${APTFUNC} -y install apache2 php5.6 php5.6-mysqlnd sqlite php5.6-gd php5.6-mbstring php5.6-xml php5.6-curl php5.6-sqlite wget nano zip unzip git dos2unix mariadb-client-10.0
|
|
|
|
|
|
# Multicraft Databases
|
|
${MYSQLPARAM} -e "CREATE DATABASE multicraft_daemon;"
|
|
${MYSQLPARAM} -e "CREATE DATABASE multicraft_panel;"
|
|
${MYSQLPARAM} -e "GRANT ALL ON multicraft_daemon.* to multicraft@'%' IDENTIFIED BY '${MySQLPWD}';"
|
|
${MYSQLPARAM} -e "GRANT ALL ON multicraft_panel.* to multicraft@'%' IDENTIFIED BY '${MySQLPWD}';"
|
|
|
|
WebRoot="/var/www/html"
|
|
|
|
# Multicraft Download
|
|
cd /opt/
|
|
wget --no-check-certificate http://multicraft.org/download/linux64 -O multicraft.tar.gz
|
|
tar -xf multicraft.tar.gz
|
|
rm -fv multicraft.tar.gz
|
|
cd multicraft
|
|
rm -rf jar api setup.sh eula.txt readme.txt
|
|
mv panel multicraft
|
|
mv multicraft.conf.dist multicraft.conf
|
|
mv multicraft ${WebRoot}/
|
|
mkdir jar
|
|
cd jar
|
|
wget "https://github.com/JustOneMoreBlock/shell-scripts/blob/master/files/multicraft-jar-confs.zip?raw=true" -O multicraft-jar-confs.zip;
|
|
unzip -o multicraft-jar-confs.zip
|
|
rm -fv multicraft-jar-confs.zip
|
|
wget http://s3.amazonaws.com/MCProHosting-Misc/Spigot/Spigot.jar -O Spigot.jar
|
|
wget http://s3.amazonaws.com/MCProHosting-Misc/PaperSpigot/PaperSpigot.jar -O PaperSpigot.jar
|
|
wget http://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar -O Bungeecord.jar
|
|
cd /opt/multicraft/
|
|
|
|
# Multicraft Panel
|
|
ProtectedConf="/protected/config/config.php"
|
|
cd ${WebRoot}/multicraft/
|
|
mv protected /
|
|
mv ${ProtectedConf}.dist ${ProtectedConf}
|
|
|
|
sed -i 's/dirname(__FILE__)./\E/g' index.php
|
|
rm -fv api.php install.php
|
|
|
|
|
|
# php.ini Auto-Detector
|
|
PHP="$(php -r "echo php_ini_loaded_file();")"
|
|
rm -fv /etc/php.ini
|
|
ln -s ${PHP} /etc/php.ini
|
|
|
|
# Modify php.ini Settings
|
|
sed -i 's/upload_max_filesize = \(.*\)/\Eupload_max_filesize = 100M/g' /etc/php.ini
|
|
sed -i 's/post_max_size = \(.*\)/\Epost_max_size = 100M/g' /etc/php.ini
|
|
sed -i 's/max_execution_time = \(.*\)/\Emax_execution_time = 300/g' /etc/php.ini
|
|
sed -i 's/max_input_time = \(.*\)/\Emax_input_time = 600/g' /etc/php.ini
|
|
|
|
# Memory Checker
|
|
MemTotal="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"
|
|
Memory="$((${MemTotal} / 1024))"
|
|
|
|
# Multicraft Config
|
|
MulticraftConf="/opt/multicraft/multicraft.conf"
|
|
sed -i 's/user =\(.*\)/\Euser = root/g' ${MulticraftConf}
|
|
sed -i 's/webUser =\(.*\)/\EwebUser = /g' ${MulticraftConf}
|
|
sed -i 's/\#id =\(.*\)/\Eid = 1/g' ${MulticraftConf}
|
|
sed -i 's/\#database = mysql\(.*\)/\Edatabase = mysql:host=10.5.10.56:3307;dbname=multicraft_daemon/g' ${MulticraftConf}
|
|
sed -i 's/\#dbUser =\(.*\)/\EdbUser = multicraft/g' ${MulticraftConf}
|
|
sed -i "s/\#dbPassword =\(.*\)/\EdbPassword = ${MySQLPWD}/g" ${MulticraftConf}
|
|
sed -i "s/\#password =\(.*\)/\Epassword = ${DaemonPassword}/g" ${MulticraftConf}
|
|
sed -i 's/\#name =\(.*\)/\Ename = Server 1/g' ${MulticraftConf}
|
|
sed -i "s/#totalMemory =\(.*\)/\EtotalMemory = ${Memory}/g" ${MulticraftConf}
|
|
sed -i "s/\(.*\)baseDir =\(.*\)/\EbaseDir = \/opt\/multicraft\//g" ${MulticraftConf}
|
|
sed -i 's/\#multiuser =\(.*\)/\Emultiuser = true/g' ${MulticraftConf}
|
|
sed -i "s/\(.*\)forbiddenFiles\(.*\)/\#forbiddenFiles = /g" ${MulticraftConf}
|
|
sed -i "s/\ip = 127.0.0.1/\Eip = ${IP}/g" ${MulticraftConf}
|
|
|
|
# Multicraft Panel Config
|
|
cd /protected/config/
|
|
cat > config.php << eof
|
|
<?php
|
|
return array (
|
|
'panel_db' => 'mysql:host=10.5.10.56:3307;dbname=multicraft_panel',
|
|
'daemon_db' => 'mysql:host=10.5.10.56:3307;dbname=dmulticraft_aemon',
|
|
'daemon_password' => '${DaemonPassword}',
|
|
'superuser' => 'admin',
|
|
'api_enabled' => false,
|
|
'api_allow_get' => false,
|
|
'user_api_keys' => false,
|
|
'admin_name' => 'Multicraft Administrator',
|
|
'admin_email' => '',
|
|
'show_serverlist' => 'user',
|
|
'hide_userlist' => true,
|
|
'ftp_client_disabled' => false,
|
|
'ftp_client_passive' => false,
|
|
'templates_disabled' => false,
|
|
'ajax_updates_disabled' => false,
|
|
'ajax_update_interval' => '2000',
|
|
'timeout' => '5',
|
|
'mark_daemon_offline' => '10',
|
|
'theme' => '',
|
|
'mobile_theme' => '',
|
|
'user_theme' => false,
|
|
'language' => '',
|
|
'login_tries' => '4',
|
|
'login_interval' => '300',
|
|
'ajax_serverlist' => false,
|
|
'status_banner' => true,
|
|
'mail_welcome' => false,
|
|
'mail_assign' => false,
|
|
'sqlitecache_schema' => false,
|
|
'sqlitecache_commands' => false,
|
|
'user_mysql' => true,
|
|
'user_mysql_host' => '10.5.10.56:3307',
|
|
'user_mysql_user' => 'sqluser',
|
|
'user_mysql_pass' => 'dcs2057',
|
|
'user_mysql_prefix' => 'db_',
|
|
'user_mysql_admin' => 'https://pma.scity.us/index.php',
|
|
'show_repairtool' => 'superuser',
|
|
'register_disabled' => true,
|
|
'reset_token_hours' => '0',
|
|
'default_ignore_ip' => false,
|
|
'default_display_ip' => '',
|
|
'show_memory' => true,
|
|
'log_bottomup' => true,
|
|
'admin_ips' => '',
|
|
'api_ips' => '',
|
|
'enable_csrf_validation' => true,
|
|
'enable_cookie_validation' => true,
|
|
'use_bukget' => false,
|
|
'auto_jar_submit' => 'yes',
|
|
'pw_crypt' => 'sha512_crypt',
|
|
'ip_auth' => true,
|
|
'cpu_display' => 'core',
|
|
'ram_display' => '',
|
|
'enable_disk_quota' => false,
|
|
'block_chat_characters' => true,
|
|
'log_console_commands' => false,
|
|
'show_delete_all_players' => 'superuser',
|
|
'kill_button' => 'superuser',
|
|
'fill_port_gaps' => true,
|
|
'support_legacy_daemons' => false,
|
|
'panel_db_user' => 'multicraft',
|
|
'panel_db_pass' => '${DaemonPassword}',
|
|
'daemon_db_user' => 'multicraft',
|
|
'daemon_db_pass' => '${DaemonPassword}',
|
|
'min_pw_length' => '',
|
|
'default_displayed_ip' => '',
|
|
'support_legacy_api' => false,
|
|
);
|
|
eof
|
|
|
|
|
|
${APTFUNC} -y install software-properties-common python-software-properties debconf-utils
|
|
${APTFUNC} -y update
|
|
add-apt-repository ppa:webupd8team/java -y
|
|
${APTFUNC} -y update
|
|
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
|
|
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true" | debconf-set-selections
|
|
${APTFUNC} -y install oracle-java8-installer
|
|
|
|
java -version
|
|
|
|
chown -rf www-data:www-data ${WebRoot}/multicraft
|
|
chown -rf www-data:www-data /protected
|
|
chmod -rf 775 ${WebRoot}/multicraft
|
|
chmod -rf 775 /protected
|
|
|
|
# Restart Services
|
|
service apache2 stop
|
|
service apache2 start
|
|
|
|
# Output Vars
|
|
cd /opt/multicraft/
|
|
cat > logins.conf << eof
|
|
# Stored Passwords
|
|
MySQL Password: ${MySQLPWD}
|
|
|
|
# Control Panel Link:
|
|
http://${IP}/multicraft/index.php
|
|
Username: admin
|
|
Password: ${AdminPassword}
|
|
|
|
eof
|
|
|
|
cat /opt/miulticraft/logins.conf
|
|
|
|
# Automatically Import MySQL Database Schema's, thus removing the web installer. :)
|
|
${MYSQLPARAM} -D multicraft_panel < /protected/data/panel/schema.mysql.sql
|
|
${MYSQLPARAM} -D multicraft_daemon < /protected/data/daemon/schema.mysql.sql
|
|
|
|
# Daemon MySQL Changes
|
|
${MYSQLPARAM} -D multicraft_daemon -e "INSERT INTO setting VALUES ('defaultServerIp', '1');"
|
|
${MYSQLPARAM} -D multicraft_daemon -e "INSERT INTO setting VALUES ('minecraftEula', 'auto');"
|
|
|
|
# Auto Start
|
|
mv /etc/rc.local /etc/rc.local-old
|
|
cd /etc/
|
|
cat > rc.local << eof
|
|
#!/bin/sh -e
|
|
|
|
/opt/multicraft/bin/multicraft start
|
|
/sbin/iptables -F
|
|
/sbin/iptables -X
|
|
|
|
exit 0
|
|
eof
|
|
dos2unix /etc/rc.local
|
|
chmod +x /etc/rc.local
|
|
chmod +x /etc/rc.d/rc.local
|
|
/etc/rc.local
|
|
|
|
${MYSQLPARAM} -Dmysql -e "FLUSH PRIVILEGES;"
|
|
|
|
# Configure New Admin Password
|
|
SaltPassword="$(python -c "import crypt, getpass, pwd; \
|
|
print crypt.crypt('${AdminPassword}', '\$6\$saltsalt\$')")"
|
|
${MYSQLPARAM} -D multicraft_panel -e "UPDATE user SET password='${SaltPassword}' WHERE name='admin';"
|
|
${MYSQLPARAM} -D multicraft_daemon -e "UPDATE ftp_user SET password='${SaltPassword}' WHERE name='admin';" |