sudo yum -y update
sudo yum -y upgrade
#Get the public key for Perforce package repo
sudo rpm --import http://package.perforce.com/perforce.pubkey
#Update sources list with the Perforce Package repo.
sudo echo "[perforce]
name=Perforce
baseurl=http://package.perforce.com/yum/rhel/7/x86_64
enabled=1
gpgcheck=1" >> /etc/yum.repos.d/perforce.repo
sudo yum -y update
sudo yum -y install helix-p4d
sudo yum -y install git
#Install Git LFS, as we will need it later to setup LFS for the liblouis repo.
#curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
#sudo yum -y install git-lfs
git lfs install
#Configure P4D
sudo /opt/perforce/sbin/configure-helix-p4d.sh -n perforce1 -p ssl:1666 -r /opt/perforce/servers/perforce1 -u super -P REinforce --unicode
sudo yum -y install helix-git-fusion
sudo chown -R vagrant /home/vagrant/*
#Set some system wide variables for the VM.
sudo echo "export P4EDITOR=nano" >> /etc/bash.bashrc
sudo echo "export P4PORT=ssl:1666" >> /etc/bash.bashrc
sudo echo "export P4CONFIG=.p4config" >> /etc/bash.bashrc
p4 -u super -p ssl:1666 trust -f
#Create a password file we use to log in
echo REinforce > /home/vagrant/hws/passwd
p4 -p ssl:1666 -u super login < /home/vagrant/hws/passwd
p4 configure set triggers.io=0
sudo su
touch /opt/perforce/git-fusion/libexec/p4gf_submit_trigger.cfg.tickets
#Configure Git Fusion
/opt/perforce/git-fusion/libexec/configure-git-fusion.sh -n --debug --super super --superpassword REinforce --gfp4password REinforce --gfsysuser git --gfdir /opt/perforce/git-fusion/libexec --server remote --p4port ssl:1666 --timezone Europe/London --unicode y --unknownuser pusher --https
#Install the triggers.
p4 -p ssl:1666 -u git-fusion-user login < /home/vagrant/hws/passwd
grep git-fusion-user /opt/perforce/git-fusion/home/perforce-git-fusion/.p4tickets > /opt/perforce/git-fusion/libexec/p4gf_submit_trigger.cfg.tickets
sudo /opt/perforce/git-fusion/libexec/p4gf_submit_trigger.py --install ssl:1666 super REinforce
#Swap out the log config file
cp /home/vagrant/hws/gf_configs/git-fusion.log.conf /etc/git-fusion.log.conf
#Setup SSL certs
sudo yum -y install openssl
sudo mkdir -p /etc/gf/ssl
openssl req -x509 -subj '/C=US/ST=CA/L=Alameda/O=Perforce/OU=gf/CN=gf/E=gf@perforce.com' -nodes -days 365 -newkey rsa:2048 -keyout /etc/gf/ssl/192.168.2.73.key -out /etc/gf/ssl/192.168.2.73.crt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo 'Errors while creating self-signed certificates!'
exit 1
else
echo 'Self-signed certificates have been created'
fi
sudo mkdir -p /etc/gf/trusted-certs
sudo cp /etc/gf/ssl/192.168.2.73.crt /etc/gf/trusted-certs/192.168.2.73.crt
#Create a directory structure, that will be used for the GF admin workspace.
mkdir -p /home/vagrant/workspaces/gf
cd /home/vagrant/workspaces/gf
echo "P4USER=super" > .p4config
echo "P4PORT=ssl:1666" >> .p4config
echo "P4CLIENT=gf_admin" >> .p4config
p4 login < ../../hws/passwd
p4 client -i < /home/vagrant/hws/gf_configs/gf_client
#Add the public key used for testing to the workspace.
mkdir -p .git-fusion/users/jen/keys
cd .git-fusion/users/jen/keys
rm vagrant_key*
ssh-keygen -t rsa -f vagrant_key
mv vagrant_key /home/vagrant/.ssh
cd /home/vagrant/workspaces/gf
#Obliterate the original p4gf_config, so don't have to do complicated stuff with resolve and change numbers
p4 obliterate -y //.git-fusion/p4gf_config
#Swap out the global p4gf_config file, for one that tells GF it's own URL.
#This is used for LFS
cp /home/vagrant/hws/gf_configs/lfs_global_config /home/vagrant/workspaces/gf/.git-fusion/p4gf_config
#Submit the new global config file, as we can only validate one at a time.
p4 -c gf_admin reconcile //.git-fusion/...
p4 -c gf_admin submit -d "Submitting new global p4gf_config file"
#Put the config files for the orca and liblouis repos in the correct place
mkdir -p .git-fusion/repos/orca
mkdir -p .git-fusion/repos/liblouis
cd .git-fusion/repos/orca
cp /home/vagrant/hws/gf_configs/orca_config .
mv orca_config p4gf_config
#The p4gf_config validator can not validate more than one config file at a time, so have to submit them individually.
p4 -c gf_admin reconcile //.git-fusion/...
p4 -c gf_admin submit -d "Adding the key for user 'jen' and p4gf_config files for the Orca repo"
cd ../liblouis
cp /home/vagrant/hws/gf_configs/lfs_liblouis_config .
mv lfs_liblouis_config p4gf_config
sudo chown -R vagrant /home/vagrant/workspaces/*
#Now submit the rest of the configs and keys
cd /home/vagrant/workspaces/gf
p4 -c gf_admin reconcile //.git-fusion/...
p4 -c gf_admin submit -d "Adding the key for user 'jen' and p4gf_config files for the liblouis repo"
#Now create the user jen
p4 -c gf_admin configure set security=1
p4 -c gf_admin configure set triggers.io=0
p4 -c gf_admin user -f -i < /home/vagrant/hws/gf_configs/gf_test_user
p4 -c gf_admin -u jen passwd -P REinforce
git config --global http.sslVerify "false"
git config --global user.email jen@example.com
#Now create the orca and liblouis repos
sudo -u git -i p4gf_init_repo.py orca
sudo -u git -i p4gf_init_repo.py liblouis
#Get SSH working so we can populate orca with content using this method if we wish
cp /home/vagrant/hws/config /home/vagrant/.ssh
#Populate Orca with some content
echo Populating Orca with content
cd /home/vagrant
mkdir testrepos
cd testrepos
git clone https://github.com/GNOME/orca.git
cd orca
git clone https://192.168.2.73/@info
git remote rename origin upstream
git remote add origin https://jen:REinforce@192.168.2.73/orca
git push -u --all origin
#Now create the liblouis repo, which will store the 'liblouis.*' files using LFS
cd ..
git clone https://github.com/liblouis/liblouis.git
cd liblouis
git remote rename origin upstream
git remote add origin https://jen:REinforce@192.168.2.73/liblouis
git push -u --all origin