Created
June 19, 2020 05:28
-
-
Save sdorra/75e1fd497896dbd002dde3ad488bf2e4 to your computer and use it in GitHub Desktop.
SCM-Manager on FreeBSD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "freebsd/FreeBSD-12.0-STABLE" | |
# forward SCM-Manager port to host | |
config.vm.network "forwarded_port", guest: 8080, host: 8080 | |
# add some more memory | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "2048" | |
end | |
# does not work on freebsd | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
# default is bash, but we need sh on freebsd | |
config.ssh.shell = "sh" | |
# install scm-manager | |
config.vm.provision "shell", inline: <<-SHELL | |
# install wget and java | |
pkg install -y wget $(pkg search ^openjdk | grep openjdk11-11 | awk '{print $1}') | |
# mount proc and fdesc this seems to be required by java | |
echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab | |
echo "proc /proc procfs rw 0 0" >> /etc/fstab | |
mount /dev/fd | |
mount /proc | |
# switch to our install location | |
cd /usr/local | |
# create out scm home directory | |
mkdir -p /var/lib/scm | |
# create user and group, so we don't have to run scm-manager as root | |
pw group add -n scm | |
pw user add -n scm -c 'SCM-Manager' -g scm -d /var/lib/scm | |
# change the ownership of our home directory | |
chown scm:scm /var/lib/scm | |
# download and extract scm-manager package for unix | |
# TODO get rid of --no-check-certificate | |
wget --no-check-certificate https://packages.scm-manager.org/repository/releases/sonia/scm/packaging/unix/2.1.0/unix-2.1.0-app.tar.gz | |
tar xvfz unix-2.1.0-app.tar.gz | |
rm -f unix-2.1.0-app.tar.gz | |
# freebsd has no preinstalled bash | |
# TODO we should check why we use bash at all | |
sed -i'.bak' 's@/bin/bash@/bin/sh@' /usr/local/scm-server/bin/scm-server | |
# move work directory to /var/cache/scm/work | |
# i don't know if this makes, but we do this on linux | |
cd scm-server | |
mkdir -p /var/cache/scm/work | |
chown -R scm:scm /var/cache/scm | |
rm -rf work | |
ln -s /var/cache/scm/work | |
# create run directory to store service pid | |
mkdir -p /var/run/scm | |
chown scm:scm /var/run/scm | |
# TODO do we need this | |
chown scm /usr/local/scm-server/var | |
chown scm /usr/local/scm-server/bin/scm-server | |
# configure home directory of scm-manager service (scmserver) | |
echo "export SCM_HOME=/var/lib/scm" >> /etc/rc.conf.d/scmserver | |
chmod +x /etc/rc.conf.d/scmserver | |
# create service for scm-manager (scmsever) | |
# scm-server cause trouble so we use scmserver | |
cat <<'EOF'>/etc/rc.d/scmserver | |
#!/bin/sh | |
# PROVIDE: scmserver | |
# REQUIRE: LOGIN | |
# KEYWORD: shutdown | |
# | |
# Add the following line to /etc/rc.conf to enable 'scmserver': | |
# | |
# scmserver_enable="YES" | |
. /etc/rc.subr | |
name=scmserver | |
rcvar=scmserver_enable | |
load_rc_config ${name} | |
: ${scmserver_enable:=NO} | |
: ${scmserver_user:=scm} | |
: ${scmserver_group:=scm} | |
: ${scmserver_chdir=/var/lib/scm} | |
pidfile="/var/run/scm/${name}.pid" | |
procname="/usr/local/openjdk11/bin/java" | |
command="/usr/sbin/daemon" | |
command_args="-f -p ${pidfile} /usr/local/scm-server/bin/scm-server" | |
run_rc_command "$1" | |
EOF | |
chmod +x /etc/rc.d/scmserver | |
# enable scmserver on startup | |
echo 'scmserver_enable="YES"' >> /etc/rc.conf | |
# start it now | |
/etc/rc.d/scmserver start | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment