mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-24 08:46:24 -07:00
Add Vagrant setup scripts
This commit is contained in:
parent
41fa3a7c04
commit
f9c7912a2c
2 changed files with 115 additions and 0 deletions
24
vagrant/Vagrantfile
vendored
Executable file
24
vagrant/Vagrantfile
vendored
Executable file
|
@ -0,0 +1,24 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
# use 16.04 because 14.04's go version is ooooooooooooooooooooold
|
||||
config.vm.box = "ubuntu/xenial64"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
|
||||
config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
config.vm.network :private_network, ip: "172.27.0.3"
|
||||
config.vm.synced_folder "../", "/vagrant"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.gui = false
|
||||
vb.cpus = "4"
|
||||
vb.memory = "4096"
|
||||
end
|
||||
config.vm.provision :shell, path: "bootstrap.sh"
|
||||
end
|
91
vagrant/bootstrap.sh
Executable file
91
vagrant/bootstrap.sh
Executable file
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
# Vagrant provision script, kinda sorta based on Ponychan's
|
||||
|
||||
set -euo pipefail
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export GOCHAN_PATH=/home/ubuntu/gochan
|
||||
apt-get update
|
||||
apt-get -y install git subversion mercurial golang nginx redis-server mariadb-server mariadb-client #gifsicle
|
||||
|
||||
# Make sure any imported database is utf8mb4
|
||||
# http://mathiasbynens.be/notes/mysql-utf8mb4
|
||||
# Put in /etc/mysql/conf.d/local.cnf
|
||||
cat - <<EOF123 >/etc/mysql/conf.d/local.cnf
|
||||
[client]
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqld]
|
||||
character-set-client-handshake = FALSE
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
default-storage-engine = innodb
|
||||
EOF123
|
||||
|
||||
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS gochan; \
|
||||
GRANT USAGE ON *.* TO gochan IDENTIFIED BY ''; \
|
||||
GRANT ALL PRIVILEGES ON gochan.* TO gochan; \
|
||||
SET PASSWORD FOR 'gochan'@'%' = PASSWORD('gochan');
|
||||
FLUSH PRIVILEGES;"
|
||||
|
||||
cat - <<EOF123 >/etc/mysql/conf.d/open.cnf
|
||||
[mysqld]
|
||||
bind-address = 0.0.0.0
|
||||
EOF123
|
||||
|
||||
service mysql restart &
|
||||
wait
|
||||
rm -f /etc/nginx/sites-enabled/* /etc/nginx/sites-available/*
|
||||
cp -f /vagrant/gochan.nginx /etc/nginx/sites-available/gochan.nginx
|
||||
ln -sf /etc/nginx/sites-available/gochan.nginx /etc/nginx/sites-enabled/
|
||||
|
||||
# VirtualBox shared folders don't play nicely with sendfile.
|
||||
sed -e 's/sendfile on;/sendfile off;/' -i /etc/nginx/nginx.conf
|
||||
service nginx restart
|
||||
|
||||
|
||||
mkdir -p /vagrant/lib || true
|
||||
export GOPATH=/vagrant/lib
|
||||
cd /vagrant
|
||||
su ubuntu
|
||||
go get github.com/disintegration/imaging
|
||||
go get github.com/nranchev/go-libGeoIP
|
||||
go get github.com/nyarla/go-crypt
|
||||
go get github.com/ziutek/mymysql/godrv
|
||||
go get golang.org/x/crypto/bcrypt
|
||||
make verbose
|
||||
|
||||
rm -f $GOCHAN_PATH/gochan
|
||||
rm -f $GOCHAN_PATH/initialsetupdb.sql
|
||||
|
||||
install -m 775 -o ubuntu -g ubuntu -d $GOCHAN_PATH
|
||||
install -m 775 -o ubuntu -g ubuntu -d $GOCHAN_PATH/html
|
||||
install -m 775 -o ubuntu -g ubuntu -d $GOCHAN_PATH/log
|
||||
install -m 775 -o ubuntu -g ubuntu -T /vagrant/gochan $GOCHAN_PATH/gochan
|
||||
install -m 775 -o ubuntu -g ubuntu -T /vagrant/initialsetupdb.sql $GOCHAN_PATH/initialsetupdb.sql
|
||||
ln -sf /vagrant/html/javascript $GOCHAN_PATH/html/javascript
|
||||
ln -sf /vagrant/templates $GOCHAN_PATH/templates
|
||||
ln -sf /vagrant/html/css $GOCHAN_PATH/html/css
|
||||
ln -sf /vagrant/html/css $GOCHAN_PATH/html/error
|
||||
|
||||
if [ ! -e "$GOCHAN_PATH/html/index.html" ]; then
|
||||
install -m 775 -o ubuntu -g ubuntu -T /vagrant/html/index.html $GOCHAN_PATH/html/index.html
|
||||
fi
|
||||
|
||||
if [ ! -e "$GOCHAN_PATH/gochan.json" ]; then
|
||||
install -m 775 -o ubuntu -g ubuntu -T /vagrant/gochan.example.json $GOCHAN_PATH/gochan.json
|
||||
fi
|
||||
|
||||
sed -e 's/"Port": 8080,/"Port": 9000,/' -i $GOCHAN_PATH/gochan.json
|
||||
sed -e 's/"UseFastCGI": false,/"UseFastCGI": true,/' -i /$GOCHAN_PATH/gochan.json
|
||||
sed -e 's/"DomainRegex": ".*",/"DomainRegex": "(https|http):\\\/\\\/(.*)\\\/(.*)",/' -i $GOCHAN_PATH/gochan.json
|
||||
sed -e 's/"DBpassword": ""/"DBpassword": "gochan"/' -i /home/ubuntu/gochan/gochan.json
|
||||
sed -e 's/"RandomSeed": ""/"RandomSeed": "abc123"/' -i $GOCHAN_PATH/gochan.json
|
||||
|
||||
echo
|
||||
echo "Server set up, please run \"vagrant ssh\" on your host machine, and"
|
||||
echo "\"cd ~/gochan && ./gochan\" in the guest. Then browse to http://172.27.0.3/manage"
|
||||
echo "to complete installation (TODO: add further instructions as default initial announcement"
|
||||
echo "or /manage?action=firstrun)"
|
Loading…
Add table
Add a link
Reference in a new issue