break su_monkeysphere_user into common function, since it will likely
[monkeysphere.git] / src / share / common
index 00a10080008571b4cd89b40f10fcc59015f26dfd..2a20c1c9311e203f0f30009da0ba91172fad1ca3 100644 (file)
@@ -90,6 +90,19 @@ log() {
     done
 }
 
+# run command as monkeysphere user
+su_monkeysphere_user() {
+    # if the current user is the monkeysphere user, then just eval
+    # command
+    if [ $(id -un) = "$MONKEYSPHERE_USER" ] ; then
+       eval "$@"
+
+    # otherwise su command as monkeysphere user
+    else
+       su "$MONKEYSPHERE_USER" -c "$@"
+    fi
+}
+
 # cut out all comments(#) and blank lines from standard input
 meat() {
     grep -v -e "^[[:space:]]*#" -e '^$' "$1"