Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ language: generic
sudo: required
dist: trusty

group: deprecated-2017Q2

install: ./extra/provision.sh -m dev -s $TRAVIS_BUILD_DIR -d $TRAVIS_BUILD_DIR

script: ./extra/run_tests.sh $TRAVIS_BUILD_DIR
15 changes: 4 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ ARG CRT

WORKDIR $HOME
COPY . $HOME
RUN apt-get update \
&& apt-get install -y \
rsync \
curl \
ca-certificates \
&& chown www-data:www-data $HOME \
&& ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker \
&& rm -f /var/run/hhvm/sock \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
CMD ["./extra/service_startup.sh"]
RUN chown www-data:www-data $HOME

RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker
CMD ["./extra/service_startup.sh"]
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "10.10.10.5"
config.vm.hostname = "facebookCTF-Dev"
config.vm.hostname = "FacebookCTF-Dev"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provision "shell", path: "extra/provision.sh", args: ENV['FBCTF_PROVISION_ARGS'], privileged: false
config.vm.provider "virtualbox" do |v|
Expand Down
56 changes: 56 additions & 0 deletions Vagrantfile-multi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

# MySQL Server
config.vm.define "mysql" do |mysql|
mysql.vm.network "private_network", ip: "10.10.10.6"
mysql.vm.hostname = "mysql"
mysql.vm.provision "shell", path: "extra/provision.sh", args: "ENV['FBCTF_PROVISION_ARGS'] --multiple-servers --server-type mysql", privileged: false
mysql.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end

# Cache Server
config.vm.define "cache" do |cache|
cache.vm.network "private_network", ip: "10.10.10.8"
cache.vm.hostname = "cache"
cache.vm.provision "shell", path: "extra/provision.sh", args: "ENV['FBCTF_PROVISION_ARGS'] --multiple-servers --server-type cache", privileged: false
cache.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end

# HHVM Server
config.vm.define "hhvm" do |hhvm|
hhvm.vm.network "private_network", ip: "10.10.10.7"
hhvm.vm.hostname = "hhvm"
hhvm.vm.provision "shell", path: "extra/provision.sh", args: "ENV['FBCTF_PROVISION_ARGS'] --multiple-servers --server-type hhvm --mysql-server 10.10.10.6 --cache-server 10.10.10.8", privileged: false
hhvm.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end

# Nginx Server
config.vm.define "nginx" do |nginx|
nginx.vm.network "private_network", ip: "10.10.10.5"
nginx.vm.network "forwarded_port", guest: 80, host: 80
nginx.vm.network "forwarded_port", guest: 443, host: 443
nginx.vm.hostname = "nginx"
nginx.vm.provision "shell", path: "extra/provision.sh", args: "ENV['FBCTF_PROVISION_ARGS'] --multiple-servers --server-type nginx --hhvm-server 10.10.10.7", privileged: false
nginx.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end

