cat /etc/apache2/sites-enabled/000-default.conf | \
sed '/<\/VirtualHost>/ i\' | \
sed '/<\/VirtualHost>/ i\ SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1' | \
sed '/<\/VirtualHost>/ i\' | \
sed '/<\/VirtualHost>/ i\ RewriteEngine on' | \
sed '/<\/VirtualHost>/ i\ RewriteRule ^/rsrc/(.*) - [L,QSA]' | \
sed '/<\/VirtualHost>/ i\ RewriteRule ^/favicon.ico - [L,QSA]' | \
sed '/<\/VirtualHost>/ i\ RewriteRule ^(.*)$ fcgi://127.0.0.1:30000/opt/phabricator/phabricator/webroot/index.php?__path__=$1 [B,L,QSA,P]' \
> /etc/apache2/sites-enabled/000-default.new
mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/000-default.old
mv /etc/apache2/sites-enabled/000-default.new /etc/apache2/sites-enabled/000-default.conf
service php5-fpm restart
service apache2 restart
############## install phabricator #####################
mkdir /opt/phabricator
groupadd phabricator
useradd -d /opt/phabricator -M -s /bin/bash -g phabricator 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