Iocage: overwrites rc.conf when creating from template

Created on 2 Jun 2017  路  6Comments  路  Source: iocage/iocage

root@firestar:/home/muad/iocage # iocage -v
Version 0.9.8 BETA

root@firestar:/home/muad/iocage # iocage create -t wpTemplate tag="wp_testme2"
9493a833-08f5-48b3-846e-d4abb7c2885e (wp_testme2) successfully created!

root@firestar:/home/muad/iocage # cat /iocage/tags/wp_testme2/root/etc/rc.conf

wp_testme2 rc.conf

host_hostname="9493a833-08f5-48b3-846e-d4abb7c2885e"
cron_flags="$cron_flags -J 15"

Disable Sendmail by default

sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

Run secure syslog

syslogd_flags="-c -ss"

Enable IPv6

ipv6_activate_all_interfaces="YES"

root@firestar:/home/muad/iocage # cat /iocage/templates/wpTemplate/root/etc/rc.conf

from the template rc.conf

host_hostname="wpTemplate.h.l9"
cron_flags="$cron_flags -J 15"

Disable Sendmail by default

sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

Run secure syslog

syslogd_flags="-c -ss"

Enable IPv6

ipv6_activate_all_interfaces="YES"
mysql_enable="YES"
nginx_enable="YES"
php_fpm_enable="YES"

ioc_create.py

def create_rc(self, location, host_hostname)
needs too check if there is a rc.conf and leave if there is one I recond,

or how I would solved this

rc_set('host_hostname="wpTemplate.h.l9"')

def rc_set(self, rc_var):
cmd = f"sysrc -j ioc-{jail_uuid} {rc_var}"
args = split(cmd)
result = subprocess.run(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)

rewriting the whole rc.conf is in my opinion a bad idea
something like that would also let iocage have the possibility too set rc.conf vars after creation
Just an idea that i had, no time gotta run wifey calls. Shopping she says

bug

All 6 comments

I'm not sure what you're saying here, the creation did what was expected, that is it replaced the hostname in the rc.conf. The sysrc command would require the jail to be running for that iirc, replacing the file is a fine thing to do in this circumstance.

Unless I'm misunderstanding you?

the problem is that the template rc.conf is being replaced with your standard rc.conf from rc_create making all changes that has been done in the template rc.conf useless.
Not only does it change the rc.conf hostname but it changes all of the rc.conf contents, look at the cat rc.conf diffrence

sysrc does not need a running jail too function it could be set to alter rc.conf without a running jail,

from the man sysrc

-f file Operate on the specified file(s) instead of the files obtained
by reading the `rc_conf_files' entry in the RC_DEFAULTS file.
This option can be specified multiple times for additional
files.

-R dir Operate within the root directory dir' rather than/'.

I have the fortune that i always have a running jail to work on thanks too iocage so i havent had the need too alter rc.conf without it running, but in my research i found that it could most likely do the same without having to start the jail before altering its rc.conf.

Oh I see the difference now! Sorry the weird formatting made it a bit hard for me to parse. Interesting, I'll look into this more. Thanks for the suggestion!

I have cleaned it up abit, not used to github formatting.
sorry :)

Alright @kitten77 it is now all implemented 馃憤, please test and let me know!

Was this page helpful?
0 / 5 - 0 ratings