diff --git a/poc_service b/poc_service new file mode 100755 index 0000000..1c2e08b --- /dev/null +++ b/poc_service @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +RUNAS="daemon" + +sw_user(){ + curr_user=$( id -un ) + echo ">>> current user $curr_user" + if [ ! $curr_user = $RUNAS ] + then + echo ">>> wrong user" + echo ">>> commande $@" + sudo -nu $RUNAS $@ + exit $? + fi +} + +echo ">>> Args: $@" +sw_user $0 $@ + +echo "Running command as $( id -un ), with args: $@"