#!/bin/sh
# What a fresh install has to do, on a machine that is already running Alpine.
#
# package() writes three init scripts and puts none of them in a runlevel, and
# the one thing that ever does is the first boot itself -- which is a service,
# so nothing ran it either. The ISO is fine: its overlay adds
# nuxpbx-firstboot to the default runlevel. The documented `apk add nuxpbx`
# was not, and left a machine with the package on it and no phone system,
# recovering only if the person read the second half of docs/install.md and
# typed the start below by hand. apk runs post-upgrade and not this one on an
# upgrade, and never falls back the other way, so the two halves are separate
# scripts. Debian's postinst has called the first boot on a fresh configure
# all along; this is the same two lines in OpenRC's spelling.
rc-update add nuxpbx-firstboot default >/dev/null 2>&1 || true

# Started as well as added, because a runlevel is read at the next boot and
# nobody installs a phone system to have one next month. The service returns
# at once on live media and on a machine that is already set up, so this is
# safe wherever apk runs it -- including inside the chroot setup-disk installs
# into, where / is the ISO's overlay and there is nothing yet to set up.
rc-service nuxpbx-firstboot start >/dev/null 2>&1 || true

exit 0
