From c1dc844a8f09b52bb4c22960115a1640f255a213 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 30 Jul 2014 23:46:14 +0200 Subject: Major rewrite: Use reclass. --- profiles/wheezy/classes/Admin/etc/functions.yml | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 profiles/wheezy/classes/Admin/etc/functions.yml (limited to 'profiles/wheezy/classes/Admin/etc/functions.yml') diff --git a/profiles/wheezy/classes/Admin/etc/functions.yml b/profiles/wheezy/classes/Admin/etc/functions.yml new file mode 100644 index 0000000..5d86952 --- /dev/null +++ b/profiles/wheezy/classes/Admin/etc/functions.yml @@ -0,0 +1,26 @@ +classes: + - Admin +parameters: + doc: + admin: + tweak: + - define routines to make backup of and help edit config files + tweak: + - > + _backup(){ set -e;\ + if [ -e "$1.orig" ]; then \ + :;\ + elif [ -e "$1" ]; then \ + cp -a "$1" "$1.orig";\ + else \ + touch "$1.orig";\ + fi; } + - > + _clone(){ set -e;\ + _backup "$2";\ + cp -a "$1" "$2"; } + - > + _setvar(){ set -e;\ + _backup "$1";\ + sed -i -r \ + -e "s,^#?($2)=.*,\\1=$3," "$1"; } -- cgit v1.2.3