Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lukas Werner
cx-custom-gitlab-runner
Commits
e3b98641
Commit
e3b98641
authored
Aug 03, 2021
by
Lukas Werner
Browse files
Removed unnecessary auth in config.sh
parent
519d38c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
runner_scripts/root/config.sh
View file @
e3b98641
...
...
@@ -2,42 +2,6 @@
set
-euf
-o
pipefail
shopt
-s
inherit_errexit
hash id
hash
diff
hash
ssh-keygen
hash
runuser
function
error
{
:
"
${
RV
:
=
${
2
:-
$BUILD_FAILURE_EXIT_CODE
}}
"
echo
"
$1
"
>
&2
return
"
$RV
"
}
## User authentication
:
"
${
CUSTOM_ENV_AUTH_USER
:?
"AUTH_USER CI/CD variable has not been set."
}
"
:
"
${
CUSTOM_ENV_AUTH_KEY
:?
"AUTH_KEY CI/CD variable has not been set."
}
"
AUTH_USER
=
$CUSTOM_ENV_AUTH_USER
## Check if the user exists and the validity of its ID
id
-u
"
$AUTH_USER
"
>
/dev/null 2>&1
||
error
"User
$AUTH_USER
does not exist"
((
$(
id
-u
"
$AUTH_USER
"
)
>=
1000
))
||
error
"User
$AUTH_USER
ID within system reserved range."
## Use a key pair to authenticate the user (private key has to be set as a GitLab CI/CD variable)
AUTH_KEY
=
$CUSTOM_ENV_AUTH_KEY
AUTH_PUB
=
/etc/gitlab-runner/authorized_keys
(
while
read
-r
PUB
do
diff
--color
=
never <
(
ssh-keygen
-y
-e
-f
/dev/stdin
<<<
"
$AUTH_KEY
"
)
<
(
ssh-keygen
-y
-e
-f
/dev/stdin
<<<
"
$PUB
"
)
>
/dev/null
&&
exit
0
done
<
"
$AUTH_PUB
"
exit
1
)
||
error
"Authentication failed."
### Env setup
AUTH_USER_WORK
=
$(
runuser
"
$AUTH_USER
"
--login
--command
"echo
\$
WORK"
)
:
"
${
AUTH_USER_WORK
:?
"Could not determine
$AUTH_USER
's
\$
WORK directory."
}
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment