From 7a1f81dc7b15defa8ae41fdf9f227dd8213fead1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 7 Nov 2012 16:54:34 +0100 Subject: [PATCH] remove install types Signed-off-by: Steven Armstrong --- cdist/conf/type/__mkfs/gencode-remote | 38 ----- cdist/conf/type/__mkfs/install | 0 cdist/conf/type/__mkfs/man.text | 57 -------- cdist/conf/type/__mkfs/manifest | 31 ---- cdist/conf/type/__mkfs/parameter/optional | 3 - cdist/conf/type/__mkfs/parameter/required | 1 - cdist/conf/type/__partition_msdos/install | 0 cdist/conf/type/__partition_msdos/man.text | 62 -------- cdist/conf/type/__partition_msdos/manifest | 41 ------ .../type/__partition_msdos/parameter/optional | 3 - .../type/__partition_msdos/parameter/required | 1 - .../explorer/partitions | 3 - .../type/__partition_msdos_apply/files/lib.sh | 61 -------- .../__partition_msdos_apply/gencode-remote | 138 ------------------ .../conf/type/__partition_msdos_apply/install | 0 .../type/__partition_msdos_apply/man.text | 42 ------ .../type/__partition_msdos_apply/singleton | 0 17 files changed, 481 deletions(-) delete mode 100755 cdist/conf/type/__mkfs/gencode-remote delete mode 100644 cdist/conf/type/__mkfs/install delete mode 100644 cdist/conf/type/__mkfs/man.text delete mode 100755 cdist/conf/type/__mkfs/manifest delete mode 100644 cdist/conf/type/__mkfs/parameter/optional delete mode 100644 cdist/conf/type/__mkfs/parameter/required delete mode 100644 cdist/conf/type/__partition_msdos/install delete mode 100644 cdist/conf/type/__partition_msdos/man.text delete mode 100755 cdist/conf/type/__partition_msdos/manifest delete mode 100644 cdist/conf/type/__partition_msdos/parameter/optional delete mode 100644 cdist/conf/type/__partition_msdos/parameter/required delete mode 100755 cdist/conf/type/__partition_msdos_apply/explorer/partitions delete mode 100644 cdist/conf/type/__partition_msdos_apply/files/lib.sh delete mode 100755 cdist/conf/type/__partition_msdos_apply/gencode-remote delete mode 100644 cdist/conf/type/__partition_msdos_apply/install delete mode 100644 cdist/conf/type/__partition_msdos_apply/man.text delete mode 100644 cdist/conf/type/__partition_msdos_apply/singleton 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/manifest b/cdist/conf/type/__mkfs/manifest deleted file mode 100755 index e9d275a4..00000000 --- a/cdist/conf/type/__mkfs/manifest +++ /dev/null @@ -1,31 +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/device" ]; then - device="(cat "$__object/parameter/device")" -else - device="/$__object_id" - echo "$device" > "$__object/parameter/device" -fi - -type="(cat "$__object/parameter/type")" - -options="(cat "$__object/parameter/options")" 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/__partition_msdos_apply/man.text b/cdist/conf/type/__partition_msdos_apply/man.text deleted file mode 100644 index 6cc53b77..00000000 --- a/cdist/conf/type/__partition_msdos_apply/man.text +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__partition_msdos_apply(7) -==================================== -Steven Armstrong - - -NAME ----- -cdist-type__partition_msdos_apply - Apply dos partition settings - - -DESCRIPTION ------------ -Create the partitions defined with __partition_msdos - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - --------------------------------------------------------------------------------- -__partition_msdos_apply --------------------------------------------------------------------------------- - - -SEE ALSO --------- -- cdist-type(7) -- cdist-type__partition_msdos_apply(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_apply/singleton b/cdist/conf/type/__partition_msdos_apply/singleton deleted file mode 100644 index e69de29b..00000000