__ungleich_openvpn_server/manifest

74 lines
2.1 KiB
Bash

#!/bin/sh -e
#
# 2018 ungleich glarus ag (foss at ungleich.ch)
#
# This file is part of cdist.
#
# cdist 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 3 of the License, or
# (at your option) any later version.
#
# cdist 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 cdist. If not, see <http://www.gnu.org/licenses/>.
#
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