Skip to content
Snippets Groups Projects
Commit afd5f537 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

added function runas

parent 1a1a9ed5
Branches
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment