Re: [PATCH lorax/master] add 'systemctl' command and use it in postinstall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ack

----- Original Message -----
> The 'systemctl' command can be used to enable, disable, or mask
> systemd
> units inside the runtime being modified. Modify
> runtime-postinstall.tmpl
> to use the 'systemctl' command.
> 
> We also no longer remove quota*.service or kexec*.service, since
> these aren't enabled by default. And systemd-remount-api-vfs.service
> should work correctly now, so we can leave it alone as well.
> ---
>  share/runtime-postinstall.tmpl |   28 +++++++++++++++++-----------
>  src/pylorax/ltmpl.py           |   22 ++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 11 deletions(-)
> 
> diff --git a/share/runtime-postinstall.tmpl
> b/share/runtime-postinstall.tmpl
> index 6523dfb..13e3dbc 100644
> --- a/share/runtime-postinstall.tmpl
> +++ b/share/runtime-postinstall.tmpl
> @@ -20,18 +20,24 @@ move etc/yum.repos.d etc/anaconda.repos.d
>  
>  ## Configure systemd to start anaconda
>  remove etc/systemd/system/default.target
> -remove etc/systemd/system/default.target.wants/*
>  symlink /lib/systemd/system/anaconda.target
>  etc/systemd/system/default.target
> -## remove/disable unwanted systemd services
> -removefrom systemd /usr/lib/systemd/system/kexec*
> -removefrom systemd
> /usr/lib/systemd/system/local-fs.target.wants/media.mount
> -removefrom systemd /usr/lib/systemd/system/media.mount
> -removefrom systemd /usr/lib/systemd/system/*plymouth*
> -removefrom systemd /usr/lib/systemd/system/quota*.service
> -removefrom systemd
> /usr/lib/systemd/system/systemd-remount-api-vfs.service
> -removefrom initscripts
> */lib/systemd/system/local-fs.target.wants/fedora-storage*.service
> */lib/systemd/system/basic.target.wants/*.service
> -removefrom lvm2 */lib/systemd/system/*
> -removefrom mdadm */lib/systemd/system/*
> +
> +## Disable unwanted systemd services
> +systemctl disable systemd-readahead-collect.service \
> +                  systemd-readahead-replay.service \
> +                  mdmonitor.service \
> +                  mdmonitor-takeover.service \
> +                  lvm2-monitor.service
> +## These services can't be disabled normally (they're linked into
> place in
> +## /usr/lib/systemd rather than /etc/systemd), so we have to mask
> them.
> +systemctl mask fedora-configure.service fedora-loadmodules.service \
> +               fedora-storage-init.service
> fedora-storage-init-late.service \
> +               fedora-autorelabel.service
> fedora-autorelabel-mark.service \
> +               fedora-wait-storage.service media.mount \
> +               plymouth-quit.service plymouth-quit-wait.service \
> +               plymouth-kexec.service plymouth-halt.service \
> +               plymouth-poweroff.service plymouth-reboot.service \
> +               plymouth-read-write.service plymouth-start.service
>  
>  ## install some basic configuration files
>  append etc/resolv.conf ""
> diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py
> index d3e05e3..0edd5ab 100644
> --- a/src/pylorax/ltmpl.py
> +++ b/src/pylorax/ltmpl.py
> @@ -531,3 +531,25 @@ class LoraxTemplateRunner(object):
>          addrsize_data = struct.pack(">iiii", 0, int(addr, 16), 0,
>          os.stat(src).st_size)
>          addrsize.write(addrsize_data)
>          addrsize.close()
> +
> +    def systemctl(self, cmd, *units):
> +        '''
> +        systemctl [enable|disable|mask] UNIT [UNIT...]
> +          Enable, disable, or mask the given systemd units.
> +          Examples:
> +            systemctl disable lvm2-monitor.service
> +            systemctl mask fedora-storage-init.service
> fedora-configure.service
> +        '''
> +        if cmd not in ('enable', 'disable', 'mask'):
> +            raise ValueError('unsupported systemctl cmd: %s' % cmd)
> +        if not units:
> +            logger.debug("systemctl: no units given for %s,
> ignoring", cmd)
> +            return
> +        self.mkdir("/run/systemd/system") # XXX workaround for
> systemctl bug
> +        systemctl = ('systemctl', '--root', self.outroot,
> '--no-reload',
> +                     '--quiet', cmd)
> +        # XXX for some reason 'systemctl enable/disable' always
> returns 1
> +        try:
> +            check_call(systemctl + units)
> +        except CalledProcessError:
> +            pass
> --
> 1.7.10.2
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list
> 

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux