-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 13/06/12 03:14 PM, Mike Frysinger wrote:
>
> eset{home,shell} don't exist today, so you should implement them
> :) -mike
RFC - heavily based on enewuser.
- --- user.eclass [some timestamp]
+++ user.eclass.esethome [some other timestamp]
@@ -388,3 +388,63 @@
}
fi
+
+# @FUNCTION: esethome
+# @USAGE: <user> <homedir>
+# @DESCRIPTION:
+# Update the home directory in a platform-agnostic way.
+# Required parameters is the username and the new home directory.
+# Specify -1 if you want to set home to the enewuser default
+# of /dev/null.
+# If the new home directory does not exist, it is created.
+# Any previously existing home directory is NOT moved.
+esethome() {
+ _assert_pkg_ebuild_phase ${FUNCNAME}
+
+ # get the username
+ local euser=$1; shift
+ if [[ -z ${euser} ]] ; then
+ eerror "No username specified !"
+ die "Cannot call esethome without a username"
+ fi
+
+ # lets see if the username already exists
+ if [[ ! -n $(egetent passwd "${euser}") ]] ; then
+ ewarn "User does not exist, cannot set home. skipping."
+ return 1
+ fi
+
+ # handle homedir
+ local ehome=$1; shift
+ if [[ -z ${ehome} ]] ; then
+ eerror "No home directory specified !"
+ die "Cannot call esethome without a home directory"
+ fi
+
+ if [[ ${ehome} == "-1" ]] ; then
+ ehome="/dev/null"
+ fi
+ einfo " - Home: ${ehome}"
+
+ # update the home directory
+ case ${CHOST} in
+ *-darwin*)
+ dscl . change "/users/${euser}" home "${ehome}"
+ ;;
+
+ *-freebsd*|*-dragonfly*)
+ pw usermod "${euser}" -d "${ehome}" || die
+ ;;
+
+ *)
+ usermod -d "${ehome}" "${euser}" || die
+ ;;
+ esac
+
+ if [[ ! -e ${ROOT}/${ehome} ]] ; then
+ einfo " - Creating ${ehome} in ${ROOT}"
+ mkdir -p "${ROOT}/${ehome}"
+ chown "${euser}" "${ROOT}/${ehome}"
+ chmod 755 "${ROOT}/${ehome}"
+ fi
+}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
iF4EAREIAAYFAk/Y64wACgkQ2ugaI38ACPBZYQD9EzzmBDUon1YUNxaev5ONluAX
2GA32hOyvwGs2ylZPy8A/3RN8VNsa6XI++eHRdwjpsSZLw4sTVpa+fY2LZHSnWsh
=gLrd
-----END PGP SIGNATURE-----