Jump to content

Script to install/config on Ubuntu 16.04


arrestedgames

Recommended Posts

UPDATE NOTE: This is antiquated; the setup steps in the official documentation work well.  You might still get some use from hacking this setup, and can probably use some of this in an Ansible playbook, but I defer to the 201n.x setup guide.

 

Again; not a plugin - but this will let you take a bare ubuntu 16.04 box and automagically configure it for running atavism.

The assumption is that you have either a VM or a standalone linux box you use for devel, and you want to blow it away and rebuild at will.

This script may be able to be hacked to use for production deployments, or to use with another linux flavor.

YMMV.

 

Pre-req:

* Knowledge of Linux. Please. This is so unsupported, but it so freaking useful to me, I thought I would share.

* Fresh Ubuntu 16.04LTS server (not desktop.. may work, don't know)

* Install Oracle Java 8

- add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer

* Install MySQL

- apt-get install mysql-server

 

Use:

 

unrar atavism server into some directory.

copy this script into the atavism_server directory (i call it setup.sh)

edit the setup.sh file and change the following vars appropriately:

 

MY_IP=`ifconfig | head -2 | grep inet\ addr | awk -F: '{ print $2 }' | awk '{ print $1 }'`

#MY_IP=10.10.10.2

MY_NETWORK=192.168.1

 

You can either use the uncommented MY_IP which will find your first network address, or comment that, and uncomment the second one - which you will want to edit to your linux box's IP.

MY_NETWORK is the first 3 octet of your MY_IP (ie: 192.168.1.5 is MY_IP, then MY_NETWORK would be 192.168.1)

 

chmod 0755 ./setup.sh

sudo ./setup.sh USERNAME PASSWORD

where USERNAME = the db username you want to use and PASSWORD = the password for that user

*** DO NOT USE ROOT ... not even on your dev box. Crap has a way of leaking out to the public...

 

Follow the prompts.

 

Then, you should be able to cd into atavism_server/bin and launch auth.sh and world.sh

 

 

#!/bin/bash

if [ "$#" -lt 2 ]; then
  echo "Usage: $0 DB_USERNAME DB_PASSWORD"
  exit
fi

echo "Setting up Atavism development server..."
echo "Setting Variables..."
DTU_FILES="auth.sh auth.properties world.sh world.properties"
FIX_BASH="auth.sh world.sh"
SET_WORLD_DB="atavism.db_password= atavism.admin.db_password= atavism.content.db_password= atavism.auth.db_password="
SET_WORLD_DB_USER="atavism.db_user= atavism.admin.db_user= atavism.content.db_user= atavism.auth.db_user="

MY_IP=`ifconfig | head -2 | grep inet\ addr | awk -F: '{ print $2 }' | awk '{ print $1 }'`
#MY_IP=10.1.24.212
MY_NETWORK=10.1.24
DATABASES="admin master atavism world_content"


export db_user=$1
export db_pass=$2

echo -n "Fixing EOL terminators: "
for i in `echo $DTU_FILES` ; do dos2unix bin/$i ; done
echo "[Done]"
echo -n "Setting Permissions: "
for i in `echo $FIX_BASH` ; do chmod +x bin/$i ; done
echo "[Done]"
echo -n "Fixing bin/bash: "
for i in `echo $FIX_BASH` ; do sed -i '1 s/^.*$/\#\!\/bin\/bash/g' bin/$i ; done
echo "[Done]"
echo -n "Fixing prop2sh: "
sed -i 's/:space:/[:space:]/g' bin/prop2sh.awk
echo "[Done]"
echo -n "Setting Auth DB Username: "
sed -i "s/atavism.db_user=root/atavism.db_user=${db_user}/g" bin/auth.properties
echo "[Done]"
echo -n "Setting Auth DB Password: "
sed -i "s/atavism.db_password=test/atavism.db_password=${db_pass}/g" bin/auth.properties
echo "[Done]"
echo -n "Setting World DB Passwords: "
for i in `echo $SET_WORLD_DB` ; do sed -i "s/${i}test/${i}${db_pass}/g" bin/world.properties ; done
echo "[Done]"
echo -n "Setting World DB Usernames: "
for i in `echo $SET_WORLD_DB_USER` ; do sed -i "s/${i}root/${i}${db_user}/g" bin/world.properties ; done
echo "[Done]"
echo -n "Changing bind IP Address to ${MY_IP}: "
sed -i "s/atavism.login.bindaddress=localhost/atavism.login.bindaddress=${MY_IP}/g" bin/world.properties
sed -i "s/atavism.proxy.bindaddress=localhost/atavism.proxy.bindaddress=${MY_IP}/g" bin/world.properties
sed -i "s/atavism.db_hostname=localhost/atavism.db_hostname=${MY_IP}/g" bin/world.properties
sed -i "s/atavism.db_hostname=localhost/atavism.db_hostname=${MY_IP}/g" bin/auth.properties
echo "[Done]"
echo "Setting up the database - using [root] password for MySQL:"
mysql_config_editor set --login-path=local --host=localhost --user=root --password
echo "Disabling strict sql mode..."
mysql --login-path=local -e "set sql_mode = '';"
echo "Editing mysql.cnf..."
echo "[mysql]" > /etc/mysql/conf.d/mysql.cnf
echo "[mysqld]" >> /etc/mysql/conf.d/mysql.cnf
echo "sql_mode=\"\"" >> /etc/mysql/conf.d/mysql.cnf
echo "Editing /etc/mysql/mysql.conf.d/mysqld.cnf..."
sed -i "s/127.0.0.1/${MY_IP}/g" /etc/mysql/mysql.conf.d/mysqld.cnf
echo "Restarting MySQL..."
service mysql restart
echo "Dropping Old Databases..."
mysql --login-path=local -e "drop database admin; drop database atavism; drop database master; drop database world_content;"
echo "Dropping db users..."
mysql --login-path=local -e "drop user ${db_user}@'localhost'; drop user ${db_user}@'${MY_NETWORK}.%';"
for slurpdb in `ls -1 sql/*.sql` ; do echo "Importing ${slurpdb} ... " ; mysql --login-path=local < ${slurpdb} ; done
 mysql --login-path=local -e "CREATE USER ${db_user}@localhost IDENTIFIED BY '${db_pass}';"
 mysql --login-path=local -e "CREATE USER ${db_user}@'${MY_NETWORK}.%' IDENTIFIED BY '${db_pass}';"
 for i in `echo $DATABASES`
  do
    echo "Creating user: ${db_user} in DB: ${i} ..."
    mysql --login-path=local -e "GRANT ALL PRIVILEGES ON ${i}.* TO ${db_user}@localhost identified by '${db_pass}';"
    mysql --login-path=local -e "GRANT ALL PRIVILEGES ON ${i}.* TO ${db_user}@'${MY_NETWORK}.%' identified by '${db_pass}';"
    mysql --login-path=local -e "FLUSH PRIVILEGES;"
  done
unset db_pass
unset db_user
echo "Database setup complete."
 
Edited by arrestedgames
Link to comment
Share on other sites

  • 5 months later...
  • 5 months later...

that is weird.

please note this:

 

"*** DO NOT USE ROOT ... not even on your dev box. Crap has a way of leaking out to the public..."

 

so - do not install this into root's homedir

do not run this as root

 

create a new user to run atavism under

become that user

then follow those instructions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recommended Cloud Solution


    ksweb.net

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.