end
16 changes: 16 additions & 0 deletions Vagrantfile-single
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "10.10.10.5"
config.vm.hostname = "facebookCTF-Dev"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provision "shell", path: "extra/provision.sh", args: ENV['FBCTF_PROVISION_ARGS'], privileged: false
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 4
end
end
4 changes: 2 additions & 2 deletions database/logos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DROP TABLE IF EXISTS `logos`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`used` tinyint(1) DEFAULT 1,
`used` tinyint(1) DEFAULT 0,
`enabled` tinyint(1) DEFAULT 1,
`protected` tinyint(1) DEFAULT 0,
`custom` tinyint(1) DEFAULT 0,
Expand All @@ -23,7 +23,7 @@ CREATE TABLE `logos` (

LOCK TABLES `logos` WRITE;
/*!40000 ALTER TABLE `logos` DISABLE KEYS */;
INSERT INTO `logos` (name, logo, protected, custom) VALUES ('admin', '/static/svg/icons/badges/badge-admin.svg', 1, 0);
INSERT INTO `logos` (name, logo, protected, used, custom) VALUES ('admin', '/static/svg/icons/badges/badge-admin.svg', 1, 1, 0);
INSERT INTO `logos` (name, logo, custom) VALUES ('4chan-2', '/static/svg/icons/badges/badge-4chan-2.svg', 0);
INSERT INTO `logos` (name, logo, custom) VALUES ('4chan', '/static/svg/icons/badges/badge-4chan.svg', 0);
INSERT INTO `logos` (name, logo, custom) VALUES ('8ball', '/static/svg/icons/badges/badge-8ball.svg', 0);
Expand Down
23 changes: 22 additions & 1 deletion database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ INSERT INTO `configuration` (field, value, description) VALUES("pause_ts", "0",
INSERT INTO `configuration` (field, value, description) VALUES("timer", "0", "(Boolean) Timer is enabled");
INSERT INTO `configuration` (field, value, description) VALUES("scoring", "0", "(Boolean) Ability score levels");
INSERT INTO `configuration` (field, value, description) VALUES("gameboard", "1", "(Boolean) Refresh all data in the gameboard");
INSERT INTO `configuration` (field, value, description) VALUES("auto_announce", "0", "(Boolean) Auto game announcements");
INSERT INTO `configuration` (field, value, description) VALUES("progressive_cycle", "300", "(Integer) Frequency to take progressive scoreboard in seconds");
INSERT INTO `configuration` (field, value, description) VALUES("bases_cycle", "5", "(Integer) Frequency to score base levels in seconds");
INSERT INTO `configuration` (field, value, description) VALUES("autorun_cycle", "30", "(Integer) Frequency to cycle autorun in seconds");
Expand All @@ -232,7 +233,8 @@ INSERT INTO `configuration` (field, value, description) VALUES("language", "en",
INSERT INTO `configuration` (field, value, description) VALUES("livesync", "0", "(Boolean) LiveSync functionality");
INSERT INTO `configuration` (field, value, description) VALUES("livesync_auth_key", "", "(String) Optional LiveSync Auth Key");
INSERT INTO `configuration` (field, value, description) VALUES("custom_logo", "0", "(Boolean) Custom branding logo");
INSERT INTO `configuration` (field, value, description) VALUES("custom_text", "Powered By Facebook", "(String) Custom branding text");
INSERT INTO `configuration` (field, value, description) VALUES("custom_org", "Facebook", "(String) Custom branding organization text");
INSERT INTO `configuration` (field, value, description) VALUES("custom_byline", "Powered By Facebook", "(String) Custom branding byline text");
INSERT INTO `configuration` (field, value, description) VALUES("custom_logo_image", "static/img/favicon.png", "(String) Custom logo image file");
UNLOCK TABLES;

Expand Down Expand Up @@ -417,3 +419,22 @@ CREATE TABLE `announcements_log` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `activity_log`
--

DROP TABLE IF EXISTS `activity_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `activity_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subject` text NOT NULL,
`action` text NOT NULL,
`entity` text NOT NULL,
`message` text NOT NULL,
`arguments` text NOT NULL,
`ts` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
24 changes: 24 additions & 0 deletions database/test_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ INSERT INTO `configuration` (field, value, description) VALUES("pause_ts", "0",
INSERT INTO `configuration` (field, value, description) VALUES("timer", "0", "(Boolean) Timer is enabled");
INSERT INTO `configuration` (field, value, description) VALUES("scoring", "0", "(Boolean) Ability score levels");
INSERT INTO `configuration` (field, value, description) VALUES("gameboard", "1", "(Boolean) Refresh all data in the gameboard");
INSERT INTO `configuration` (field, value, description) VALUES("auto_announce", "0", "(Boolean) Auto game announcements");
INSERT INTO `configuration` (field, value, description) VALUES("progressive_cycle", "300", "(Integer) Frequency to take progressive scoreboard in seconds");
INSERT INTO `configuration` (field, value, description) VALUES("bases_cycle", "5", "(Integer) Frequency to score base levels in seconds");
INSERT INTO `configuration` (field, value, description) VALUES("autorun_cycle", "30", "(Integer) Frequency to cycle autorun in seconds");
Expand All @@ -231,6 +232,10 @@ INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec
INSERT INTO `configuration` (field, value, description) VALUES("language", "en", "(String) Language of the system");
INSERT INTO `configuration` (field, value, description) VALUES("livesync", "0", "(Boolean) LiveSync functionality");
INSERT INTO `configuration` (field, value, description) VALUES("livesync_auth_key", "", "(String) Optional LiveSync Auth Key");
INSERT INTO `configuration` (field, value, description) VALUES("custom_logo", "0", "(Boolean) Custom branding logo");
INSERT INTO `configuration` (field, value, description) VALUES("custom_org", "Facebook", "(String) Custom branding organization text");
INSERT INTO `configuration` (field, value, description) VALUES("custom_byline", "Powered By Facebook", "(String) Custom branding byline text");
INSERT INTO `configuration` (field, value, description) VALUES("custom_logo_image", "static/img/favicon.png", "(String) Custom logo image file");
UNLOCK TABLES;

--
Expand Down Expand Up @@ -414,3 +419,22 @@ CREATE TABLE `announcements_log` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `activity_log`
--

DROP TABLE IF EXISTS `activity_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `activity_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subject` text NOT NULL,
`action` text NOT NULL,
`entity` text NOT NULL,
`message` text NOT NULL,
`arguments` text NOT NULL,
`ts` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '2'
services:
mysql:
restart: always
build:
context: .
dockerfile: extra/mysql/Dockerfile
#args:
# MODE: prod
environment:
MYSQL_ROOT_PASSWORD: root
expose:
- "3306"

cache:
restart: always
build:
context: .
dockerfile: extra/cache/Dockerfile
#args:
# MODE: prod
expose:
- "11211"

hhvm:
restart: always
build:
context: .
dockerfile: extra/hhvm/Dockerfile
#args:
# MODE: prod
depends_on:
- mysql
- cache
expose:
- "9000"

nginx:
restart: always
build:
context: .
dockerfile: extra/nginx/Dockerfile
#args:
# MODE: prod
depends_on:
- hhvm
ports:
- "80:80"
- "443:443"
17 changes: 17 additions & 0 deletions extra/cache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <[email protected]>"

ENV HOME /root

ARG DOMAIN
ARG EMAIL
ARG MODE=dev
ARG TYPE=self
ARG KEY
ARG CRT

WORKDIR $HOME
COPY . $HOME

RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type cache
CMD ["./extra/cache/cache_startup.sh"]
11 changes: 11 additions & 0 deletions extra/cache/cache_startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

service memcached restart

while true; do
sleep 5

service memcached status
done
1 change: 1 addition & 0 deletions extra/hhvm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ hhvm.enable_xhp = true
hhvm.force_hh = true
hhvm.server.type = fastcgi
hhvm.server.ip = 127.0.0.1
hhvm.server.port = 9000
hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.server.default_document = index.php
hhvm.server.upload.upload_max_file_size = 25M
Expand Down
17 changes: 17 additions & 0 deletions extra/hhvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <[email protected]>"

ENV HOME /root

ARG DOMAIN
ARG EMAIL
ARG MODE=dev
ARG TYPE=self
ARG KEY
ARG CRT

WORKDIR $HOME
COPY . $HOME

RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type hhvm --mysql-server mysql --cache-server cache
CMD ["./extra/hhvm/hhvm_startup.sh"]
15 changes: 15 additions & 0 deletions extra/hhvm/hhvm_startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

service hhvm restart

while true; do
if [[ -e /var/run/hhvm/sock ]]; then
chown www-data:www-data /var/run/hhvm/sock
fi

sleep 5

service hhvm status
done
Loading