diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest index 04c66ce0..e7ad0c26 100755 --- a/cdist/conf/type/__apt_ppa/manifest +++ b/cdist/conf/type/__apt_ppa/manifest @@ -20,7 +20,7 @@ name="$__object_id" -__package python-software-properties --state installed +__package python-software-properties --state present require="__package/python-software-properties" \ __file /usr/local/bin/remove-apt-repository \ diff --git a/cdist/conf/type/__apt_update_index/gencode-remote b/cdist/conf/type/__apt_update_index/gencode-remote index e66ff7a3..61ce11a9 100755 --- a/cdist/conf/type/__apt_update_index/gencode-remote +++ b/cdist/conf/type/__apt_update_index/gencode-remote @@ -20,7 +20,7 @@ # run 'apt-get update' if anything in /etc/apt is newer then /var/lib/apt/lists cat << DONE -if find /etc/apt -cnewer /var/lib/apt/lists | grep . > /dev/null; then +if find /etc/apt -mindepth 1 -cnewer /var/lib/apt/lists | grep . > /dev/null; then apt-get update || apt-get update fi DONE diff --git a/cdist/conf/type/__partition_msdos_apply/man.text b/cdist/conf/type/__autofs/man.text similarity index 60% rename from cdist/conf/type/__partition_msdos_apply/man.text rename to cdist/conf/type/__autofs/man.text index 6cc53b77..9b343309 100644 --- a/cdist/conf/type/__partition_msdos_apply/man.text +++ b/cdist/conf/type/__autofs/man.text @@ -1,21 +1,21 @@ -cdist-type__partition_msdos_apply(7) -==================================== +cdist-type__autofs(7) +===================== Steven Armstrong NAME ---- -cdist-type__partition_msdos_apply - Apply dos partition settings +cdist-type__autofs - install and start autofs DESCRIPTION ----------- -Create the partitions defined with __partition_msdos +This space intentionally left blank. REQUIRED PARAMETERS ------------------- -None +None. OPTIONAL PARAMETERS @@ -27,16 +27,16 @@ EXAMPLES -------- -------------------------------------------------------------------------------- -__partition_msdos_apply +__autofs -------------------------------------------------------------------------------- SEE ALSO -------- - cdist-type(7) -- cdist-type__partition_msdos_apply(7) + COPYING ------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is +Copyright \(C) 2012 Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__mkfs/manifest b/cdist/conf/type/__autofs/manifest similarity index 59% rename from cdist/conf/type/__mkfs/manifest rename to cdist/conf/type/__autofs/manifest index e9d275a4..31844415 100755 --- a/cdist/conf/type/__mkfs/manifest +++ b/cdist/conf/type/__autofs/manifest @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -18,14 +18,21 @@ # along with cdist. If not, see . # -# set defaults -if [ -f "$__object/parameter/device" ]; then - device="(cat "$__object/parameter/device")" -else - device="/$__object_id" - echo "$device" > "$__object/parameter/device" -fi -type="(cat "$__object/parameter/type")" +os=$(cat "$__global/explorer/os") -options="(cat "$__object/parameter/options")" +not_supported() { + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 +} + +case "$os" in + ubuntu|debian|archlinux) + __package autofs --state present + __start_on_boot autofs --state present + ;; + *) + not_supported + ;; +esac diff --git a/cdist/conf/type/__autofs_master/singleton b/cdist/conf/type/__autofs/singleton similarity index 100% rename from cdist/conf/type/__autofs_master/singleton rename to cdist/conf/type/__autofs/singleton diff --git a/cdist/conf/type/__autofs_map/explorer/entry b/cdist/conf/type/__autofs_map/explorer/entry new file mode 100755 index 00000000..7aa26518 --- /dev/null +++ b/cdist/conf/type/__autofs_map/explorer/entry @@ -0,0 +1,50 @@ +#!/bin/sh +# +# 2011 - 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +candidates="/etc/auto.master /etc/autofs/auto.master" +find_auto_master() { + # get the path of the auto.master file + for candidate in $candidates; do + if [ -f "$candidate" ]; then + echo "$candidate" + return + fi + done +} + +auto_master="$(find_auto_master)" + +# no auto.master, nothing we could do +[ -f "$auto_master" ] || exit 0 + +# NOTE: keep variables in sync in manifest/explorer/gencode-* +prefix="#cdist:$__object_name" +suffix="#/cdist:$__object_name" +awk -v prefix="$prefix" -v suffix="$suffix" '{ + if (index($0,prefix)) { + triggered=1 + } + if (triggered) { + if (index($0,suffix)) { + triggered=0 + } + print + } +}' "$auto_master" diff --git a/cdist/conf/type/__autofs_map/gencode-remote b/cdist/conf/type/__autofs_map/gencode-remote new file mode 100755 index 00000000..fa6acffb --- /dev/null +++ b/cdist/conf/type/__autofs_map/gencode-remote @@ -0,0 +1,93 @@ +#!/bin/sh +# +# 2011 - 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +entry="$__object/files/entry" +state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)" +if [ ! -s "$__object/explorer/entry" ]; then + state_is='absent' +else + state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \ + && echo present \ + || echo changed + ) +fi + +if [ "$state_should" = "$state_is" ]; then + # Nothing to do, move along + exit 0 +fi + +cat << DONE +candidates="/etc/auto.master /etc/autofs/auto.master" +find_auto_master() { + # get the path of the auto.master file + for candidate in \$candidates; do + if [ -f "\$candidate" ]; then + echo "\$candidate" + return + fi + done +} + +auto_master="\$(find_auto_master)" + +if [ ! -f "\$auto_master" ]; then + echo "Could not determine auto.master location, tried: \$candidates" >&2 + exit 1 +fi +DONE + +remove_entry() { + # NOTE: keep variables in sync in manifest/explorer/gencode-* + prefix="#cdist:$__object_name" + suffix="#/cdist:$__object_name" + cat << DONE +awk -v prefix="$prefix" -v suffix="$suffix" ' +{ + if (index(\$0,prefix)) { + triggered=1 + } + if (triggered) { + if (index(\$0,suffix)) { + triggered=0 + } + } else { + print + } +}' "\$auto_master" > "\$auto_master"+ +mv -f "\$auto_master"+ "\$auto_master" +DONE +} + +case "$state_should" in + present) + if [ "$state_is" = "changed" ]; then + remove_entry + fi + cat << DONE +cat >> "\$auto_master" << EOC +$(cat "$entry") +EOC +DONE + ;; + absent) + remove_entry + ;; +esac diff --git a/cdist/conf/type/__autofs_map/man.text b/cdist/conf/type/__autofs_map/man.text index 941e22da..50ce2fa8 100644 --- a/cdist/conf/type/__autofs_map/man.text +++ b/cdist/conf/type/__autofs_map/man.text @@ -36,25 +36,35 @@ comment:: auto.master. +BOOLEAN PARAMETERS +------------------ +noreload:: + don't reload autofs after the entry has been changed + + EXAMPLES -------- -------------------------------------------------------------------------------- -# Add auto mounter at /net +# Add auto mounter at /net and reload __autofs_map /net --map /etc/auto.net --type program -# Add auto mounter at /pub -__autofs_map /pub --map /etc/auto.pub \ - --type file --options nosuid,rw,bg,hard,intr --ghost +# Add auto mounter at /pub and don't reload +__autofs_map /pub \ + --map /etc/auto.pub \ + --type file \ + --options "nosuid,rw,bg,hard,intr --ghost" \ + --noreload -------------------------------------------------------------------------------- SEE ALSO -------- - cdist-type(7) +- cdist-type__autofs_reload(7) COPYING ------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is +Copyright \(C) 2012 Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__autofs_map/manifest b/cdist/conf/type/__autofs_map/manifest index d86ea799..58dc0f98 100755 --- a/cdist/conf/type/__autofs_map/manifest +++ b/cdist/conf/type/__autofs_map/manifest @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 - 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -20,23 +20,36 @@ name="/$__object_id" map="$(cat "$__object/parameter/map")" +type="$(cat "$__object/parameter/type" 2>/dev/null || echo "file")" +options="$(cat "$__object/parameter/options" 2>/dev/null || true)" -if [ -f "$__object/parameter/type" ]; then - type="$(cat "$__object/parameter/type")" -else - type="file" - echo "$type" > "$__object/parameter/type" -fi +# NOTE: keep variables in sync in manifest/explorer/gencode-* +prefix="#cdist:$__object_name" +suffix="#/cdist:$__object_name" -# Generate entry for use in auto.master -entry="${name} ${type}:${map}" -if [ -f "$__object/parameter/options" ]; then - entry="$entry $(cat "$__object/parameter/options")" -fi +mkdir "$__object/files" + +# Generate entry for inclusion in auto.master +entry="$__object/files/entry" +echo "$prefix" > "$entry" if [ -f "$__object/parameter/comment" ]; then - echo "# $(cat "$__object/parameter/comment")" > "$__object/parameter/entry" + echo "# $(cat "$__object/parameter/comment")" >> "$entry" fi -echo "$entry" >> "$__object/parameter/entry" - -require="$__object_name" __autofs_master +echo "$name $type:$map $options" >> $entry +echo "$suffix" >> "$entry" +# Reload autofs after changes if the user wishes this +if [ ! -f "$__object/parameter/noreload" ]; then + state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)" + if [ ! -s "$__object/explorer/entry" ]; then + state_is='absent' + else + state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \ + && echo present \ + || echo changed + ) + fi + if [ "$state_is" != "$state_should" ]; then + require="$__object_name" __autofs_reload + fi +fi diff --git a/cdist/conf/type/__autofs_map/parameter/boolean b/cdist/conf/type/__autofs_map/parameter/boolean new file mode 100644 index 00000000..862edc87 --- /dev/null +++ b/cdist/conf/type/__autofs_map/parameter/boolean @@ -0,0 +1 @@ +noreload diff --git a/cdist/conf/type/__autofs_master/files/auto.master.header b/cdist/conf/type/__autofs_master/files/auto.master.header deleted file mode 100644 index 53590257..00000000 --- a/cdist/conf/type/__autofs_master/files/auto.master.header +++ /dev/null @@ -1,3 +0,0 @@ -# Generated from cdist __autofs_master -# Do not change this file. Changes will be overwritten. - diff --git a/cdist/conf/type/__autofs_master/parameter/optional b/cdist/conf/type/__autofs_master/parameter/optional deleted file mode 100644 index 8e83f898..00000000 --- a/cdist/conf/type/__autofs_master/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -header diff --git a/cdist/conf/type/__autofs_master/manifest b/cdist/conf/type/__autofs_reload/gencode-remote similarity index 62% rename from cdist/conf/type/__autofs_master/manifest rename to cdist/conf/type/__autofs_reload/gencode-remote index e429842e..883602e2 100755 --- a/cdist/conf/type/__autofs_master/manifest +++ b/cdist/conf/type/__autofs_reload/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -19,13 +19,19 @@ # -if [ ! -f "$__object/parameter/header" ]; then - echo "$__type/files/auto.master.header" > "$__object/parameter/header" -fi +os=$(cat "$__global/explorer/os") -[ -d "$__object/files" ] || mkdir "$__object/files" -require="$__object_name" __file /etc/auto.master --source "$__object/files/auto.master" \ - --mode 644 \ - --owner root \ - --group root +not_supported() { + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 +} +case "$os" in + ubuntu|debian|archlinux) + echo "pkill -HUP automount" + ;; + *) + not_supported + ;; +esac diff --git a/cdist/conf/type/__autofs_master/man.text b/cdist/conf/type/__autofs_reload/man.text similarity index 51% rename from cdist/conf/type/__autofs_master/man.text rename to cdist/conf/type/__autofs_reload/man.text index 641c8393..d2085a98 100644 --- a/cdist/conf/type/__autofs_master/man.text +++ b/cdist/conf/type/__autofs_reload/man.text @@ -1,38 +1,33 @@ -cdist-type__autofs_master(7) +cdist-type__autofs_reload(7) ============================ Steven Armstrong NAME ---- -cdist-type__autofs_master - Generate the auto.master file +cdist-type__autofs_reload - tell automounter to reload config file DESCRIPTION ----------- -This cdist type generates a auto.master configuration from given __autofs_map -definitions. See cdist-type__auto_map(7). +This space intentionally left blank. REQUIRED PARAMETERS ------------------- -None +None. + OPTIONAL PARAMETERS ------------------- -header:: - Absolute path to a file used as the header for the generated auto.master - file. +None. + EXAMPLES -------- -------------------------------------------------------------------------------- -# auto.master with default header -__autofs_master - -# auto.master with custom header -__autofs_master --header /path/to/header +__autofs_reload -------------------------------------------------------------------------------- @@ -43,5 +38,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is +Copyright \(C) 2012 Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__partition_msdos_apply/singleton b/cdist/conf/type/__autofs_reload/singleton similarity index 100% rename from cdist/conf/type/__partition_msdos_apply/singleton rename to cdist/conf/type/__autofs_reload/singleton diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local index b74893fb..a6c55abf 100755 --- a/cdist/conf/type/__file/gencode-local +++ b/cdist/conf/type/__file/gencode-local @@ -27,7 +27,7 @@ exists="$(cat "$__object/explorer/exists")" [ "$state_should" = "exists" -a "$exists" = "yes" ] && exit 0 # nothing to do -if [ "$state_should" = "present" ]; then +if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then if [ -f "$__object/parameter/source" ]; then source="$(cat "$__object/parameter/source")" if [ "$source" = "-" ]; then diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index 2b4c7e45..04a1ea78 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -26,7 +26,7 @@ state_should="$(cat "$__object/parameter/state")" exists="$(cat "$__object/explorer/exists")" case "$state_should" in - present) + present|exists) # No source? Create empty file if [ ! -f "$__object/parameter/source" ]; then if [ "$exists" = "no" ]; then diff --git a/cdist/conf/type/__mkfs/gencode-remote b/cdist/conf/type/__mkfs/gencode-remote deleted file mode 100755 index b3561bad..00000000 --- a/cdist/conf/type/__mkfs/gencode-remote +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# 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 . -# - -device="$(cat "$__object/parameter/device")" -type="$(cat "$__object/parameter/type")" - -if [ "$type" = "swap" ]; then - echo "mkswap $device" -else - command="mkfs -t $type -q" - if [ -f "$__object/parameter/options" ]; then - options="$(cat "$__object/parameter/options")" - command="$command $options" - fi - command="$command $device" - if [ -f "$__object/parameter/blocks" ]; then - blocks="$(cat "$__object/parameter/blocks")" - command="$command $blocks" - fi - echo "$command" -fi diff --git a/cdist/conf/type/__mkfs/install b/cdist/conf/type/__mkfs/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__mkfs/man.text b/cdist/conf/type/__mkfs/man.text deleted file mode 100644 index 4320c639..00000000 --- a/cdist/conf/type/__mkfs/man.text +++ /dev/null @@ -1,57 +0,0 @@ -cdist-type__mkfs(7) -=================== -Steven Armstrong - - -NAME ----- -cdist-type__mkfs - build a linux file system - - -DESCRIPTION ------------ -This cdist type is a wrapper for the mkfs command. - - -REQUIRED PARAMETERS -------------------- -type:: - The filesystem type to use. Same as mkfs -t. - - -OPTIONAL PARAMETERS -------------------- -device:: - defaults to object_id - -options:: - file system-specific options to be passed to the mkfs command - -blocks:: - the number of blocks to be used for the file system - - -EXAMPLES --------- - --------------------------------------------------------------------------------- -# reiserfs /dev/sda5 -__mkfs /dev/sda5 --type reiserfs -# same thing with explicit device -__mkfs whatever --device /dev/sda5 --type reiserfs - -# jfs with journal on /dev/sda2 -__mkfs /dev/sda1 --type jfs --options "-j /dev/sda2" --------------------------------------------------------------------------------- - - -SEE ALSO --------- -- cdist-type(7) -- mkfs(8) - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__mkfs/parameter/optional b/cdist/conf/type/__mkfs/parameter/optional deleted file mode 100644 index 86aeae30..00000000 --- a/cdist/conf/type/__mkfs/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -device -options -blocks diff --git a/cdist/conf/type/__mkfs/parameter/required b/cdist/conf/type/__mkfs/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__mkfs/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__partition_msdos/install b/cdist/conf/type/__partition_msdos/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__partition_msdos/man.text b/cdist/conf/type/__partition_msdos/man.text deleted file mode 100644 index 78220ee0..00000000 --- a/cdist/conf/type/__partition_msdos/man.text +++ /dev/null @@ -1,62 +0,0 @@ -cdist-type__partition_msdos(7) -============================== -Steven Armstrong - - -NAME ----- -cdist-type__partition_msdos - creates msdos partitions - - -DESCRIPTION ------------ -This cdist type allows you to create msdos paritions. - - -REQUIRED PARAMETERS -------------------- -type:: - the partition type used in fdisk (such as 82 or 83) or "extended" - - -OPTIONAL PARAMETERS -------------------- -partition:: - defaults to object_id -bootable:: - mark partition as bootable, true or false, defaults to false -size:: - the size of the partition (such as 32M or 15G, whole numbers - only), '+' for remaining space, or 'n%' for percentage of remaining - (these should only be used after all specific partition sizes are - specified). Defaults to +. - - -EXAMPLES --------- - --------------------------------------------------------------------------------- -# 128MB, linux, bootable -__partition_msdos /dev/sda1 --type 83 --size 128M --bootable true -# 512MB, swap -__partition_msdos /dev/sda2 --type 82 --size 512M -# 100GB, extended -__partition_msdos /dev/sda3 --type extended --size 100G -# 10GB, linux -__partition_msdos /dev/sda5 --type 83 --size 10G -# 50% of the free space of the extended partition, linux -__partition_msdos /dev/sda6 --type 83 --size 50% -# rest of the extended partition, linux -__partition_msdos /dev/sda7 --type 83 --size + --------------------------------------------------------------------------------- - - -SEE ALSO --------- -- cdist-type(7) - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__partition_msdos/manifest b/cdist/conf/type/__partition_msdos/manifest deleted file mode 100755 index 21e43856..00000000 --- a/cdist/conf/type/__partition_msdos/manifest +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# 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 . -# - -# set defaults -if [ -f "$__object/parameter/partition" ]; then - partition="(cat "$__object/parameter/partition")" -else - partition="/$__object_id" - echo "$partition" > "$__object/parameter/partition" -fi -device="$(echo "$partition" | sed 's/[0-9]//g')" -echo "$device" > "$__object/parameter/device" -minor="$(echo "$partition" | sed 's/[^0-9]//g')" -echo "$minor" > "$__object/parameter/minor" - -if [ ! -f "$__object/parameter/bootable" ]; then - echo "false" > "$__object/parameter/bootable" -fi -if [ ! -f "$__object/parameter/size" ]; then - echo "+" > "$__object/parameter/size" -fi - -# pull in the type that actually does something with the above parameters -require="$__object_name" __partition_msdos_apply diff --git a/cdist/conf/type/__partition_msdos/parameter/optional b/cdist/conf/type/__partition_msdos/parameter/optional deleted file mode 100644 index b2b0a4c2..00000000 --- a/cdist/conf/type/__partition_msdos/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -partition -bootable -size diff --git a/cdist/conf/type/__partition_msdos/parameter/required b/cdist/conf/type/__partition_msdos/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__partition_msdos/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__partition_msdos_apply/explorer/partitions b/cdist/conf/type/__partition_msdos_apply/explorer/partitions deleted file mode 100755 index 6be61af4..00000000 --- a/cdist/conf/type/__partition_msdos_apply/explorer/partitions +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -cat /proc/partitions diff --git a/cdist/conf/type/__partition_msdos_apply/files/lib.sh b/cdist/conf/type/__partition_msdos_apply/files/lib.sh deleted file mode 100644 index 5767ea43..00000000 --- a/cdist/conf/type/__partition_msdos_apply/files/lib.sh +++ /dev/null @@ -1,61 +0,0 @@ -die() { - echo "[__partition_msdos_apply] $@" >&2 - exit 1 -} -debug() { - #echo "[__partition_msdos_apply] $@" >&2 - : -} - -fdisk_command() { - local device="$1" - local cmd="$2" - - debug fdisk_command "running fdisk command '${cmd}' on device ${device}" - printf "${cmd}\nw\n" | fdisk -c -u "$device" - # give disk some time - sleep 1 - return $? -} - -create_disklabel() { - local device=$1 - - debug create_disklabel "creating new msdos disklabel" - fdisk_command ${device} "o" - return $? -} - -create_partition() { - local device="$1" - local minor="$2" - local size="$3" - local type="$4" - local primary_count="$5" - - if [ "$type" = "extended" -o "$type" = "5" ]; then - # Extended partition - primary_extended="e\n" - first_minor="${minor}\n" - [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\n" - [ "${minor}" = "1" ] && type_minor="" - type="5" - elif [ "${minor}" -lt "5" ]; then - primary_extended="p\n" - first_minor="${minor}\n" - [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\n" - [ "${minor}" = "1" ] && type_minor="" - else - # Logical partitions - first_minor="${minor}\n" - type_minor="${minor}\n" - primary_extended="l\n" - [ "$primary_count" -gt "3" ] && primary_extended="" - fi - [ -n "${size}" ] && size="+${size}M" - fdisk_command ${device} "n\n${primary_extended}${first_minor}\n${size}\nt\n${type_minor}${type}\n" - return $? -} - diff --git a/cdist/conf/type/__partition_msdos_apply/gencode-remote b/cdist/conf/type/__partition_msdos_apply/gencode-remote deleted file mode 100755 index 5dab7070..00000000 --- a/cdist/conf/type/__partition_msdos_apply/gencode-remote +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# 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 . -# - -die() { - echo "[__partition_msdos_apply] $@" >&2 - exit 1 -} -debug() { - #echo "[__partition_msdos_apply] $@" >&2 - : -} - -# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB. -size_to_mb() { - local size=$1 - local available_size="$2" - - local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([MmGg%]\)[Bb]\?:\1|\2:')" - local number="$(echo ${number_suffix} | cut -d '|' -f1)" - local suffix="$(echo ${number_suffix} | cut -d '|' -f2)" - - case "$suffix" in - M|m) - size="$number" - ;; - G|g) - size="$(( $number * 1024 ))" - ;; - %) - size="$(( $available_size * $number / 100 ))" - ;; - *) - size="-1" - esac - echo "$size" -} - -# include function library for use on target -cat "$__type/files/lib.sh" - -partitions="$__object/explorer/partitions" -objects=$(find "$__global/object/__partition_msdos" -path "*.cdist") -current_device="" -available_device_size= -available_extended_size= -available_size= -primary_count=0 -for object in $objects; do - device="$(cat "$object/parameter/device")" - if [ "$current_device" != "$device" ]; then - echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'" - current_device="$device" - device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g') - available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) - # make sure we don't go past the end of the drive - available_device_size=$((available_device_size - 2)) - available_extended_size=0 - primary_count=0 - debug "----- $device" - debug "current_device=$current_device" - debug "available_device_size=$available_device_size" - fi - - type="$(cat "$object/parameter/type")" - partition="$(cat "$object/parameter/partition")" - minor="$(cat "$object/parameter/minor")" - - bootable="$(cat "$object/parameter/bootable")" - size="$(cat "$object/parameter/size")" - - - if [ "${minor}" -lt "5" ]; then - # Primary partitions - primary_count=$(( $primary_count + 1 )) - available_size=$available_device_size - else - # Logical partitions - available_size=$available_extended_size - fi - - if [ "$size" = "+" ]; then - # use rest of device - partition_size="" - available_size=0 - else - partition_size=$(size_to_mb "$size" "$available_size") - available_size="$(( $available_size - $partition_size ))" - fi - - if [ "${minor}" -lt "5" ]; then - # Primary partitions - available_device_size=$available_size - if [ "$type" = "extended" -o "$type" = "5" ]; then - # Extended partition - available_extended_size=$partition_size - fi - else - # Logical paritions - available_extended_size=$available_size - fi - - [ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value" - debug "----- $partition" - debug "primary_count=$primary_count" - debug "current_device=$current_device" - debug "device=$device" - debug "type=$type" - debug "partition=$partition" - debug "minor=$minor" - debug "bootable=$bootable" - debug "size=$size" - debug "partition_size=$partition_size" - debug "available_size=$available_size" - debug "available_device_size=$available_device_size" - debug "available_extended_size=$available_extended_size" - debug "----------" - - echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \ - || die 'Failed to create partition: $partition'" -done - diff --git a/cdist/conf/type/__partition_msdos_apply/install b/cdist/conf/type/__partition_msdos_apply/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__ssh_authorized_key/manifest b/cdist/conf/type/__ssh_authorized_key/manifest index d9db9c78..8984d5d4 100755 --- a/cdist/conf/type/__ssh_authorized_key/manifest +++ b/cdist/conf/type/__ssh_authorized_key/manifest @@ -21,7 +21,7 @@ # This type allows to send a public ssh key from a user to the # authorized_keys of another # -#require="__package openssh-server --state installed" +#require="__package openssh-server --state present" # Get option srcuser if defined if [ -f "$__object/parameter/srcuser" ]; then srcuser=`cat "$__object/parameter/srcuser"` diff --git a/cdist/conf/type/__autofs_master/gencode-local b/cdist/conf/type/__timezone/gencode-remote similarity index 66% rename from cdist/conf/type/__autofs_master/gencode-local rename to cdist/conf/type/__timezone/gencode-remote index 701f97a8..b4782d4b 100755 --- a/cdist/conf/type/__autofs_master/gencode-local +++ b/cdist/conf/type/__timezone/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -18,9 +18,13 @@ # along with cdist. If not, see . # # -# Generate auto.master config based on all defined __autofs_map ojbects. -# +# This type allows to configure the desired localtime timezone. + +timezone="$__object_id" +os=$(cat "$__global/explorer/os") -auto_master="$__object/files/auto.master" -cat "$(cat "$__object/parameter/header")" > "$auto_master" -find "$__global/object/__autofs_map" -path "*.cdist/parameter/entry" | xargs cat >> "$auto_master" +case "$os" in + ubuntu|debian) + echo "echo \"$timezone\" > /etc/timezone" + ;; +esac diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index b0bae209..7583c9c9 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -1,6 +1,7 @@ #!/bin/sh # # 2011 Ramon Salvadó (rsalvado at gnuine dot com) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,7 +23,25 @@ timezone="$__object_id" -__package tzdata --state installed +os=$(cat "$__global/explorer/os") + +not_supported() { + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 +} + +case "$os" in + ubuntu|debian|archlinux) + : + ;; + *) + not_supported + ;; +esac + +# same for all supported os's +__package tzdata --state present require="__package/tzdata" __link /etc/localtime \ --source "/usr/share/zoneinfo/${timezone}" \ --type symbolic