diff --git a/changelog.d/opt-init.d-migrations.change b/changelog.d/opt-init.d-migrations.change new file mode 100644 index 000000000..c53f2baa0 --- /dev/null +++ b/changelog.d/opt-init.d-migrations.change @@ -0,0 +1 @@ +- OpenRC: Automatically run migrations before starting pleroma diff --git a/installation/init.d/pleroma b/installation/init.d/pleroma index cb6635a0b..3b584bd45 100755 --- a/installation/init.d/pleroma +++ b/installation/init.d/pleroma @@ -37,6 +37,13 @@ depend() { need nginx postgresql } +start_pre() { + ebegin "running migrations if any" + su -s /bin/sh -c "cd \"${directory}\" && exec /usr/bin/mix ecto.migrate" \ + "${command_user%%:*}" + eend "$?" +} + healthcheck() { # put pleroma_health=YES in /etc/conf.d/pleroma if you want healthchecking # and make sure you have curl installed diff --git a/rel/files/installation/init.d/pleroma b/rel/files/installation/init.d/pleroma index ca5b842e1..2d3977e41 100755 --- a/rel/files/installation/init.d/pleroma +++ b/rel/files/installation/init.d/pleroma @@ -17,6 +17,13 @@ retry="SIGTERM/30/SIGKILL/5" pidfile="/var/run/pleroma.pid" depend() { - want nginx - need postgresql + want nginx + need postgresql +} + +start_pre() { + ebegin "running migrations if any" + su -s /bin/sh -c "cd \"${directory}\" && exec /opt/pleroma/bin/pleroma_ctl migrate" \ + "${command_user%%:*}" + eend "$?" }