/usr/lib/python3.6/site-packages/cloudinit/distros
NameSizeModeActions
package_management/-0755rm
parsers/-0755rm
__pycache__/-0755rm
almalinux.py1510644editdlrm
alpine.py85830644editdlrm
amazon.py5920644editdlrm
arch.py87100644editdlrm
bsd.py52040644editdlrm
bsd_utils.py14300644editdlrm
centos.py1510644editdlrm
cloudlinux.py1510644editdlrm
cos.py2470644editdlrm
debian.py100760644editdlrm
dragonflybsd.py2300644editdlrm
eurolinux.py1510644editdlrm
fedora.py4370644editdlrm
freebsd.py76320644editdlrm
gentoo.py93320644editdlrm
mariner.py16920644editdlrm
miraclelinux.py1510644editdlrm
netbsd.py48980644editdlrm
networking.py110110644editdlrm
net_util.py65500644editdlrm
openbsd.py19100644editdlrm
OpenCloudOS.py2770644editdlrm
openeuler.py2750644editdlrm
openmandriva.py2370644editdlrm
opensuse-leap.py2470644editdlrm
opensuse-microos.py2470644editdlrm
opensuse-tumbleweed.py2470644editdlrm
opensuse.py100880644editdlrm
photon.py53040644editdlrm
rhel.py76790644editdlrm
rhel_util.py14290644editdlrm
rocky.py1510644editdlrm
sle-micro.py2470644editdlrm
sles.py2470644editdlrm
sle_hpc.py2470644editdlrm
suse.py810644editdlrm
TencentOS.py2770644editdlrm
ubuntu.py17970644editdlrm
ug_util.py99800644editdlrm
virtuozzo.py1510644editdlrm
__init__.py524170644editdlrm
Edit: /usr/lib/python3.6/site-packages/cloudinit/distros/bsd_utils.py (1430B)
# This file is part of cloud-init. See LICENSE file for license information. import shlex from cloudinit import util # On NetBSD, /etc/rc.conf comes with a if block: # if [ -r /etc/defaults/rc.conf ]; then # as a consequence, the file is not a regular key/value list # anymore and we cannot use cloudinit.distros.parsers.sys_conf # The module comes with a more naive parser, but is able to # preserve these if blocks. def _unquote(value): if value[0] == value[-1] and value[0] in ['"', "'"]: return value[1:-1] return value def get_rc_config_value(key, fn="/etc/rc.conf"): key_prefix = "{}=".format(key) for line in util.load_file(fn).splitlines(): if line.startswith(key_prefix): value = line.replace(key_prefix, "") return _unquote(value) def set_rc_config_value(key, value, fn="/etc/rc.conf"): lines = [] done = False value = shlex.quote(value) original_content = util.load_file(fn) for line in original_content.splitlines(): if "=" in line: k, v = line.split("=", 1) if k == key: v = value done = True lines.append("=".join([k, v])) else: lines.append(line) if not done: lines.append("=".join([key, value])) new_content = "\n".join(lines) + "\n" if new_content != original_content: util.write_file(fn, new_content)