forked from ungleich-public/cdist
Merge remote-tracking branch 'telmich/master' into filestate
Conflicts: conf/type/__file/gencode-local Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
commit
8c1aa87296
271 changed files with 17717 additions and 3049 deletions
26
conf/explorer/lsb_codename
Executable file
26
conf/explorer/lsb_codename
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
set +e
|
||||
lsb_release=$(which lsb_release 2>/dev/null)
|
||||
if [ -x "$lsb_release" ]; then
|
||||
$lsb_release --short --codename
|
||||
fi
|
||||
26
conf/explorer/lsb_description
Executable file
26
conf/explorer/lsb_description
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
set +e
|
||||
lsb_release=$(which lsb_release 2>/dev/null)
|
||||
if [ -x "$lsb_release" ]; then
|
||||
$lsb_release --short --description
|
||||
fi
|
||||
26
conf/explorer/lsb_id
Executable file
26
conf/explorer/lsb_id
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
set +e
|
||||
lsb_release=$(which lsb_release 2>/dev/null)
|
||||
if [ -x "$lsb_release" ]; then
|
||||
$lsb_release --short --id
|
||||
fi
|
||||
26
conf/explorer/lsb_release
Executable file
26
conf/explorer/lsb_release
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
set +e
|
||||
lsb_release=$(which lsb_release 2>/dev/null)
|
||||
if [ -x "$lsb_release" ]; then
|
||||
$lsb_release --short --release
|
||||
fi
|
||||
|
|
@ -49,7 +49,7 @@ if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# CentOS is also based on Redhat, this return before redhat!
|
||||
# CentOS is also based on Redhat, thus return before redhat!
|
||||
if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then
|
||||
echo centos
|
||||
exit 0
|
||||
|
|
@ -65,6 +65,16 @@ if [ -f /etc/SuSE-release ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f /etc/owl-release ]; then
|
||||
echo owl
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f /etc/cdist-preos ]; then
|
||||
echo cdist-preos
|
||||
exit 0
|
||||
fi
|
||||
|
||||
uname_s="$(uname -s)"
|
||||
|
||||
# Assume there is no tr on the client -> do lower case ourselves
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ case "$($__explorer/os)" in
|
|||
*bsd|solaris)
|
||||
uname -r
|
||||
;;
|
||||
owl)
|
||||
cat /etc/owl-release
|
||||
;;
|
||||
redhat|centos)
|
||||
cat /etc/redhat-release
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2010-2011 Daniel Roth (dani-cdist@d-roth.li)
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -25,9 +26,18 @@ else
|
|||
file="/$__object_id"
|
||||
fi
|
||||
|
||||
regex=$(cat "$__object/parameter/line")
|
||||
if [ -f "$__object/parameter/regex" ]; then
|
||||
regex=$(cat "$__object/parameter/regex")
|
||||
else
|
||||
wrap=$(cat "$__object/parameter/line")
|
||||
regex="^$wrap\$"
|
||||
fi
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
grep -q "^$regex\$" "$file"
|
||||
# sh -e is our environment, we know what we do,
|
||||
# skip error detection for now
|
||||
set +e
|
||||
grep -q "$regex" "$file"
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "NOTFOUND"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ OPTIONAL PARAMETERS
|
|||
file::
|
||||
If supplied, use this as the destination file.
|
||||
Otherwise the object_id is used.
|
||||
|
||||
regex::
|
||||
If supplied, search for this regex.
|
||||
Otherwise entire line must be matched.
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
file
|
||||
regex
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ require="__package/python-software-properties" \
|
|||
--source "$__type/files/remove-apt-repository" \
|
||||
--mode 0755
|
||||
|
||||
require="$__self" __apt_update_index
|
||||
require="$__object_name" __apt_update_index
|
||||
|
|
|
|||
|
|
@ -38,5 +38,5 @@ if [ -f "$__object/parameter/comment" ]; then
|
|||
fi
|
||||
echo "$entry" >> "$__object/parameter/entry"
|
||||
|
||||
require="$__self" __autofs_master
|
||||
require="$__object_name" __autofs_master
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if [ ! -f "$__object/parameter/header" ]; then
|
|||
fi
|
||||
|
||||
[ -d "$__object/files" ] || mkdir "$__object/files"
|
||||
require="$__self" __file /etc/auto.master --source "$__object/files/auto.master" \
|
||||
require="$__object_name" __file /etc/auto.master --source "$__object/files/auto.master" \
|
||||
--mode 644 \
|
||||
--owner root \
|
||||
--group root
|
||||
|
|
|
|||
37
conf/type/__cdistmarker/gencode-remote
Executable file
37
conf/type/__cdistmarker/gencode-remote
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2011 Daniel Maher (phrawzty+cdist at gmail.com)
|
||||
#
|
||||
# This file is part of cdist (https://github.com/telmich/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/>.
|
||||
#
|
||||
|
||||
# The marker file is established in the docs, but it isn't obligatory.
|
||||
if [ -f "$__object/parameter/destination" ]; then
|
||||
destination="$(cat "$__object/parameter/destination")"
|
||||
else
|
||||
destination='/etc/cdist-configured'
|
||||
fi
|
||||
|
||||
# The basic output of date is usually good enough, but variety is the
|
||||
# spice of life...
|
||||
if [ -f "$__object/parameter/format" ]; then
|
||||
format="$(cat "$__object/parameter/format")"
|
||||
else
|
||||
format='-u'
|
||||
fi
|
||||
|
||||
# Dump the timestamp in UTC to the marker
|
||||
echo "date $format > $destination"
|
||||
55
conf/type/__cdistmarker/man.text
Normal file
55
conf/type/__cdistmarker/man.text
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
cdist-type__cdistmarker(7)
|
||||
==========================
|
||||
Daniel Maher <phrawzty+cdist at gmail.com>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__cdistmarker - Add a timestamped cdist marker.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This type is used to add a common marker file which indicates that a given
|
||||
machine is being managed by cdist. The contents of this file consist of a
|
||||
timestamp, which can be used to determine the most recent time at which cdist
|
||||
was run against the machine in question.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
destination::
|
||||
The path and filename of the marker.
|
||||
Default: /etc/cdist-configured
|
||||
|
||||
format::
|
||||
The format of the timestamp. This is passed directly to system 'date'.
|
||||
Default: -u
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Creates the marker as normal.
|
||||
__cdistmarker
|
||||
|
||||
# Creates the marker differently.
|
||||
__cdistmarker --file /tmp/cdist_marker --format '+%s'
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Daniel Maher. Free use of this software is granted under
|
||||
the terms of the GNU General Public License version 3 (GPLv3).
|
||||
2
conf/type/__cdistmarker/parameter/optional
Normal file
2
conf/type/__cdistmarker/parameter/optional
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
destination
|
||||
format
|
||||
0
conf/type/__cdistmarker/singleton
Normal file
0
conf/type/__cdistmarker/singleton
Normal file
39
conf/type/__cron/explorer/entry
Executable file
39
conf/type/__cron/explorer/entry
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
name="$__object_id"
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
|
||||
prefix="#cdist:__cron/$name"
|
||||
suffix="#/cdist:__cron/$name"
|
||||
|
||||
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index($0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index($0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
print
|
||||
}
|
||||
}
|
||||
'
|
||||
63
conf/type/__cron/gencode-remote
Executable file
63
conf/type/__cron/gencode-remote
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is=$(diff -q "$__object/parameter/entry" "$__object/explorer/entry" \
|
||||
&& echo present \
|
||||
|| echo absent
|
||||
)
|
||||
|
||||
if [ "$state_is" != "$state_should" ]; then
|
||||
case "$state_should" in
|
||||
present)
|
||||
cat << DONE
|
||||
tmp=\$(mktemp)
|
||||
crontab -u $user -l > \$tmp
|
||||
cat >> \$tmp << EOC
|
||||
$(cat "$__object/parameter/entry")"
|
||||
EOC
|
||||
crontab -u $user \$tmp
|
||||
rm \$tmp
|
||||
DONE
|
||||
;;
|
||||
absent)
|
||||
# defined in type manifest
|
||||
prefix="$(cat "$__object/parameter/prefix")"
|
||||
suffix="$(cat "$__object/parameter/suffix")"
|
||||
cat << DONE
|
||||
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index(\$0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index(\$0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}
|
||||
' | crontab -u $user -
|
||||
DONE
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
61
conf/type/__cron/man.text
Normal file
61
conf/type/__cron/man.text
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
cdist-type__cron(7)
|
||||
===================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__cron - installs and manages cron jobs
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to manage entries in a users crontab.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
user::
|
||||
The user who's crontab is edited
|
||||
command::
|
||||
The command to run.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either present or absent. Defaults to present.
|
||||
minute::
|
||||
See crontab(5). Defaults to *
|
||||
hour::
|
||||
See crontab(5). Defaults to *
|
||||
day_of_month::
|
||||
See crontab(5). Defaults to *
|
||||
month::
|
||||
See crontab(5). Defaults to *
|
||||
day_of_week::
|
||||
See crontab(5). Defaults to *
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# add cronjob
|
||||
__cron some-id --user root --command "/path/to/script"
|
||||
|
||||
# remove cronjob
|
||||
__cron some-id --user root --command "/path/to/script" --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- crontab(5)
|
||||
|
||||
|
||||
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).
|
||||
66
conf/type/__cron/manifest
Executable file
66
conf/type/__cron/manifest
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
name="$__object_id"
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
command="$(cat "$__object/parameter/command")"
|
||||
|
||||
# set defaults
|
||||
if [ ! -f "$__object/parameter/state" ]; then
|
||||
echo "present" > "$__object/parameter/state"
|
||||
fi
|
||||
if [ -f "$__object/parameter/minute" ]; then
|
||||
minute="$(cat "$__object/parameter/minute")"
|
||||
else
|
||||
minute="*"
|
||||
echo "$minute" > "$__object/parameter/minute"
|
||||
fi
|
||||
if [ -f "$__object/parameter/hour" ]; then
|
||||
hour="$(cat "$__object/parameter/hour")"
|
||||
else
|
||||
hour="*"
|
||||
echo "$hour" > "$__object/parameter/hour"
|
||||
fi
|
||||
if [ -f "$__object/parameter/day_of_month" ]; then
|
||||
day_of_month="$(cat "$__object/parameter/day_of_month")"
|
||||
else
|
||||
day_of_month="*"
|
||||
echo "$day_of_month" > "$__object/parameter/day_of_month"
|
||||
fi
|
||||
if [ -f "$__object/parameter/month" ]; then
|
||||
month="$(cat "$__object/parameter/month")"
|
||||
else
|
||||
month="*"
|
||||
echo "$month" > "$__object/parameter/month"
|
||||
fi
|
||||
if [ -f "$__object/parameter/day_of_week" ]; then
|
||||
day_of_week="$(cat "$__object/parameter/day_of_week")"
|
||||
else
|
||||
day_of_week="*"
|
||||
echo "$day_of_week" > "$__object/parameter/day_of_week"
|
||||
fi
|
||||
|
||||
# NOTE: if changed, also change in explorers
|
||||
prefix="#cdist:__cron/$name"
|
||||
suffix="#/cdist:__cron/$name"
|
||||
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
|
||||
echo "$minute $hour $day_of_month $month $day_of_week $command" >> "$__object/parameter/entry"
|
||||
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"
|
||||
|
||||
6
conf/type/__cron/parameter/optional
Normal file
6
conf/type/__cron/parameter/optional
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
state
|
||||
minute
|
||||
hour
|
||||
day_of_month
|
||||
month
|
||||
day_of_week
|
||||
2
conf/type/__cron/parameter/required
Normal file
2
conf/type/__cron/parameter/required
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
user
|
||||
command
|
||||
38
conf/type/__mkfs/gencode-remote
Executable file
38
conf/type/__mkfs/gencode-remote
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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
|
||||
0
conf/type/__mkfs/install
Normal file
0
conf/type/__mkfs/install
Normal file
57
conf/type/__mkfs/man.text
Normal file
57
conf/type/__mkfs/man.text
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
cdist-type__mkfs(7)
|
||||
===================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
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).
|
||||
31
conf/type/__mkfs/manifest
Executable file
31
conf/type/__mkfs/manifest
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# 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")"
|
||||
3
conf/type/__mkfs/parameter/optional
Normal file
3
conf/type/__mkfs/parameter/optional
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
device
|
||||
options
|
||||
blocks
|
||||
1
conf/type/__mkfs/parameter/required
Normal file
1
conf/type/__mkfs/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
type
|
||||
|
|
@ -49,4 +49,4 @@ for property in $(ls .); do
|
|||
fi
|
||||
done
|
||||
|
||||
require="$__self" __package_$type "$@"
|
||||
require="$__object_name" __package_$type "$@"
|
||||
|
|
|
|||
|
|
@ -27,13 +27,6 @@ else
|
|||
name="$__object_id"
|
||||
fi
|
||||
|
||||
# Check for preseeding and add preseed as here document
|
||||
if [ -f "$__object/parameter/preseed" ]; then
|
||||
echo "debconf-set-selections << __file-eof"
|
||||
cat "$(cat "$__object/parameter/preseed")"
|
||||
echo "__file-eof"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"
|
||||
|
||||
|
|
|
|||
31
conf/type/__package_luarocks/explorer/pkg_status
Executable file
31
conf/type/__package_luarocks/explorer/pkg_status
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2012 SwellPath, Inc.
|
||||
# Christian G. Warden <cwarden@xerus.org>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# Retrieve the status of a rock
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
# Accept luarocks failing if package is not known/installed
|
||||
luarocks list "$name" | egrep -A1 "^$name$" || exit 0
|
||||
52
conf/type/__package_luarocks/gencode-remote
Executable file
52
conf/type/__package_luarocks/gencode-remote
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2012 SwellPath, Inc.
|
||||
# Christian G. Warden <cwarden@xerus.org>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Manage LuaRocks packages
|
||||
#
|
||||
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Install only if non-existent
|
||||
if [ -z "$is_installed" ]; then
|
||||
echo luarocks install \"$name\"
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
# Remove only if existent
|
||||
if [ -n "$is_installed" ]; then
|
||||
echo luarocks remove \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
49
conf/type/__package_luarocks/man.text
Normal file
49
conf/type/__package_luarocks/man.text
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
cdist-type__package_luarocks(7)
|
||||
==============================
|
||||
Christian G. Warden <cwarden@xerus.org>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__package_luarocks - Manage luarocks packages
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
LuaRocks is a deployment and management system for Lua modules.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure luasocket is installed
|
||||
__package_luarocks luasocket --state installed
|
||||
|
||||
# Remove package
|
||||
__package_luarocks luasocket --state removed
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__package(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 SwellPath, Inc. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
23
conf/type/__package_luarocks/manifest
Normal file
23
conf/type/__package_luarocks/manifest
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2012 SwellPath, Inc.
|
||||
# Christian G. Warden <cwarden@xerus.org>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
__package luarocks --state installed
|
||||
__package make --state installed
|
||||
1
conf/type/__package_luarocks/parameter/optional
Normal file
1
conf/type/__package_luarocks/parameter/optional
Normal file
|
|
@ -0,0 +1 @@
|
|||
name
|
||||
1
conf/type/__package_luarocks/parameter/required
Normal file
1
conf/type/__package_luarocks/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
state
|
||||
30
conf/type/__package_rubygem/explorer/pkg_status
Executable file
30
conf/type/__package_rubygem/explorer/pkg_status
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Chase Allen James (nx-cdist@nu-ex.com)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# Retrieve the status of a rubygem
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
# Except gem failing, if package is not known / installed
|
||||
gem list -i "$name" 2>/dev/null || exit 0
|
||||
51
conf/type/__package_rubygem/gencode-remote
Executable file
51
conf/type/__package_rubygem/gencode-remote
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Chase Allen James <nx-cdist@nu-ex.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Manage Rubygem packages
|
||||
#
|
||||
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)"
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Install only if non-existent
|
||||
if [ -z "$is_installed" ]; then
|
||||
echo gem install \"$name\" --no-ri --no-rdoc
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
# Remove only if existent
|
||||
if [ -n "$is_installed" ]; then
|
||||
echo gem uninstall \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
49
conf/type/__package_rubygem/man.text
Normal file
49
conf/type/__package_rubygem/man.text
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
cdist-type__package_rubygem(7)
|
||||
==============================
|
||||
Chase Allen James <nx-cdist@nu-ex.com>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__package_rubygem - Manage rubygem packages
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Rubygems is the default package management system for the Ruby programming language.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure sinatra is installed
|
||||
__package_rubygem sinatra --state installed
|
||||
|
||||
# Remove package
|
||||
__package_rubygem rails --state removed
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__package(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Chase Allen James. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
1
conf/type/__package_rubygem/parameter/optional
Normal file
1
conf/type/__package_rubygem/parameter/optional
Normal file
|
|
@ -0,0 +1 @@
|
|||
name
|
||||
1
conf/type/__package_rubygem/parameter/required
Normal file
1
conf/type/__package_rubygem/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
state
|
||||
0
conf/type/__partition_msdos/install
Normal file
0
conf/type/__partition_msdos/install
Normal file
62
conf/type/__partition_msdos/man.text
Normal file
62
conf/type/__partition_msdos/man.text
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
cdist-type__partition_msdos(7)
|
||||
==============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
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).
|
||||
41
conf/type/__partition_msdos/manifest
Executable file
41
conf/type/__partition_msdos/manifest
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# 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
|
||||
3
conf/type/__partition_msdos/parameter/optional
Normal file
3
conf/type/__partition_msdos/parameter/optional
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
partition
|
||||
bootable
|
||||
size
|
||||
1
conf/type/__partition_msdos/parameter/required
Normal file
1
conf/type/__partition_msdos/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
type
|
||||
3
conf/type/__partition_msdos_apply/explorer/partitions
Executable file
3
conf/type/__partition_msdos_apply/explorer/partitions
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
cat /proc/partitions
|
||||
61
conf/type/__partition_msdos_apply/files/lib.sh
Normal file
61
conf/type/__partition_msdos_apply/files/lib.sh
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
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 $?
|
||||
}
|
||||
|
||||
138
conf/type/__partition_msdos_apply/gencode-remote
Executable file
138
conf/type/__partition_msdos_apply/gencode-remote
Executable file
|
|
@ -0,0 +1,138 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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
|
||||
|
||||
0
conf/type/__partition_msdos_apply/install
Normal file
0
conf/type/__partition_msdos_apply/install
Normal file
42
conf/type/__partition_msdos_apply/man.text
Normal file
42
conf/type/__partition_msdos_apply/man.text
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
cdist-type__partition_msdos_apply(7)
|
||||
====================================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
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).
|
||||
0
conf/type/__partition_msdos_apply/singleton
Normal file
0
conf/type/__partition_msdos_apply/singleton
Normal file
|
|
@ -24,7 +24,7 @@
|
|||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="/$__object_id"
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
pgrep -x -f "$name" || true
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ __process /usr/sbin/sshd --state stopped --stop "/etc/rc.d/sshd stop"
|
|||
# Ensure cups is running, which runs with -C ...:
|
||||
__process cups --start "/etc/rc.d/cups start" --state running \
|
||||
--name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
|
||||
|
||||
# Ensure rpc.statd is running (which usually runs with -L) using a regexp
|
||||
__process rpcstatd --state running --start "/etc/init.d/statd start" \
|
||||
--name "rpc.statd.*"
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
|||
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
|
||||
|
||||
if [ "$new_value" != "$current_value" ]; then
|
||||
set -- "$@" "--$property" \"$new_value\"
|
||||
set -- "$@" "--$property" \'$new_value\'
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
|||
else
|
||||
for property in $(ls .); do
|
||||
new_value="$(cat "$property")"
|
||||
set -- "$@" "--$property" \"$new_value\"
|
||||
set -- "$@" "--$property" \'$new_value\'
|
||||
done
|
||||
|
||||
echo useradd "$@" "$name"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue