diff --git a/deploy_app.sh b/deploy_app.sh
index 1823657db81926826b60d950c7b76427a057aad2..8fe2f668f12bb6ea7d381e724e79d52765ed3707 100755
--- a/deploy_app.sh
+++ b/deploy_app.sh
@@ -8,6 +8,7 @@
 # 2021-05-09  v0.2  <axel.hahn@iml.unibe.ch>  chown includes dot files
 # 2021-05-14  v0.3  <axel.hahn@iml.unibe.ch>  add params (list, force, help)
 # 2021-05-27  v0.4  <axel.hahn@iml.unibe.ch>  FIX first install
+# 2021-07-08  v0.5  <axel.hahn@iml.unibe.ch>  added function "runas"
 # ======================================================================
 
 
@@ -88,6 +89,24 @@ function header(){
     echo
 }
 
+# run a command as another posix user (even if it does not have a shell)
+# to be used in taskas_*install.sh
+#
+# example:
+# runas www-data "./hooks/ondeploy"
+#
+# param  string  username
+# param  string  command to execute. Needs to be quoted.
+# param  string  optional: shell (default: /bin/sh)
+function runas(){
+    local _user=$1
+    local _cmd=$2
+    local _shell=$3
+    test -z "$_shell" && _shell=/bin/sh
+
+    su $_user -s $_shell -c "$_cmd"
+}
+
 # execute a task/ hook - if the given task script exists and has executable
 # persmissions; if not it is not an error
 # param  string  filename