diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..18ab65d --- /dev/null +++ b/README.rst @@ -0,0 +1,105 @@ +cdist-type__ungleich_openvpn_server(7) +====================================== + +NAME +---- +cdist-type__ungleich_openvpn_server - Configure an OpenVPN Server + + +DESCRIPTION +----------- +This cdist type allows you to create and maintain OpenVPN servers. +It assumes existence of the directory files/openvpn/ and various +subdirectories (see below). + + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +state + 'present', 'absent', 'exists' or 'pre-exists', defaults to 'present' where: + + present + the file is exactly the one from source + absent + the file does not exist + exists + the file from source but only if it doesn't already exist + pre-exists + check that the file exists and is a regular file, but do not + create or modify it + +group + Group to chgrp to. + +mode + Unix permissions, suitable for chmod. + +owner + User to chown to. + +source + If supplied, copy this file from the host running cdist to the target. + If not supplied, an empty file or directory will be created. + If source is '-' (dash), take what was written to stdin as the file content. + +MESSAGES +-------- +chgrp + Changed group membership +chown + Changed owner +chmod + Changed mode +create + Empty file was created (no --source specified) +remove + File exists, but state is absent, file will be removed by generated code. +upload + File was uploaded + + +EXAMPLES +-------- + +.. code-block:: sh + + # Create /etc/cdist-configured as an empty file + __file /etc/cdist-configured + # The same thing + __file /etc/cdist-configured --state present + # Use __file from another type + __file /etc/issue --source "$__type/files/archlinux" --state present + # Delete existing file + __file /etc/cdist-configured --state absent + # Supply some more settings + __file /etc/shadow --source "$__type/files/shadow" \ + --owner root --group shadow --mode 0640 \ + --state present + # Provide a default file, but let the user change it + __file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ + --state exists \ + --owner frodo --mode 0600 + # Check that the file is present, show an error when it is not + __file /etc/somefile --state pre-exists + # Take file content from stdin + __file /tmp/whatever --owner root --group root --mode 644 --source - << DONE + Here goes the content for /tmp/whatever + DONE + + +AUTHORS +------- +Nico Schottelius + + +COPYING +------- +Copyright \(C) 2011-2013 Nico Schottelius. 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 3 of the +License, or (at your option) any later version. diff --git a/gencode-remote b/gencode-remote new file mode 100644 index 0000000..2bef0ca --- /dev/null +++ b/gencode-remote @@ -0,0 +1,7 @@ +if grep -q "^__file/etc/openvpn" "$__messages_in"; then + cat << eof + if [ "\$(pgrep openvpn)" ]; then + echo /etc/init.d/openvpn restart + fi +eof +fi diff --git a/manifest b/manifest new file mode 100644 index 0000000..306b2b2 --- /dev/null +++ b/manifest @@ -0,0 +1,52 @@ +config=$(cat "$__object/parameter/config") + +srcdirparamfile="$__object/parameter/srcdir" +if [ -f "$srcdirparamfile" ]; then + srcdirparam=$(cat "$srcdirparamfile") +else + srcdirparam="server-generic" +fi +srcdir="$__files/openvpn/$srcdirparam" + +if [ ! -d "$srcdir" ]; then + echo "No such srcdir, ${srcdirparam}. Aborting." + exit 1 +fi + +confdir="$__files/openvpn/server-config" +basedir=/etc/openvpn + +configfile="$confdir/${config}.conf" + +if [ ! -f "$configfile" ]; then + echo "No such config, ${config}. Aborting." + exit 1 +fi + +require="__package/openvpn" __file "$basedir/server.conf" \ + --state present --mode 0600 \ + --source "$configfile" + +__package openvpn --state present +require="__package/openvpn" __start_on_boot openvpn --state present + +cd "$srcdir" + +for entry in *; do + if [ -d "$entry" ]; then + require="__package/openvpn" __directory "$basedir/$entry" \ + --state present --mode 0755 + cd "$entry" + for file in *; do + require="__package/openvpn __directory/$basedir/$entry" \ + __file "$basedir/$entry/$file" \ + --state present --mode 0644 \ + --source "$srcdir/$entry/$file" + done + cd ".." + else + require="__package/openvpn" __file "$basedir/$entry" \ + --state present --mode 0644 \ + --source "$srcdir/$entry" + fi +done diff --git a/parameter/optional b/parameter/optional new file mode 100644 index 0000000..da900f5 --- /dev/null +++ b/parameter/optional @@ -0,0 +1 @@ +srcdir diff --git a/parameter/required b/parameter/required new file mode 100644 index 0000000..04204c7 --- /dev/null +++ b/parameter/required @@ -0,0 +1 @@ +config diff --git a/singleton b/singleton new file mode 100644 index 0000000..e69de29