forked from freeciv/freeciv-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42b6066
commit 2bd1036
Showing
2 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/bash | ||
|
||
# Freeciv-web Vagrant Bootstrap Script - play.freeciv.org | ||
# 2014-02-17 - Andreas Røsdal | ||
# | ||
# Setup script for Freeciv-web to be used on a Vagrant local developer image. | ||
# This script assumes that the source code in git has been checked out from | ||
# https://github.com/freeciv/freeciv-web to /vagrant | ||
|
||
if [ -d "/vagrant/" ]; then | ||
# script is run to install Freeciv-web under vagrant | ||
basedir="/vagrant" | ||
logfile="/vagrant/freeciv-web-vagrant.log" | ||
else | ||
# script is run to install Freeciv-web on current system without vagrant | ||
echo "Installing Freeciv-web on current system. Please run this script as root user." | ||
basedir=$(pwd)"/.." | ||
logfile="${basedir}/freeciv-web-vagrant.log" | ||
fi | ||
|
||
|
||
# Redirect copy of output to a log file. | ||
exec > >(tee ${logfile}) | ||
exec 2>&1 | ||
set -e | ||
|
||
echo "=================================" | ||
echo "Running Freeciv-web setup script." | ||
echo "=================================" | ||
|
||
uname -a | ||
echo basedir $basedir | ||
echo logfile $logfile | ||
|
||
# User will need permissions to create a database | ||
mysql_user="root" | ||
mysql_pass="vagrant" | ||
|
||
resin_version="4.0.38" | ||
resin_url="http://www.caucho.com/download/resin-${resin_version}.tar.gz" | ||
tornado_url="https://pypi.python.org/packages/source/t/tornado/tornado-3.2.tar.gz" | ||
|
||
# Based on fresh install of Ubuntu 12.04 | ||
dependencies="maven2 mysql-server-5.5 openjdk-7-jdk libcurl4-openssl-dev nginx libjansson-dev subversion pngcrush libtool automake autoconf autotools-dev language-pack-en python3-setuptools libglib2.0-dev" | ||
|
||
## Setup | ||
mkdir -p ${basedir} | ||
cd ${basedir} | ||
|
||
## dependencies | ||
echo "==== Installing Updates and Dependencies ====" | ||
echo "apt-get update" | ||
apt-get -y update | ||
echo "mysql setup..." | ||
sudo debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password password ${mysql_pass}" | ||
sudo debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password_again password ${mysql_pass}" | ||
echo "apt-get install dependencies" | ||
apt-get -y install ${dependencies} | ||
|
||
## build/install resin | ||
echo "==== Fetching/Installing Resin ${resin_version} ====" | ||
wget ${resin_url} | ||
tar xvfz resin-${resin_version}.tar.gz | ||
rm -Rf resin | ||
mv resin-${resin_version} resin | ||
|
||
echo "==== Fetching/Installing Tornado Web Server ====" | ||
wget ${tornado_url} | ||
tar xvfz tornado-3.2.tar.gz | ||
cd tornado-3.2 | ||
python3.3 setup.py install | ||
|
||
|
||
## mysql setup | ||
echo "==== Setting up MySQL ====" | ||
mysqladmin -u ${mysql_user} -p${mysql_pass} create freeciv_web | ||
mysql -u ${mysql_user} -p${mysql_pass} freeciv_web < ${basedir}/freeciv-web/src/main/webapp/meta/private/metaserver.sql | ||
|
||
echo "==== Building freeciv ====" | ||
cd ${basedir}/freeciv && ./prepare_freeciv.sh | ||
cd freeciv && make install | ||
cd ${basedir}/freeciv/data/ && cp -rf fcweb /usr/local/share/freeciv | ||
|
||
echo "==== Building freeciv-web ====" | ||
sed -e "s/user>root/user>${mysql_user}/" -e "s/password>changeme/password>${mysql_pass}/" ${basedir}/freeciv-web/src/main/webapp/WEB-INF/resin-web.xml.dist > ${basedir}/freeciv-web/src/main/webapp/WEB-INF/resin-web.xml | ||
cd ${basedir}/freeciv-img-extract/ && ./setup_links.sh && ./sync.sh | ||
cd ${basedir}/scripts && ./sync-js-hand.sh | ||
cd ${basedir}/freeciv-web && ./build.sh | ||
|
||
echo "==============================" | ||
|
||
rm /etc/nginx/sites-enabled/default | ||
cp ${basedir}/publite2/nginx.conf /etc/nginx/ | ||
cp ${basedir}/publite2/nginx/freeciv-web /etc/nginx/sites-enabled/ | ||
|
||
if [ -d "/vagrant/" ]; then | ||
echo "Starting Freeciv-web..." | ||
service nginx start | ||
cd ${basedir}/scripts/ && sudo -u vagrant ./start-freeciv-web.sh | ||
echo "Freeciv-web started! Now try http://localhost/ on your host operating system." | ||
else | ||
echo "Freeciv-web installed. Please start it manually." | ||
fi |