#!/bin/bash -xe
chown phabricator:phabricator /opt/phabricator
chmod g+s /opt/phabricator
cd /opt/phabricator
sudo -u phabricator git clone https://github.com/phacility/libphutil.git
sudo -u phabricator git clone https://github.com/phacility/arcanist.git
sudo -u phabricator git clone https://github.com/phacility/phabricator.git
cd phabricator
# set up database
sudo -u phabricator ./bin/config set mysql.host ninetales.scimonshouse.net
sudo -u phabricator ./bin/config set mysql.user phabricator
sudo -u phabricator ./bin/config set mysql.pass phabricator
sudo -u phabricator ./bin/storage upgrade --force
# set up user accounts
sudo -u phabricator ./bin/config set diffusion.ssh-user git
sudo -u phabricator ./bin/config set diffusion.phd-user phabricator
echo "git ALL=(phabricator) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack" > /etc/sudoers.d/phabricator