Skip to content

Commit

Permalink
Merge pull request #15 from rrauenza/feature-add-base
Browse files Browse the repository at this point in the history
add --base option to set the base directory for home directories
  • Loading branch information
vbem authored Jun 7, 2024
2 parents 2285af8 + 2698648 commit d8b4693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Options:
--org GitHub organization name
--repo GitHub repository name, registration on organization-level if empty
--user Linux local username of runner
--base Base directory for user home directories
--labels Extra labels for the runner
--group Runner group for the runner
--token Runner registration token, takes precedence over MR_GITHUB_PAT
Expand Down
9 changes: 7 additions & 2 deletions mr.bash
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function mr::addUser {
run::logFailed sudo tee /etc/sudoers.d/runners <<<'%runners ALL=(ALL) NOPASSWD:ALL' >/dev/null \
&& run::logFailed sudo groupadd -f 'runners' >&2 \
&& run::logFailed sudo groupadd -f 'docker' >&2 \
&& run::log sudo useradd -m -s /bin/bash -G 'runners,docker' "$user" >&2 || return $?
&& run::log sudo useradd -b "${base:-/home}" -m -s /bin/bash -G 'runners,docker' "$user" >&2 || return $?
echo "$user"
}

Expand Down Expand Up @@ -337,6 +337,7 @@ Options:
--org GitHub organization name
--repo GitHub repository name, registration on organization-level if empty
--user Linux local username of runner
--base Base directory for user home directories
--labels Extra labels for the runner
--group Runner group for the runner
--token Runner registration token, takes precedence over MR_GITHUB_PAT
Expand All @@ -352,7 +353,7 @@ function mr::main {
local org='' repo='' user='' labels='' token='' group='' dotenv=''

# parse options into variables
getopt_output="$(getopt -o h -l help,org:,repo:,user:,labels:,token:,group:,dotenv: -n "$FILE_THIS" -- "$@")"
getopt_output="$(getopt -o h -l help,org:,repo:,base:,user:,labels:,token:,group:,dotenv: -n "$FILE_THIS" -- "$@")"
log::failed $? "getopt failed!" || return $?
eval set -- "$getopt_output"

Expand All @@ -371,6 +372,10 @@ function mr::main {
user="$2"
shift 2
;;
--base)
base="$2"
shift 2
;;
--labels)
labels="$2"
shift 2
Expand Down

0 comments on commit d8b4693

Please sign in to comment.