Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
8a82c80b
Unverified
Commit
8a82c80b
authored
Dec 08, 2017
by
Serge Hallyn
Committed by
GitHub
Dec 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2016 from flx42/lxc-oci-misc-improvements
lxc-oci misc improvements
parents
6d75f4cb
a787c332
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
lxc-oci.in
templates/lxc-oci.in
+46
-0
No files found.
templates/lxc-oci.in
View file @
8a82c80b
...
@@ -121,6 +121,40 @@ getenv() {
...
@@ -121,6 +121,40 @@ getenv() {
return
return
}
}
# FIXME 1: only support numerical values in the configuration file.
# FIXME 2: from the OCI image spec: "If group/gid is not specified,
# the default group and supplementary groups of the given user/uid in
# /etc/passwd from the container are applied."
getuidgid
()
{
if
[
"$#"
-eq
0
]
;
then
echo
"0 0"
return
fi
configpath
=
"
$1
"
uidgid
=
`
cat
"
${
configpath
}
"
| jq
-c
-r
'.config.User // "0:0"'
`
uidgid
=(
${
uidgid
//
:/
}
)
printf
'%d %d'
${
uidgid
[0]
:-
0
}
${
uidgid
[1]
:-
0
}
2>/dev/null
||
true
return
}
# get cwd from oci image.
getcwd
()
{
if
[
"$#"
-eq
0
]
;
then
echo
"/"
return
fi
configpath
=
"
$1
"
cwd
=
`
cat
"
${
configpath
}
"
| jq
-c
-r
'.config.WorkingDir // "/"'
`
echo
"
${
cwd
}
"
return
}
usage
()
{
usage
()
{
cat
<<
EOF
cat
<<
EOF
LXC container template for OCI images
LXC container template for OCI images
...
@@ -289,8 +323,20 @@ EOF
...
@@ -289,8 +323,20 @@ EOF
cat
<<
EOF
>
${
LXC_ROOTFS
}
/etc/hosts
cat
<<
EOF
>
${
LXC_ROOTFS
}
/etc/hosts
127.0.0.1 localhost
127.0.0.1 localhost
127.0.1.1
${
LXC_NAME
}
127.0.1.1
${
LXC_NAME
}
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
EOF
uidgid
=(
$(
getuidgid
${
OCI_CONF_FILE
})
)
echo
"lxc.init.uid =
${
uidgid
[0]
}
"
>>
"
${
LXC_CONF_FILE
}
"
echo
"lxc.init.gid =
${
uidgid
[1]
}
"
>>
"
${
LXC_CONF_FILE
}
"
cwd
=
$(
getcwd
${
OCI_CONF_FILE
})
echo
"lxc.init.cwd =
${
cwd
}
"
>>
"
${
LXC_CONF_FILE
}
"
if
[
-n
"
$LXC_MAPPED_UID
"
]
&&
[
"
$LXC_MAPPED_UID
"
!=
"-1"
]
;
then
if
[
-n
"
$LXC_MAPPED_UID
"
]
&&
[
"
$LXC_MAPPED_UID
"
!=
"-1"
]
;
then
chown
$LXC_MAPPED_UID
$LXC_PATH
/config
$LXC_PATH
/fstab
>
/dev/null 2>&1
||
true
chown
$LXC_MAPPED_UID
$LXC_PATH
/config
$LXC_PATH
/fstab
>
/dev/null 2>&1
||
true
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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