Skip to content

Commit 9ac9a6f

Browse files
authored
Create run_as_user.sh
1 parent 441331d commit 9ac9a6f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

run_as_user.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Exit on any error and treat unset variables as errors
4+
set -euo
5+
6+
OLD_UID=$1
7+
OLD_GID=$2
8+
shift; shift
9+
10+
groupadd --gid $OLD_GID --non-unique user
11+
useradd --uid $OLD_UID --gid $OLD_GID --non-unique user
12+
13+
sudo -E -u user "$@"

0 commit comments

Comments
 (0)