Skip to content

Commit

Permalink
hack(sysvinit): On *BSD, create /run as symlink (canonical#4677)
Browse files Browse the repository at this point in the history
On *BSD, `/run` is not ephemeral, but the way cloud-init behaves, it
expects it to be.
This is hack is partial fix for canonicalGH-4180 / canonicalGH-4231.
But to be good Unix citizens, we should still make /run relocatable in
the code and in the installer.

Sponsored by: The FreeBSD Foundation
Fixes canonicalGH-4180
Fixes canonicalGH-4231
  • Loading branch information
igalic committed Dec 8, 2023
1 parent 949af54 commit fd67571
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sysvinit/freebsd/cloudinitlocal.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ PATH="{{ prefix }}/sbin:{{ prefix }}/bin:/usr/sbin:/usr/bin:/sbin:/bin"

name="cloudinitlocal"
command="{{prefix}}/bin/cloud-init"
start_precmd="cloudlocal_precmd"
start_cmd="cloudlocal_start"
stop_cmd=":"
rcvar="cloudinit_enable"

cloudlocal_precmd()
{
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
}

cloudlocal_start()
{
echo -n "${command} starting"
Expand Down
9 changes: 9 additions & 0 deletions sysvinit/freebsd/dsidentify.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ PATH="{{ prefix }}/sbin:{{ prefix }}/bin:/usr/sbin:/usr/bin:/sbin:/bin"

name="dsidentify"
command="{{ prefix }}/lib/cloud-init/ds-identify"
start_precmd="dsidentify_precmd"
start_cmd="dsidentify_start"
stop_cmd=":"
rcvar="cloudinit_enable"

dsidentify_precmd()
{
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
}

dsidentify_start()
{
if checkyesno cloudinit_dsidentify_enable; then
Expand Down
10 changes: 10 additions & 0 deletions sysvinit/netbsd/cloudinitlocal.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ That makes it easy for image builders to create images without ``dsidentify``.
$_rc_subr_loaded . /etc/rc.subr

name="cloudinitlocal"
start_precmd="cloud_init_local_precmd"
start_cmd="start_cloud_init_local"

cloud_init_local_precmd()
{
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
}

start_cloud_init_local()
{
test -e {{prefix}}/etc/cloud/cloud-init.disabled \
Expand Down
10 changes: 10 additions & 0 deletions sysvinit/netbsd/dsidentify.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
$_rc_subr_loaded . /etc/rc.subr

name="dsidentify"
start_precmd="dsidentify_precmd"
start_cmd="start_dsidentify"

dsidentify_precmd()
{
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
}

start_dsidentify()
{
test -e {{prefix}}/etc/cloud/cloud-init.disabled \
Expand Down
7 changes: 7 additions & 0 deletions sysvinit/openbsd/cloudinitlocal.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ daemon_user=root
rc_bg="YES" # (undefined or "YES")
rc_usercheck="YES"

rc_pre() {
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
}

rc_start() {
if test -e /etc/cloud/cloud-init.disabled; then
echo -n "cloud-init is disabled via cloud-init.disabled file." | logger -t ${daemon}
Expand Down
5 changes: 5 additions & 0 deletions tools/build-on-openbsd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ else
RC_LOCAL="/etc/rc.local"
RC_LOCAL_CONTENT="
if ! test -L /run ; then
rm -rf /run
ln -s /var/run /run
fi
/usr/lib/cloud-init/ds-identify
cloud-init init --local
Expand Down

0 comments on commit fd67571

Please sign in to comment.