diff --git a/bin/cdist-type-template b/bin/cdist-type-template
index 0391510c..cd34027c 100755
--- a/bin/cdist-type-template
+++ b/bin/cdist-type-template
@@ -37,7 +37,7 @@ touch "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_parameter_re
touch "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_parameter_optional}"
# Manifest
-cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_manifest}"
+cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_dir "$__cdist_type")/${__cdist_name_manifest}"
#
# This is the manifest, which can be used to create other objects like this:
@@ -50,7 +50,7 @@ cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_parameter_
eof
# Gencode
-cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_gencode}"
+cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_dir "$__cdist_type")/${__cdist_name_gencode}"
#
# This file should generate code on stdout, which will be collected by cdist
@@ -63,4 +63,4 @@ cat "$__cdist_abs_mydir/../doc/dev/header" - << eof > "$(__cdist_type_parameter_
eof
# Explorer
-mkdir -p "$(__cdist_type_parameter_dir "$__cdist_type")/${__cdist_name_explorer}"
+mkdir -p "$(__cdist_type_dir "$__cdist_type")/${__cdist_name_explorer}"
diff --git a/conf/type/__group/TODO b/conf/type/__group/TODO
new file mode 100644
index 00000000..c20a5d21
--- /dev/null
+++ b/conf/type/__group/TODO
@@ -0,0 +1,2 @@
+- delete groups
+
diff --git a/conf/type/__package_emerge/manifest b/conf/type/__group/explorer/group
similarity index 65%
rename from conf/type/__package_emerge/manifest
rename to conf/type/__group/explorer/group
index 178fa510..4c1e6ac0 100755
--- a/conf/type/__package_emerge/manifest
+++ b/conf/type/__group/explorer/group
@@ -18,19 +18,10 @@
# along with cdist. If not, see .
#
#
-# __package is an abstract type which dispatches to the lower level
-# __package_$name types which do the actual interaction with the packaging
-# system.
+# Get an existing groups group entry.
#
-# TODO: depend on package gentoolkit for qpkg
+name=$__object_id
-# TODO:
-# if /var/cache/eix is older then /usr/portage/metadata/timestamp
-# then run /usr/bin/eix-update
-#
-# check if package is installed:
-#
-# get currently installed version:
-#
+getent group "$name" || true
diff --git a/conf/type/__package_emerge/gencode b/conf/type/__group/explorer/gshadow
similarity index 59%
rename from conf/type/__package_emerge/gencode
rename to conf/type/__group/explorer/gshadow
index ee95b823..51d502a1 100755
--- a/conf/type/__package_emerge/gencode
+++ b/conf/type/__group/explorer/gshadow
@@ -18,27 +18,10 @@
# along with cdist. If not, see .
#
#
-# Manage packages on gentoo.
+# Get an existing groups gshadow entry.
#
-if [ -f "$__object/parameter/name" ]; then
- name="$(cat "$__object/parameter/name")"
-else
- name="$__object_id"
-fi
+name=$__object_id
-state="$(cat "$__object/parameter/state")"
+getent gshadow "$name" || true
-case "$state" in
- installed)
- # FIXME: only install if not already installed
- echo "emerge -q \"$name\""
- ;;
- deinstalled)
- # FIXME: only uninstall if currently installed
- # FIXME: rename deinstalled to uninstalled
- echo "emerge -q -C \"$name\""
- ;;
-esac
-
-exit 0
diff --git a/conf/type/__group/gencode b/conf/type/__group/gencode
new file mode 100755
index 00000000..527a6079
--- /dev/null
+++ b/conf/type/__group/gencode
@@ -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 .
+#
+#
+# Manage groups.
+#
+
+name="$__object_id"
+
+command=
+if grep -q "^$name" "$__object/explorer/group"; then
+ # group exists
+ command="groupmod"
+else
+ # group does not exist
+ command="groupadd"
+fi
+
+
+get_current_value() {
+ local key="$1"
+ local index
+ case "$key" in
+ password)
+ cut -d':' -f 2 "$__object/explorer/gshadow"
+ break
+ ;;
+ gid) index=3;;
+ esac
+ cut -d':' -f $index "$__object/explorer/group"
+}
+
+
+set -- "$@"
+cd "$__object/parameter"
+for property in $(ls .); do
+ current_value=$(get_current_value "$property")
+ new_value="$(cat "$property")"
+ if [ "$new_value" != "$current_value" ]; then
+ # Shedule changed properties for update
+ set -- "$@" "--$property" \"$new_value\"
+ fi
+done
+
+
+if [ $# -gt 0 ]; then
+ # Update changed properties
+ echo $command $@ $name
+fi
+
diff --git a/conf/type/__group/man.text b/conf/type/__group/man.text
new file mode 100644
index 00000000..26b52111
--- /dev/null
+++ b/conf/type/__group/man.text
@@ -0,0 +1,52 @@
+cdist-type__group(7)
+===================
+Steven Armstrong
+
+
+NAME
+----
+cdist-type__group - Manage groups
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to create or modify groups on the target.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+gid::
+ see groupmod(8)
+password::
+ see above
+
+
+EXAMPLES
+--------
+
+--------------------------------------------------------------------------------
+# Create a group 'foobar' with operating system default settings
+__group foobar
+
+# Same but with a specific gid
+__group foobar --gid 1234
+
+# Same but with a gid and password
+__group foobar --gid 1234 --password 'crypted-password-string'
+--------------------------------------------------------------------------------
+
+
+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/conf/type/__group/parameter/optional b/conf/type/__group/parameter/optional
new file mode 100644
index 00000000..4c661c8f
--- /dev/null
+++ b/conf/type/__group/parameter/optional
@@ -0,0 +1,2 @@
+gid
+password
diff --git a/conf/type/__package/man.text b/conf/type/__package/man.text
new file mode 100644
index 00000000..eeeceba0
--- /dev/null
+++ b/conf/type/__package/man.text
@@ -0,0 +1,61 @@
+cdist-type__user(7)
+===================
+Steven Armstrong
+
+
+NAME
+----
+cdist-type__package - Manage packages
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to install or uninstall packages on the target.
+It dispatches the actual work to the package system dependant types.
+
+
+REQUIRED PARAMETERS
+-------------------
+state::
+ The state the package should be in, either "installed" or "uninstalled"
+
+
+OPTIONAL PARAMETERS
+-------------------
+name::
+ The name of the package to install. Default is to use the object_id as the
+ package name.
+version::
+ The version of the package to install. Default is to install the version
+ choosen by the local package manager.
+type::
+ The package type to use. Default is determined based on the $os explorer
+ variable.
+ e.g. __package_apt for Debian
+ __package_emerge for Gentoo
+
+
+EXAMPLES
+--------
+
+--------------------------------------------------------------------------------
+# Install the package vim on the target
+__package vim --state installed
+
+# Same but install specific version
+__package vim --state installed --version 7.3.50
+
+# Force use of a specific package type
+__package vim --state installed --type __package_apt
+--------------------------------------------------------------------------------
+
+
+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/conf/type/__package_apt/gencode b/conf/type/__package_apt/gencode
index 413562d5..370f0102 100755
--- a/conf/type/__package_apt/gencode
+++ b/conf/type/__package_apt/gencode
@@ -38,7 +38,7 @@ case "$state" in
echo apt-get --quiet --yes install \"$name\"
fi
;;
- deinstalled)
+ uninstalled)
# Remove only if existent
if [ -n "$is_installed" ]; then
echo apt-get --quiet --yes remove \"$name\"
diff --git a/conf/type/__package_emerge/parameter/optional b/conf/type/__package_emerge/parameter/optional
deleted file mode 100644
index a52167d3..00000000
--- a/conf/type/__package_emerge/parameter/optional
+++ /dev/null
@@ -1,2 +0,0 @@
-name
-version
diff --git a/conf/type/__package_emerge/parameter/required b/conf/type/__package_emerge/parameter/required
deleted file mode 100644
index ff72b5c7..00000000
--- a/conf/type/__package_emerge/parameter/required
+++ /dev/null
@@ -1 +0,0 @@
-state
diff --git a/conf/type/__package_pacman/gencode b/conf/type/__package_pacman/gencode
index 9702aa8e..536b7708 100755
--- a/conf/type/__package_pacman/gencode
+++ b/conf/type/__package_pacman/gencode
@@ -44,7 +44,7 @@ case "$state" in
echo pacman "$pacopts" -S \"$name\"
fi
;;
- deinstalled)
+ uninstalled)
if [ "$pkg_version" ]; then
echo pacman "$pacopts" -R \"$name\"
fi
diff --git a/conf/type/__user/TODO b/conf/type/__user/TODO
new file mode 100644
index 00000000..fa6aeee7
--- /dev/null
+++ b/conf/type/__user/TODO
@@ -0,0 +1,2 @@
+- delete users
+
diff --git a/conf/type/__user/explorer/passwd b/conf/type/__user/explorer/passwd
new file mode 100755
index 00000000..fdbfb193
--- /dev/null
+++ b/conf/type/__user/explorer/passwd
@@ -0,0 +1,27 @@
+#!/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 .
+#
+#
+# Get an existing users passwd entry.
+#
+
+name=$__object_id
+
+getent passwd "$name" || true
+
diff --git a/conf/type/__user/explorer/shadow b/conf/type/__user/explorer/shadow
new file mode 100755
index 00000000..c75e36f4
--- /dev/null
+++ b/conf/type/__user/explorer/shadow
@@ -0,0 +1,27 @@
+#!/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 .
+#
+#
+# Get an existing users shadow entry.
+#
+
+name=$__object_id
+
+getent shadow "$name" || true
+
diff --git a/conf/type/__user/gencode b/conf/type/__user/gencode
new file mode 100755
index 00000000..5990ac92
--- /dev/null
+++ b/conf/type/__user/gencode
@@ -0,0 +1,70 @@
+#!/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 .
+#
+#
+# Manage users.
+#
+
+name="$__object_id"
+
+command=
+if grep -q "^$name" "$__object/explorer/passwd"; then
+ # user exists
+ command="usermod"
+else
+ # user does not exist
+ command="useradd"
+fi
+
+
+get_current_value() {
+ local key="$1"
+ local index
+ case "$key" in
+ password)
+ cut -d':' -f 2 "$__object/explorer/shadow"
+ break
+ ;;
+ uid) index=3;;
+ gid) index=4;;
+ comment) index=5;;
+ home) index=6;;
+ shell) index=7;;
+ esac
+ cut -d':' -f $index "$__object/explorer/passwd"
+}
+
+
+set -- "$@"
+cd "$__object/parameter"
+for property in $(ls .); do
+ current_value=$(get_current_value "$property")
+ new_value="$(cat "$property")"
+ if [ "$new_value" != "$current_value" ]; then
+ # Shedule changed properties for update
+ set -- "$@" "--$property" \"$new_value\"
+ fi
+done
+
+
+if [ $# -gt 0 ]; then
+ # Update changed properties
+ echo $command $@ $name
+fi
+
diff --git a/conf/type/__user/man.text b/conf/type/__user/man.text
new file mode 100644
index 00000000..e571c7c5
--- /dev/null
+++ b/conf/type/__user/man.text
@@ -0,0 +1,62 @@
+cdist-type__user(7)
+===================
+Steven Armstrong
+
+
+NAME
+----
+cdist-type__user - Manage users
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to create or modify users on the target.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+comment::
+ see usermod(8)
+home::
+ see above
+gid::
+ see above
+groups::
+ see above
+password::
+ see above
+shell::
+ see above
+uid::
+ see above
+
+
+EXAMPLES
+--------
+
+--------------------------------------------------------------------------------
+# Create user account for foobar with operating system default settings
+__user foobar
+
+# Same but with a different shell
+__user foobar --shell /bin/zsh
+
+# Set explicit uid and home
+__user foobar --uid 1001 --shell /bin/zsh --home /home/foobar
+--------------------------------------------------------------------------------
+
+
+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/conf/type/__user/parameter/optional b/conf/type/__user/parameter/optional
new file mode 100644
index 00000000..fe02e227
--- /dev/null
+++ b/conf/type/__user/parameter/optional
@@ -0,0 +1,7 @@
+comment
+home
+gid
+groups
+password
+shell
+uid
diff --git a/doc/changelog b/doc/changelog
index 52a872d1..fae5607a 100644
--- a/doc/changelog
+++ b/doc/changelog
@@ -9,6 +9,8 @@
* New type __motd
* New type __addifnosuchline (Daniel Roth)
* Document type __issue
+ * New type __user
+ * Document type __package
* Document type __package_pacman
* Document type __package_apt
* New parameter for __file: --owner and --group