Skip to content
Snippets Groups Projects
Select Git revision
  • 0dce9932b6006dd601d07659921574830258ceea
  • master default protected
  • hpke
  • ppc-chacha-4core
  • delete-internal-name-mangling
  • master-updates
  • ppc-gcm
  • ppc-chacha-2core
  • refactor-ecc-mod
  • ppc-chacha-core
  • use-mpn_cnd-functions
  • optimize-ecc-invert
  • default-m4-quote-char
  • power-asm-wip
  • test-fat
  • chacha-3core-neon
  • x86_64-salsa20-2core
  • salsa20-2core-neon
  • bcrypt
  • arm-salsa20-chacha-vsra
  • test-shlib-dir
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
41 results

desTest.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    unit.pp 3.66 KiB
    # Copyright © 2021-2023   Thomas Bellman, Linköping, Sweden
    # Licensed under the GNU LGPL v3+; see the README file for more information.
    
    
    /*
     * Manage systemd units.
     *
     * This actually manages a config file in /etc/systemd/system/<service>.
     * The name parameter must be on the format
     *
     *     UNITNAME "." TYPE
     *
     * where
     *
     *  - UNITNAME is the name of the service, e.g. "sshd" or "getty@".
     *  - TYPE is the unit type, e.g. "service", "socket", et.c; see
     *    systemd.unit(5).
     *
     * The content of the unit file can be specified in one of three ways
     *  - the 'options' parameter, specifying the content as a hash of hashes,
     *  - the 'content' parameter, specifying the content as a string,
     *  - the 'source' parameter, specifying a file or Puppet URL to copy.
     */
    define systemd::unit(
    	# Hash of hash of options to put in the unit file.  The keys in the
    	# top level hash are the sections in the config file, e.g. "Unit",
    	# "Service", "Socket".  The inner hashes are mappings from option
    	# names to values.
    	#
    	# This parameter is mutually exclusive with the 'source' and
    	# 'content' parameters.
    	#
    	# If the value of an option is a (possibly nested) list, one option
    	# line will be generated for each element in the list.  This is to
    	# support multi-value options, e.g. "ExecStart" in a service config,
    	# or "ListenStream" in a socket config.
    	#
    	# A section name (at the top level) or an option name (at the inner
    	# level) starting with a hash sign (#), e.g. "#Service" or "#User",
    	# takes a string or (nested) list of strings, which will become a
    	# comment in front of the corresponding section or option.
    	#
    	$options=undef,
    
    	# String to put in the unit file.  This is equivalent to the
    	# 'content' parameter on the 'file' resource type.
    	#
    	# This parameter is mutally exclusive with the 'source' and
    	# 'options' parameters.
    	#
    	$content=undef,
    
    	# Path or puppet: URL to a file to copy into the unit file.  This is
    	# equivalent to the 'source' parameter on the 'file' resource type.
    	#
    	# This parameter is mutally exclusive with the 'options' and
    	# 'content' parameters.
    	#
    	$source=undef,
    
    	# List of comment lines to add to the start of the parameter file.
    	# The list may be nested, and individual "lines" are allowed to
    	# contain newlines, turning them into multiple comment lines.
    	# This is only used if the 'options' parameter is used to specify
    	# the content of the unit file.
    	#
    	$comment=[],
    
    	# One of 'present' of 'absent'.
    	#
    	$ensure='present',
    )
    {
        include systemd::vars
        contain systemd::daemon_reload
    
        if ($name !~ /^([^\/.]+)\.([^\/.]+)$/)
        {
    	fail("Systemd::Unit[${title}]:",
    	     " Name not on format <service>.<type>, ``${name}''")
        }
        if (($source != undef and $content == undef and $options == undef) or
    	($source == undef and $content != undef and $options == undef) or
    	($source == undef and $content == undef and $options != undef) or
    	($ensure == 'absent'))
        {
    	# OK
        } else {
    	fail("Systemd::Unit[${title}]:",
    	     "Exactly one of 'source', 'content' and 'options' must be used")
        }
    
        $systemd_resource_type = 'Unit'
        $filepath = "${systemd::vars::etcdir}/${name}"
    
        case $ensure
        {
    	'present': {
    	    $xcontent = $options ? {
    		undef   => $content,
    		default => template('systemd/unitfile.erb'),
    	    }
    	    file {
    		$filepath:
    		    ensure => file,
    		    content => $xcontent, source => $source,
    		    owner => 'root', group => 'root', mode => '0444',
    		    notify => Class['systemd::daemon_reload'];
    	    }
    	}
    	'absent': {
    	    file {
    		$filepath:
    		    ensure => absent,
    		    notify => Class['systemd::daemon_reload'];
    	    }
    	}
    	default: {
    	    fail("Systemd::Unit[${title}]:",
    		 " Bad parameter ensure, ``${ensure}''")
    	}
        }
    }