Commit fff1d27e authored by Nikos Skalkotos's avatar Nikos Skalkotos

Merge branch 'release-0.19'

parents 0f9dd60c b54f681a
2016-01-19, v0.19rc2
* Fix version files
2016-01-19, v0.19rc1
* Support Windows XP/2003 (windows-legacy OSFAMILY)
* Support 32-bit versions of Windows
* Add new os_product_key and os_answer_file OS parameters
* Allow offline resizing for NTFS
* Cleanup the default Unattend.xml file
* Allow defining the Windows time zone in the default Unattend.xml file
* Add new image configuration task that executes user defined code
* Allow the image itself to overwrite configuration tasks that run
during deployment when the image is mounted
* Support Ed24419 ssh keys
* Support making swap in secondary disk
* Strip down the helper kernel (reduces helper image size)
* Support Debian Jessie helpers
* Fix bugs and cleanup the code
* Update the documentation
2015-03-13, v0.18.1
* HELPER: Fix a bug in ConfigureNetwork task that caused a syntax error
if the SUBNET was missing for a NIC
2015-03-03, v0.18
* HELPER: Auto-detect OSFAMILY and ROOT_PARTITION properties if missing
* HELPER: Add new CofigureNetwork image configuration task
......
......@@ -24,7 +24,7 @@ for more information.
Copyright and license
=====================
Copyright (C) 2011-2014 GRNET S.A.
Copyright (C) 2011-2016 GRNET S.A. and individual contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,6 +41,20 @@ some external programs in ``/etc/default/snf-image``:
# HELPER_MEMORY: Virtual RAM size in megabytes to be given to the helper VM.
# HELPER_MEMORY="512"
# HELPER_DEBUG: When enabled, the helper VM will drop to a root shell
# whenever a task fails. This allows the administrator or a developer
# to examine its internal state for debugging purposes.
# To access the shell, use a program like 'minicom' to connect to /dev/pts/X on
# the host, where /dev/pts/X is the name of the device reported in the Ganeti
# OS installation logs for helper's 3rd serial port, e.g.,
# "char device redirected to /dev/pts/9 (label serial3)".
# This feature is KVM-specific for the time being.
# For HELPER_DEBUG to be useful, you also need to set HELPER_SOFT_TIMEOUT
# to a much higher value.
# WARNING: DO NOT ENABLE THIS FEATURE IN PRODUCTION. Every failure to deploy
# an Image will cause the helper VM to hang.
# HELPER_DEBUG="no"
# MULTISTRAP_CONFIG: Configuration file to be used with multistrap to create
# the rootfs of the helper image.
# MULTISTRAP_CONFIG="/etc/snf-image/multistrap.conf"
......@@ -52,6 +66,12 @@ some external programs in ``/etc/default/snf-image``:
# XEN_SCRIPTS_DIR: Directory where the Xen scripts are stored
# XEN_SCRIPTS_DIR="/etc/xen/scripts"
# XEN_CMD: This variable specifies the Xen CLI tool snf-image should use. This
# depends on the XEN version and configuration and should probably coincide
# with the Ganeti's xen_cmd hypervisor parameter for xen-hvm or xen-pvm. Right
# now the supported ones are 'xm' and 'xl'.
# XEN_CMD="xl"
# PITHOS_DB: Pithos database in SQLAlchemy format
# PITHOS_DB="sqlite://///var/lib/pithos/backend.db"
......@@ -101,14 +121,24 @@ some external programs in ``/etc/default/snf-image``:
# will configure a VM's NIC to perform SLAAC and Stateless DHCPv6 if the card
# is expected to have an IPv6 address and any of those tags is present in the
# card's NETWORK_TAGS variable.
# STATELESS_DHCPV6_TAGS="nfdhcpd stateless_dhcpv6
# STATELESS_DHCPV6_TAGS="nfdhcpd stateless_dhcpv6"
# UNATTEND: This variable overwrites the unattend.xml file used when deploying
# a Windows image. snf-image-helper will use its own unattend.xml file if this
# variable is empty. Please leave this empty, unless you really know what you
# are doing.
# variable is empty.
# WARNING: This variable is DEPRECATED. If you need to define an answer file
# different that the one shipped with snf-image, which is very likely, put it
# inside the image or use the os_answer_file OS parameter.
# UNATTEND=""
# WINDOWS_TIMEZONE: This variable is used to specify the time zone when
# deploying a Windows image. This will only work if you are using snf-image's
# default OS answer file. If the Windows image already contains an answer file
# or the os_answer_file OS parameter is used to define one, this variable will
# be completely ignored. For a list of available time zones, check here:
# https://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx
# WINDOWS_TIMEZONE="GMT Standard Time"
# Paths for needed programs. Uncomment and change the variables below if you
# don't want to use the default one.
# MD5SUM="md5sum"
......@@ -121,6 +151,8 @@ some external programs in ``/etc/default/snf-image``:
# CURL="curl"
# TAR="tar"
.. _configuration-parameters:
Configuration parameters
^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -138,6 +170,9 @@ The most common configuration parameters the user may need to overwrite are:
* **STATELESS_DHCPV6_TAGS**: To specify which Ganeti networks support SLAAC
and stateless DHCPv6
* **STATEFUL_DHCPV6_TAGS**: To specify which Ganeti networks support DHCPv6
* **WINDOWS_TIMEZONE**: To specify a time zone to use when deploying Windows
images that do not host an Unattend.xml file and depend on the one provided
by *snf-image*.
Paths of external programs
^^^^^^^^^^^^^^^^^^^^^^^^^^
......
Development
===========
Building a new snf-image-helper kernel
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The kernel used to boot the helper VM is custom. We build our own kernel
because the ones shipped with the major Linux distributions don't have UFS
write support enabled, since it is considered dangerous. The ability to write
to UFS file systems is needed in order to support the various \*BSD images. In
this tutorial we will show how to build a Debian Kernel package using the
kernel configuration shipped with the snf-image. The kernel configuration file
we provide with snf-image is stripped down. All unnecessary hardware drivers
are removed and only the ones that are needed to boot a KVM and a XEN guest are
left. In order to recompile a Debian kernel using our configuration file do the
following:
Install the dependencies
++++++++++++++++++++++++
Install the dependencies for compiling a kernel:
.. code-block:: console
# apt-get install build-essential fakeroot
# apt-get build-dep linux
Download the kernel package:
.. code-block:: console
$ apt-get source linux
Build the packages
++++++++++++++++++
Apply the existing patches:
.. code-block:: console
$ fakeroot debian/rules source
Setup the amd64 configuration:
.. code-block:: console
$ cd linux-<version>
$ fakeroot make -f debian/rules.gen setup_amd64_none
Copy the snf-image provided configuration to the new kernel:
.. code-block:: console
$ cp /usr/share/doc/snf-image/kconfig-* debian/build/build_amd64_none_amd64/.config
Apply the kernel configuration:
.. code-block:: console
$ make -C debian/build/build_amd64_none_amd64 oldconfig
$ cp debian/build/build_amd64_none_amd64/.config debian/build/config.amd64_none_amd64
Change the ABI name (the debian building system will complain otherwise):
.. code-block:: console
$ sed -i 's|abiname: .\+|abiname: 0.snf.image.helper.1|' debian/config/defines
Add a new entry in ``debian/changelog`` with ``jessie-helper`` as distribution:
.. code-block:: console
$ dch -D jessie-helper --force-distribution
Build the new kernel package:
.. code-block:: console
$ fakeroot make -j <num> -f debian/rules.gen binary-arch_amd64_none
Upload it to an apt repository
++++++++++++++++++++++++++++++
If you want to upload the package to a repository, you will need to create a
changes file:
.. code-block:: console
$ cp ../linux_<old_version>.dsc ../linux-<new_version>.dsc
$ dpkg-genchanges > ../lunux_<new_version>.changes
And sign it:
.. code-block:: console
$ debsign ../linux_<new_version>.changes
Now you can use ``dput`` or ``dupload`` to upload the package to a repository.
......@@ -29,7 +29,7 @@ successfully deploy many major Linux distributions (Debian, Ubuntu/Kubuntu,
CentOS, Fedora, OpenSUSE, Slackware, Arch Linux, CoreOS), Windows Server
flavors (2008 R2, 2012, 20012 R2), as well as BSD systems (FreeBSD, OpenBSD,
NetBSD). It is also known to work well with current Desktop versions of Windows
(7, 8, 8.1).
(7, 8, 8.1) as well as Windows XP.
The snf-image Ganeti OS Definition is released under
`GPLv2 <http://www.gnu.org/licenses/gpl-2.0.html>`_.
......@@ -47,6 +47,7 @@ Contents:
configuration
usage
advanced
development
Indices and tables
==================
......
......@@ -13,11 +13,17 @@ following OS Parameters:
the image (:ref:`details <image-id>`)
* **img_passwd** (optional): the password to be injected into the image
(:ref:`details <image-passwd>`)
* **img_passwd_hash** (optional): the hash of the password to be injected into
the image (:ref:`details <image-passwd-hash>`)
* **img_properties** (optional): additional image properties used to customize
the image (:ref:`details <image-properties>`)
* **img_personality** (optional): files to be injected into the image's file
system (:ref:`details <image-personality>`)
* **config_url** (optional): the URL to download configuration data from
* **os_product_key** (optional): a product key to be used to license a Windows
deployment (windows-only)
* **os_answer_file** (optional): an answer file used by Windows to automate
the setup process, instead the default one (windows-only)
.. _image-format:
......@@ -89,8 +95,22 @@ Image Password (img_passwd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value of this parameter is the password to be injected into the image. If
this parameter is not set at all, then the *ChangePassword* task (see
this parameter is not set at all and **img_passwd_hash** is missing too, then
the *ChangePassword* task (see
:ref:`Image Configuration Tasks <image-configuration-tasks>`) will not run.
This parameter cannot be defined in conjunction with **img_passwd_hash**.
.. _image-passwd-hash:
Image Password Hash (img_passwd_hash)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value of this parameter is the hash of the password to be injected into the
image. If this parameter is not set at all and **img_passwd** is missing too,
then the *ChangePassword* task (see
:ref:`Image Configuration Tasks <image-configuration-tasks>`) will not run.
This parameter is not applicable on Windows images and cannot be defined in
conjunction with **img_passwd**.
.. _image-properties:
......@@ -113,8 +133,9 @@ A list of all properties follows:
Diskdump only properties
++++++++++++++++++++++++
* **OSFAMILY=linux|windows|freebsd|netbsd|openbsd**
This specifies whether the image is a Linux, a Windows or a \*BSD Image.
* **OSFAMILY=linux|windows|windows-legacy|freebsd|netbsd|openbsd**
This specifies whether the image is a Linux, a Windows or a \*BSD Image. For
Windows OSes prior to Vista, *windows-legacy* should be used.
*{ext,ntfs}dump* formats are self descriptive regarding this property.
* **ROOT_PARTITION=n**
This specifies the partition number of the root partition. As mentioned
......@@ -138,13 +159,13 @@ All image formats properties
* For Windows images, the *Administrator*'s password is reset.
* For Linux and \*BSD images, the *root* password is reset.
* **DO_SYNC=yes**
* **DO_SYNC=bool**
By default in ResizeUnmounted task, when ``resize2fs`` is executed to
enlarge a ext[234] file system, ``fsync()`` is disabled to speed up the
whole process. If for some reason you need to disable this behavior, use the
*DO_SYNC* image property.
* **IGNORE_UNATTEND=yes**
* **IGNORE_UNATTEND=bool**
When deploying a Windows image, the InstallUnattend configuration task will
install an Answer File for Unattended Installation (the one shipped with
*snf-image* or the one pointed out by the *UNATTEND* configuration
......@@ -154,6 +175,29 @@ All image formats properties
exists in the above-mentioned location. For more information on "answer
files" please refer to :ref:`windows-deployment`.
* **ALLOW_MOUNTED_TASK_OVERWRITING=bool**
If this property is defined with yes, then the presence of an executable
file under */root/snf-image/helper/overwrite_task_<TASK>* inside the image
will make *snf-image* execute the code hosted there instead of the default
one. See :ref:`Overwriting Configuration Tasks<overwriting-configuration-tasks>`
for more info.
* **OFFLINE_NTFSRESIZE=bool**
When deploying a Windows Image, perform an offline NTFS resize, instead of
setting up the Unattend.xml file so SYSPREP executes a custom DISKPART
script to perform an online resize during the first boot. Note NTFS is left
dirty and will be checked automatically on first boot when performing an
offline NTFS resize. Set the *OFFLINE_NTFSRESIZE_NOCHECK* property to yes to
disable this behavior (this is dangerous). For more information on "answer
files" please refer to :ref:`windows-deployment`.
* **OFFLINE_NTFSRESIZE_NOCHECK=bool**
Set this property to yes to skip the NTFS check performed by Windows upon
the first boot when performing an offline NTFS resize (see the
*OFFLINE_NTFSRESIZE* property). Skipping the initial filesystem check is
dangerous, as it may lead to bugs of the offline NTFS resize procedure going
undetected.
* **PASSWD_HASHING_METHOD=md5|sha1|blowfish|sha256|sha512**
This property can be used on Unix instances to specify the method to be used
to hash the users password. By default this is determined by the type of the
......@@ -163,25 +207,44 @@ All image formats properties
`here <http://pythonhosted.org/passlib/modular_crypt_format.html#mcf-identifiers>`_
for more info).
* **SWAP=<partition id>:<size>**
If this property is defined, *snf-image* will create a swap partition with
the specified size in MB. The *partition id* is the number that the Linux
* **SWAP=<partition id>:<size>|<disk letter>**
If this property is defined, *snf-image* will create a swap device in the
VM. If the first form is used, then a swap partition with the specified size
in MB will be created. The *partition id* is the number that the Linux
kernel will assign to this partition. For example, if you have a disk with
an MSDOS partition table on it and one primary partition, the image
property *SWAP=2:512* would instruct *snf-image* to create a 512MB long
primary partition for swap with id=2. On the other hand, if the *SWAP*
property had this form: *SWAP=5:512*, since primary partitions may have an
id from 1 to 4, *snf-image* would create a 512MB extended partition with
id=2 and a logical swap partition with id=5 in it with the same size. This
property only applies to Linux instances.
* **EXCLUDE_ALL_TASKS=yes**
If this property is defined with a value other than null, then during the
deployment, the image will not be configured at all. This is really handy
because it gives the ability to deploy images hosting operating systems
whose configuration is not supported by *snf-image*.
* **EXCLUDE_TASK_<task_name>=yes**
an MSDOS partition table on it and one primary partition, an image property:
*SWAP=2:512* would instruct *snf-image* to create a 512MB long primary
partition for swap with id=2. On the other hand, if the *SWAP* property was
defined like this: *SWAP=5:512*, since primary partitions may have an id
from 1 to 4, *snf-image* would create a 512MB extended partition with id=2
and a logical swap partition of the same size with id=5 in it. If the second
form is specified, then a whole secondary disk will be configured
to be swap. Defining *SWAP=c* will configure the third disk of the VM to be
swap.This property only applies to Linux instances.
* **CUSTOM_TASK=<base64_encoded_content>**
This property can be used to run a user-defined configuration task. The
value of this property should host the base64-encoded body of the task. If
you want to write a custom configuration task check
:ref:`Configuration Tasks Environment<configuration-tasks-environment>`.
* **EXCLUDE_ALL_TASKS=bool**
If this property is defined with a yes value, the image will not be
configured at all, during the deployment. This is really handy because it
gives the ability to deploy images hosting operating systems whose
configuration is not supported by *snf-image*.
* **EXCLUDE_MOUNTED_TASKS=bool**
If this property is defined, then only the tasks that are meant to run
before the VM's disk gets mounted (namely *FixPartitionTable* and
*FilesystemResizeUmounted*) will be allowed to run during deployment.
* **EXCLUDE_FilesystemResize_TASKS=bool**
If this property is defined with a yes value, the 3 filesystem resize tasks
(*FilesystemResizeUnmounted*, *FilesystemResizeMounted*,
*FilesystemResizeAfterUmount*) will be prevented from running.
* **EXCLUDE_TASK_<task_name>=bool**
This family of properties gives the ability to exclude individual
configuration tasks from running. Hence, if the property
*EXCLUDE_TASK_DeleteSSHKeys* with a value other than null is passed to
......@@ -194,6 +257,10 @@ All image formats properties
will probably end up with an unsuccessful deployment because B will fail and
exit in an abnormal way. You can read more about configuration tasks here.
.. note:: All boolean properties are treated as follows: yes is assumed to be
either yes, true, 1, on, and set while no is assumed to be no, false, 0, off,
and unset. An empty or not-set property is treated as false.
img_properties OS parameter
+++++++++++++++++++++++++++
......
......@@ -23,6 +23,8 @@ Options
-h Print this message
-n Don't shrink the resulting image (useful when debugging)
-p PACKAGE
Install this deb package in the helper image, instead of the default
......
......@@ -23,10 +23,10 @@ that have been tested with *snf-image* and provided here for testing purposes:
[`diskdump <https://cdn.synnefo.org/centos-7-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/centos-7-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/centos-7-x86_64.diskdump.meta>`_]
* Fedora Desktop 21
[`diskdump <https://cdn.synnefo.org/fedora-21-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/fedora-21-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/fedora-21-x86_64.diskdump.meta>`_]
* Fedora Desktop 23
[`diskdump <https://cdn.synnefo.org/fedora-23-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/fedora-23-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/fedora-23-x86_64.diskdump.meta>`_]
* Ubuntu Desktop LTS 14.04
[`diskdump <https://cdn.synnefo.org/ubuntu_desktop-14.04-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/ubuntu_desktop-14.04-x86_64.diskdump.md5sum>`_]
......@@ -39,22 +39,18 @@ that have been tested with *snf-image* and provided here for testing purposes:
[`diskdump <https://cdn.synnefo.org/opensuse_desktop-13.2-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/opensuse_desktop-13.2-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/opensuse_desktop-13.2-x86_64.diskdump.meta>`_]
* Oracle Linux 6.x
[`diskdump <https://cdn.synnefo.org/oraclelinux-6-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/oraclelinux-6-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/oraclelinux-6-x86_64.diskdump.meta>`_]
* FreeBSD 10.0
[`diskdump <https://cdn.synnefo.org/freebsd-10.0-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/freebsd-10.0-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/freebsd-10.0-x86_64.diskdump.meta>`_]
* OpenBSD 5.5
[`diskdump <https://cdn.synnefo.org/openbsd-5.5-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/openbsd-5.5-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/openbsd-5.5-x86_64.diskdump.meta>`_]
* NetBSD 6.1
[`diskdump <https://cdn.synnefo.org/netbsd-6.1-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/netbsd-6.1-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/netbsd-6.1-x86_64.diskdump.meta>`_]
* Oracle Linux 7.x
[`diskdump <https://cdn.synnefo.org/oraclelinux-7-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/oraclelinux-7-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/oraclelinux-7-x86_64.diskdump.meta>`_]
* FreeBSD 10.2
[`diskdump <https://cdn.synnefo.org/freebsd-10.2-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/freebsd-10.2-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/freebsd-10.2-x86_64.diskdump.meta>`_]
* NetBSD 7.0
[`diskdump <https://cdn.synnefo.org/netbsd-7.0-x86_64.diskdump>`_]
[`md5sum <https://cdn.synnefo.org/netbsd-7.0-x86_64.diskdump.md5sum>`_]
[`metadata <https://cdn.synnefo.org/netbsd-7.0-x86_64.diskdump.meta>`_]
Sample Usage
^^^^^^^^^^^^
......
__version__ = "0.18.1"
__version__ = "0.19rc2"
# This is the official list of contributors for copyright purposes.
GRNET S.A.
Vangelis Koukis <vkoukis@gmail.com>
......@@ -6,10 +6,11 @@ export commondir networkingdir scriptsdir tasksdir
SUBDIRS = tasks networking
dist_doc_DATA = COPYING AUTHORS
dist_doc_DATA = COPYING AUTHORS CONTRIBUTORS
dist_bin_SCRIPTS = snf-image-helper
dist_scripts_SCRIPTS= hashpwd.py inject-files.py decode-properties.py disklabel.py
dist_common_DATA = common.sh unattend.xml
dist_scripts_SCRIPTS= hashpwd.py inject-files.py decode-properties.py \
disklabel.py handle-ini-file.py
dist_common_DATA = common.sh
edit = sed \
-e 's|@commondir[@]|$(commondir)|g' \
......
This diff is collapsed.
#!/usr/bin/env python
#
# Copyright (C) 2015 GRNET S.A. and individual contributors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Get or set a configuration variable inside an INI file.
Could have used Python's ConfigParser for this,
but it breaks with sloppily-formatted Windows SYSPREP.INF
answer files.
"""
import re
import sys
import os.path
import argparse
def main():
DESCRIPTION = "Get or set a configuration variable in a INI file"
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument("path", metavar="FILE",
help="Path to INI file")
parser.add_argument("action", metavar="ACTION",
help="Action to perform: Must be `get' or `set'.")
parser.add_argument("section", metavar="SECTION",
help="The section containing the option. If the"
" section does not exist, it will be created.")
parser.add_argument("key", metavar="KEY",
help="The name of the variable. If it does not"
" exist it, will be added to the specified"
" section.")
parser.add_argument("value", metavar="VALUE", nargs="?",
help="The value of the variable to set.",
default="")
args = parser.parse_args()
if args.action != "get" and args.action != "set":
raise ValueError("ACTION must be `get' or `set'")
if args.action == "set" and args.value == "":
raise ValueError("VALUE is required if ACTION is `set'")
update = (args.action == "set")
section = args.section
key = args.key
value = args.value
section_re = re.compile("\s*\[\s*%s\s*\]\s*" % section, re.I)
section_start_re = re.compile("\s*\[.*", re.I)
key_re = re.compile("\s*(%s)\s*=(.*)$" % key, re.I)
section_found = False
key_found = False
with open(args.path, "r") as f:
lines = f.readlines()
with open(args.path if update else "/dev/null", "w") as f:
for line in lines:
if section_re.search(line):
# Found matching section
section_found = True
elif section_found and key_re.search(line):
# Found key inside matching section.
# Preserve case of key and write the value.
key_found = True
key, val = key_re.search(line).groups()
if not update:
print val.strip()
return 0
f.write("%s=%s\n" % (key, value))
continue
elif (not key_found and section_found and
section_start_re.match(line)):
# Found a new section after the matching section, but without
# finding the key. This means that this is a new key.
f.write("%s=%s\n" % (key, value))
f.write(line)
if section_found and not key_found:
f.write("%s=%s\n" % (key, value))
if not section_found:
f.write("[%s]\n" % section)
f.write("%s=%s\n" % (key, value))
return 0
if __name__ == "__main__":
sys.exit(main())
#!/bin/bash
# Copyright (C) 2011-2015 GRNET S.A.
# Copyright (C) 2011-2016 GRNET S.A.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -67,8 +67,31 @@ else
log_error "$RULES_DEV does not contain \`rules\' file"
fi
# Export SNF_IMAGE_DEV. This is an array and exporting arrays is not supported
# in bash. We need to encode it's values to multiple variables
encode_array SNF_IMAGE_DEV
for ((i = 0; i < SNF_IMAGE_DEV_COUNT; i++)); do
export "SNF_IMAGE_DEV_$i"
done
export SNF_IMAGE_DEV_COUNT
# For backwards compatibility set the value of the SNF_IMAGE_DEV variable to
# the first value of the array
unset SNF_IMAGE_DEV
export SNF_IMAGE_DEV=${SNF_IMAGE_DEV_0}
if [ -f "$rules/unattend.xml" ]; then
export SNF_IMAGE_UNATTEND="$rules/unattend.xml"
else
log_error "unattend.xml file missing from the device hosting the rules"
fi
if [ -f "$rules/sysprep.inf" ]; then
export SNF_IMAGE_SYSPREPINF="$rules/sysprep.inf"
else
log_error "sysprep.inf file missing from the device hosting the rules"
fi
if [ -n "$SNF_IMAGE_PROPERTIES" ]; then
......@@ -98,19 +121,19 @@ if [ -z "$RUN_PARTS" ]; then
log_error "run-parts program is missing from the system"
fi
if [ -z "$SNF_IMAGE_PROPERTY_EXCLUDE_ALL_TASKS" ]; then
if ! check_yes_no SNF_IMAGE_PROPERTY_EXCLUDE_ALL_TASKS; then
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "" -o "$SNF_IMAGE_PROPERTY_ROOT_PARTITION" = "" ]; then
warn "Needed image properties are missing. Autodetecting them..."
detect_image_properties "$SNF_IMAGE_DEV"
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "" ]; then
echo "Detected OSFAMILY: $DETECTED_OSFAMILY"
warn "Detected OSFAMILY: $DETECTED_OSFAMILY"
export SNF_IMAGE_PROPERTY_OSFAMILY="$DETECTED_OSFAMILY"
fi