FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cli/scripts/updateUID.Dockerfile at main · v-Mathiyarasy/cli · GitHub
v-Mathiyarasy
/
cli
Public
forked from
devcontainers/cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cli
/
scripts
/
updateUID.Dockerfile
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (32 loc) · 1.43 KB
Breadcrumbs
cli
/
scripts
/
updateUID.Dockerfile
Copy path
File metadata and controls
35 lines (32 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
Copyright (c) Microsoft Corporation. All rights reserved.
#
Licensed under the MIT License. See License.txt in the project root for license information.
ARG
BASE_IMAGE
FROM
$BASE_IMAGE
USER
root
ARG
REMOTE_USER
ARG
NEW_UID
ARG
NEW_GID
SHELL
[
"/bin/sh"
,
"-c"
]
RUN
eval $(sed -n
"s/${REMOTE_USER}:[^:]*:
\(
[^:]*
\)
:
\(
[^:]*
\)
:[^:]*:
\(
[^:]*
\)
.*/OLD_UID=
\1
;OLD_GID=
\2
;HOME_FOLDER=
\3
/p"
/etc/passwd); \
eval $(sed -n
"s/
\(
[^:]*
\)
:[^:]*:${NEW_UID}:.*/EXISTING_USER=
\1
/p"
/etc/passwd); \
eval $(sed -n
"s/
\(
[^:]*
\)
:[^:]*:${NEW_GID}:.*/EXISTING_GROUP=
\1
/p"
/etc/group); \
if [ -z
"$OLD_UID"
]; then \
echo
"Remote user not found in /etc/passwd ($REMOTE_USER)."
; \
elif [
"$OLD_UID"
=
"$NEW_UID"
-a
"$OLD_GID"
=
"$NEW_GID"
]; then \
echo
"UIDs and GIDs are the same ($NEW_UID:$NEW_GID)."
; \
elif [
"$OLD_UID"
!=
"$NEW_UID"
-a -n
"$EXISTING_USER"
]; then \
echo
"User with UID exists ($EXISTING_USER=$NEW_UID)."
; \
else \
if [
"$OLD_GID"
!=
"$NEW_GID"
-a -n
"$EXISTING_GROUP"
]; then \
echo
"Group with GID exists ($EXISTING_GROUP=$NEW_GID)."
; \
NEW_GID=
"$OLD_GID"
; \
fi; \
echo
"Updating UID:GID from $OLD_UID:$OLD_GID to $NEW_UID:$NEW_GID."
; \
sed -i -e
"s/
\(
${REMOTE_USER}:[^:]*:
\)
[^:]*:[^:]*/
\1
${NEW_UID}:${NEW_GID}/"
/etc/passwd; \
if [
"$OLD_GID"
!=
"$NEW_GID"
]; then \
sed -i -e
"s/
\(
[^:]*:[^:]*:
\)
${OLD_GID}:/
\1
${NEW_GID}:/"
/etc/group; \
fi; \
chown -R $NEW_UID:$NEW_GID $HOME_FOLDER; \
fi;
ARG
IMAGE_USER
USER
$IMAGE_USER
Back
|
FazBrowse Home
|
New Git URL