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
ce59e4ca
Commit
ce59e4ca
authored
Nov 22, 2017
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-oci: add utility function to retrieve the path of the config file
Signed-off-by:
Felix Abecassis
<
fabecassis@nvidia.com
>
parent
b5236550
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
lxc-oci.in
templates/lxc-oci.in
+18
-9
No files found.
templates/lxc-oci.in
View file @
ce59e4ca
...
...
@@ -54,17 +54,13 @@ in_userns() {
echo yes
}
# get entrypoint from oci image. Use sh if unspecified
# TODO - we can get other things like resource limits here
getep
()
{
getconfigpath
()
{
basedir
=
"
$1
"
q
=
"
$2
"
digest
=
`
cat
"
${
basedir
}
/index.json"
| jq
--arg
q
"
$q
"
'.manifests[] | if .annotations."org.opencontainers.image.ref.name" == $q then .digest else null end'
|
sed
-e
's/"//g'
`
if
[
-z
"
${
digest
}
"
]
;
then
echo
"
$q
not found in index.json"
>
&2
echo
"/bin/sh"
return
fi
...
...
@@ -73,13 +69,25 @@ getep() {
cdigest
=
`
cat
"
${
basedir
}
/blobs/sha256/
${
d
}
"
| jq
'.config.digest'
|
sed
-e
's/"//g'
`
if
[
-z
"
${
cdigest
}
"
]
;
then
echo
"container config not found"
>
&2
echo
"/bin/sh"
return
fi
d2
=
${
cdigest
:7
}
ep
=
`
cat
"
${
basedir
}
/blobs/sha256/
${
d2
}
"
| jq
-c
'.config.Entrypoint'
|
sed
-e
's/^\[//; s/\]$//; s/","/" "/'
`
cmd
=
`
cat
"
${
basedir
}
/blobs/sha256/
${
d2
}
"
| jq
-c
'.config.Cmd'
|
sed
-e
's/^\[//; s/\]$//; s/","/" "/'
`
echo
"
${
basedir
}
/blobs/sha256/
${
d2
}
"
return
}
# get entrypoint from oci image. Use sh if unspecified
getep
()
{
if
[
"$#"
-eq
0
]
;
then
echo
"/bin/sh"
return
fi
configpath
=
"
$1
"
ep
=
`
cat
"
${
configpath
}
"
| jq
-c
'.config.Entrypoint'
|
sed
-e
's/^\[//; s/\]$//; s/","/" "/'
`
cmd
=
`
cat
"
${
configpath
}
"
| jq
-c
'.config.Cmd'
|
sed
-e
's/^\[//; s/\]$//; s/","/" "/'
`
if
[
"
${
ep
}
"
=
"null"
]
;
then
ep
=
"
${
cmd
}
"
if
[
"
${
ep
}
"
=
"null"
]
;
then
...
...
@@ -197,10 +205,11 @@ fi
umoci unpack
${
umoci_args
[@]
}
--image
"
${
DOWNLOAD_TEMP
}
:latest"
"
${
LXC_ROOTFS
}
.tmp"
rmdir
"
${
LXC_ROOTFS
}
"
mv
"
${
LXC_ROOTFS
}
.tmp/rootfs"
"
${
LXC_ROOTFS
}
"
entrypoint
=
$(
getep
${
DOWNLOAD_TEMP
}
latest
)
rm
-rf
"
${
LXC_ROOTFS
}
.tmp"
OCI_CONF_FILE
=
$(
getconfigpath
${
DOWNLOAD_TEMP
}
latest
)
LXC_CONF_FILE
=
"
${
LXC_PATH
}
/config"
entrypoint
=
$(
getep
${
OCI_CONF_FILE
})
echo
"lxc.execute.cmd = '
${
entrypoint
}
'"
>>
"
${
LXC_CONF_FILE
}
"
echo
"lxc.mount.auto = proc:mixed sys:mixed cgroup:mixed"
>>
"
${
LXC_CONF_FILE
}
"
...
...
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