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
5845ac2b
Unverified
Commit
5845ac2b
authored
Feb 07, 2016
by
Jakub Jirutka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-alpine: remove all bashisms, make it compatible with dash
Signed-off-by:
Jakub Jirutka
<
jakub@jirutka.cz
>
parent
04fa4e12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
lxc-alpine.in
templates/lxc-alpine.in
+15
-14
No files found.
templates/lxc-alpine.in
View file @
5845ac2b
#!/bin/sh
#!/bin/sh
# vim: set ts=4:
# vim: set ts=4:
set
-o
errexit
-o
pipefail
-o
nounset
# Exit on error and treat unset variables as an error.
set
-eu
#
#
# LXC template for Alpine Linux 3+
# LXC template for Alpine Linux 3+
...
@@ -47,7 +49,7 @@ readonly APK_KEYS_URI='http://alpinelinux.org/keys'
...
@@ -47,7 +49,7 @@ readonly APK_KEYS_URI='http://alpinelinux.org/keys'
readonly
MIRRORS_LIST_URL
=
'http://rsync.alpinelinux.org/alpine/MIRRORS.txt'
readonly
MIRRORS_LIST_URL
=
'http://rsync.alpinelinux.org/alpine/MIRRORS.txt'
:
${
APK_KEYS_DIR
:
=/etc/apk/keys
}
:
${
APK_KEYS_DIR
:
=/etc/apk/keys
}
if
!
ls
"
$APK_KEYS_DIR
"
/alpine
*
&>/dev/null
;
then
if
!
ls
"
$APK_KEYS_DIR
"
/alpine
*
>
/dev/null 2>&1
;
then
APK_KEYS_DIR
=
"
$LXC_CACHE_DIR
/bootstrap/keys"
APK_KEYS_DIR
=
"
$LXC_CACHE_DIR
/bootstrap/keys"
fi
fi
readonly
APK_KEYS_DIR
readonly
APK_KEYS_DIR
...
@@ -90,12 +92,12 @@ usage() {
...
@@ -90,12 +92,12 @@ usage() {
die
()
{
die
()
{
local
retval
=
$1
;
shift
local
retval
=
$1
;
shift
echo
-e
"ERROR:
$@
"
>
&2
printf
'ERROR: %s\n'
"
$@
"
1
>&2
exit
$retval
exit
$retval
}
}
einfo
()
{
einfo
()
{
echo
-e
"
\n
==>
$@
"
printf
"
\n
==>
$1
\n
"
}
}
fetch
()
{
fetch
()
{
...
@@ -154,7 +156,7 @@ run_exclusively() {
...
@@ -154,7 +156,7 @@ run_exclusively() {
#============================ Bootstrap ===========================#
#============================ Bootstrap ===========================#
bootstrap
()
{
bootstrap
()
{
if
[
[
"
$FLUSH_CACHE
"
=
'yes'
&&
-d
"
$LXC_CACHE_DIR
/bootstrap"
]
]
;
then
if
[
"
$FLUSH_CACHE
"
=
'yes'
]
&&
[
-d
"
$LXC_CACHE_DIR
/bootstrap"
]
;
then
einfo
'Cleaning cached bootstrap files'
einfo
'Cleaning cached bootstrap files'
rm
-Rf
"
$LXC_CACHE_DIR
/bootstrap"
rm
-Rf
"
$LXC_CACHE_DIR
/bootstrap"
fi
fi
...
@@ -185,7 +187,7 @@ fetch_apk_keys() {
...
@@ -185,7 +187,7 @@ fetch_apk_keys() {
echo
"
$line
"
|
sha256sum
-c
-
echo
"
$line
"
|
sha256sum
-c
-
done
||
exit
2
done
||
exit
2
cd
-
1
>/dev/null
cd
-
>
/dev/null
}
}
fetch_apk_static
()
{
fetch_apk_static
()
{
...
@@ -229,7 +231,7 @@ install() {
...
@@ -229,7 +231,7 @@ install() {
local
branch
=
"
$3
"
local
branch
=
"
$3
"
local
cache_dir
=
"
$LXC_CACHE_DIR
/rootfs-
$branch
-
$arch
"
local
cache_dir
=
"
$LXC_CACHE_DIR
/rootfs-
$branch
-
$arch
"
if
[
[
"
$FLUSH_CACHE
"
==
'yes'
&&
-d
"
$cache_dir
"
]
]
;
then
if
[
"
$FLUSH_CACHE
"
=
'yes'
]
&&
[
-d
"
$cache_dir
"
]
;
then
einfo
"Cleaning cached rootfs of Alpine
$branch
$arch
"
einfo
"Cleaning cached rootfs of Alpine
$branch
$arch
"
rm
-Rf
"
$cache_dir
"
rm
-Rf
"
$cache_dir
"
fi
fi
...
@@ -270,7 +272,7 @@ build_alpine() {
...
@@ -270,7 +272,7 @@ build_alpine() {
chroot
.
/bin/true
\
chroot
.
/bin/true
\
||
die 3
'Failed to execute /bin/true in chroot, the builded rootfs is broken!'
||
die 3
'Failed to execute /bin/true in chroot, the builded rootfs is broken!'
cd
-
1>&
/dev/null
cd
-
>
/dev/null
rm
-Rf
"
$dest
"
rm
-Rf
"
$dest
"
mv
"
$dest
.part"
"
$dest
"
mv
"
$dest
.part"
"
$dest
"
...
@@ -336,7 +338,7 @@ start() {
...
@@ -336,7 +338,7 @@ start() {
:a; n; /^
${
end_tag
}
/!ba; n
:a; n; /^
${
end_tag
}
/!ba; n
}; p" /etc/hosts
}; p" /etc/hosts
else
else
echo -e
"
$content
" >> /etc/hosts
printf
"
$content
" >> /etc/hosts
fi
fi
}
}
EOF
EOF
...
@@ -456,12 +458,11 @@ while [ $# -gt 0 ]; do
...
@@ -456,12 +458,11 @@ while [ $# -gt 0 ]; do
shift
;
break
shift
;
break
;;
;;
--mapped-
[
ug]id
)
--mapped-
[
ug]id
)
echo
"ERROR: This template can't be used for unprivileged containers."
>
&2
die 1
"This template can't be used for unprivileged containers."
\
echo
'You may want to try the "download" template instead.'
>
&2
'You may want to try the "download" template instead.'
exit
1
;;
;;
*
)
*
)
echo
"Unknown option:
$1
"
>
&2
echo
"Unknown option:
$1
"
1
>&2
usage
;
exit
1
usage
;
exit
1
;;
;;
esac
esac
...
@@ -478,7 +479,7 @@ readonly MIRROR_URL="${mirror_url:-$(random_mirror_url)}"
...
@@ -478,7 +479,7 @@ readonly MIRROR_URL="${mirror_url:-$(random_mirror_url)}"
[
-n
"
$name
"
]
||
die 1
'Missing required option --name'
[
-n
"
$name
"
]
||
die 1
'Missing required option --name'
[
-n
"
$path
"
]
||
die 1
'Missing required option --path'
[
-n
"
$path
"
]
||
die 1
'Missing required option --path'
if
[
[
-z
"
$rootfs
"
&&
-f
"
$path
/config"
]
]
;
then
if
[
-z
"
$rootfs
"
]
&&
[
-f
"
$path
/config"
]
;
then
rootfs
=
"
$(
sed
-nE
's/^lxc.rootfs\s*=\s*(.*)$/\1/p'
"
$path
/config"
)
"
rootfs
=
"
$(
sed
-nE
's/^lxc.rootfs\s*=\s*(.*)$/\1/p'
"
$path
/config"
)
"
fi
fi
if
[
-z
"
$rootfs
"
]
;
then
if
[
-z
"
$rootfs
"
]
;
then
...
...
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