Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
192 lines (149 sloc) 4.55 KB
<?xml version="1.0"?>
<template>
<name>BrowserQuest</name>
<description>BrowserQuest v1.2.2 Server</description>
<os>
<name>Fedora</name>
<version>16</version>
<arch>x86_64</arch>
<install type="url">
<!-- This is the Fedora 16 base repository -->
<url>http://download.fedoraproject.org/pub/fedora/linux/releases/16/Everything/x86_64/os/</url>
<!-- Note that only a base package installation is done. -->
<!-- No yum updates are automatically applied. If you -->
<!-- want updates (and you do! :>), you'll need to have -->
<!-- a "yum update -y" in the command list below. -->
</install>
<!-- The password for the root user. You can use this to -->
<!-- log in remotely if desired. -->
<rootpw>p@ssw0rd</rootpw>
</os>
<!-- All of the repositories below are added to /etc/yum.repos.d/ -->
<!-- *after* the initial OS installation is done. -->
<repositories>
<!-- Node.js Fedora 16 repository -->
<repository name="node-js">
<url>http://justinclift.fedorapeople.org/nodejs/Fedora-16/x86_64/</url>
<signed>false</signed>
</repository>
</repositories>
<!-- After the main OS has been installed, the packages below are installed -->
<!-- in a separate step. It takes into account the repositories in -->
<!-- /etc/yum.repos.d/, unlike the base OS installation which doesn't. -->
<packages>
<!-- Development tools -->
<package name="make"/>
<package name="gcc-c++"/>
<package name="zlib-devel"/>
<!-- Node.js -->
<package name="nodejs"/>
<package name="nodejs-devel"/>
<package name="nodejs-waf"/>
</packages>
<!-- After the packages above have been installed, -->
<!-- the commands below are run, in order. -->
<files>
<file name="/etc/init.d/browserquest"><![CDATA[#!/bin/bash
## BEGIN INIT INFO
# Provides: browserquest
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 2 3 4 6
# Required-Start: network
#
## END INIT INFO
# browserquest: Start BrowserQuest server
#
# chkconfig: 2345 80 99
#
# description: Starts the BrowserQuest server
#
# Source function library.
. /etc/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
NODE="/usr/bin/node"
prog=$(basename $NODE)
lockfile="/var/lock/subsys/node"
pidfile="/var/run/browserquest.pid"
base=${0##*/}
start() {
echo -n "Starting BrowserQuest"
# Start Node.js
cd /root/browserquest-BrowserQuest-95d47de
$NODE server/js/main.js > /var/log/nodejs.log 2> /var/log/nodejs.error &
retval=$?
echo $! > $pidfile
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n "Stopping BrowserQuest"
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest_q || return 6
stop
start
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
status|status_q)
rh_$1
;;
condrestart|try-restart)
rh_status_q || exit 7
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
]]>
</file>
</files>
<!-- After any files above have been installed, -->
<!-- the commands below are run, in order. -->
<commands>
<!-- This pulls in updated Fedora packages. Practically mandatory -->
<!-- in any real world deployment. :> -->
<command name="yum-update">yum update -y</command>
<!-- Run the script that does everything -->
<command name="setup-browserquest"><![CDATA[#!/bin/bash
# Download and extract the BrowserQuest v1.2.2 tarball
curl -sL https://github.com/browserquest/BrowserQuest/tarball/v1.2.2 | tar xpz
# Add the Node.js modules required for BrowserQuest
cd browserquest-BrowserQuest-95d47de
npm install -d
# Change the server to listen on port 80
sed -i -e "s/8000/80/" /root/browserquest-BrowserQuest-95d47de/server/config.json
# Set up BrowerQuest startup script
chmod 755 /etc/init.d/browserquest
chkconfig --add browserquest
chkconfig browserquest on
]]>
</command>
</commands>
</template>
You can’t perform that action at this time.