Subject: [PATCH] Adjust ejabberdctl for Gentoo jabberbase setup

Set SHELL since the generic jabber user used on Gentoo for jabber
servers doesn't have a valid shell set by default and fix EXEC_CMD
otherwise it fails with This account is currently not available again
due to jabber not having a valid shell.

Also, workaround the assumption that jabber's /root is a directory when
instead it defaults to /dev/null on Gentoo.
---

diff --git a/ejabberdctl.template b/ejabberdctl.template
index 571b90b..71336c0 100755
--- a/ejabberdctl.template
+++ b/ejabberdctl.template
@@ -82,6 +82,7 @@ fi
 ERL_LIBS={{libdir}}
 ERL_CRASH_DUMP="$LOGS_DIR"/erl_crash_$(date "+%Y%m%d-%H%M%S").dump
 ERL_INETRC="$ETC_DIR"/inetrc
+HOME=$SPOOL_DIR
 
 # define ejabberd parameters
 EJABBERD_OPTS="$EJABBERD_OPTS\
@@ -105,12 +106,13 @@ export ERL_MAX_ETS_TABLES
 export CONTRIB_MODULES_PATH
 export CONTRIB_MODULES_CONF_DIR
 export ERL_LIBS
+export HOME
 
 # run command either directly or via su $INSTALLUSER
 exec_cmd()
 {
     case $EXEC_CMD in
-        as_install_user) su -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
+        as_install_user) su -p -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
         as_current_user) "$@" ;;
     esac
 }
