Got it running in Freenas 9.10 jail, based on
this postgresql-how-to,
tonyschuite's instructions and
this doc.
I used only pkg & ports to install all packages.
cpanm too but I avoided using carton altogether.
pkg upgrading & other stuff tends to break the postgresql startup & service scripts.
I had to replace them with my own.
Install sudo to autorun the db as user musicbrainz.
Create the user first.
Also, create the folder /var/log/postgresql.
This is /usr/local/etc/rc.d/postgresql
Code:
#!/bin/sh
. /etc/rc.subr
name=postgresql
rcvar=postgresql_enable
start_precmd="${name}_prestart"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
postgresql_prestart() {
if ! checkyesno postgresql_enable && ! /etc/rc.d/postgresql forcestatus 1>/dev/null 2>&1; then
force_depend postgresql || return 1
fi
return 0
}
postgresql_start() {
/usr/local/bin/sudo -u musicbrainz /usr/local/bin/pg_ctl start -s -l /var/log/postgresql/log -D /usr/local/pgsql/data
}
postgresql_stop() {
/usr/local/bin/sudo -u musicbrainz /usr/local/bin/pg_ctl stop -s -l /var/log/postgresql/log -D /usr/local/pgsql/data
}
load_rc_config $name
run_rc_command "$1"
Then I created /usr/local/etc/rc.d/musicbrainz to be able to start/stop the musicbrainz service
It's kinda shady, I know.
Code:
#!/bin/sh
. /etc/rc.subr
name=musicbrainz
rcvar=musicbrainz_enable
start_precmd="${name}_prestart"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
musicbrainz_prestart() {
if ! checkyesno musicbrainz_enable && ! /etc/rc.d/postgresql forcestatus 1>/dev/null 2>&1; then
force_depend postgresql || return 1
fi
return 0
}
musicbrainz_start() {
cd /musicbrainz-server
/usr/local/bin/plackup --daemonize -Ilib -r &
}
musicbrainz_stop() {
pkill -f plackup
}
load_rc_config $name
run_rc_command "$1"
Put
Code:
musicbrainz_enable="YES"
in /etc/rc.conf to autostart with the jail.
For replication, I had to patch to
v-2016-05-23-schema-change-v2 using git checkout -f
After that I cronned
/musicbrainz-server/admin/replication/LoadReplicationChanges
once a day
Freenas server has the following cronjob (tasks --> cronjobs)
Code:
jexec 33 /usr/local/bin/perl /musicbrainz-server/admin/replication/LoadReplicationChanges
*UPDATE* something is broken again by patching. Autostarting no longer works & my attempt to daemonize plackup needs rewriting.
*UPDATE 20/6/2016* autostart remains a mistery. At jail start I manually launch postgress and musicbrainz from the commands above.