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
a36a3c0d
Commit
a36a3c0d
authored
Jan 04, 2016
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #746 from ar45/fix_debian_systemd_getty
Fix #520 - multiple instances of agetty on systemd.
parents
25a9939b
a3d42f4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
12 deletions
+30
-12
lxc-debian.in
templates/lxc-debian.in
+30
-12
No files found.
templates/lxc-debian.in
View file @
a36a3c0d
...
@@ -45,10 +45,11 @@ configure_debian()
...
@@ -45,10 +45,11 @@ configure_debian()
{
{
rootfs
=
$1
rootfs
=
$1
hostname
=
$2
hostname
=
$2
num_tty
=
$3
# squeeze only has /dev/tty and /dev/tty0 by default,
# squeeze only has /dev/tty and /dev/tty0 by default,
# therefore creating missing device nodes for tty1-4.
# therefore creating missing device nodes for tty1-4.
for
tty
in
$(
seq
1
4
)
;
do
for
tty
in
$(
seq
1
$num_tty
)
;
do
if
[
!
-e
$rootfs
/dev/tty
$tty
]
;
then
if
[
!
-e
$rootfs
/dev/tty
$tty
]
;
then
mknod
$rootfs
/dev/tty
$tty
c 4
$tty
mknod
$rootfs
/dev/tty
$tty
c 4
$tty
fi
fi
...
@@ -68,10 +69,7 @@ l6:6:wait:/etc/init.d/rc 6
...
@@ -68,10 +69,7 @@ l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
z6:6:respawn:/sbin/sulogin
1:2345:respawn:/sbin/getty 38400 console
1:2345:respawn:/sbin/getty 38400 console
c1:12345:respawn:/sbin/getty 38400 tty1 linux
$(for
tty
in
$(
seq
1
$num_tty
)
;
do
echo
"c
${
tty
}
:12345:respawn:/sbin/getty 38400 tty
${
tty
}
linux"
;
done
;
)
c2:12345:respawn:/sbin/getty 38400 tty2 linux
c3:12345:respawn:/sbin/getty 38400 tty3 linux
c4:12345:respawn:/sbin/getty 38400 tty4 linux
p6::ctrlaltdel:/sbin/init 6
p6::ctrlaltdel:/sbin/init 6
p0::powerfail:/sbin/init 0
p0::powerfail:/sbin/init 0
EOF
EOF
...
@@ -191,6 +189,8 @@ configure_debian_systemd()
...
@@ -191,6 +189,8 @@ configure_debian_systemd()
{
{
path
=
$1
path
=
$1
rootfs
=
$2
rootfs
=
$2
config
=
$3
num_tty
=
$4
# this only works if we have getty@.service to manipulate
# this only works if we have getty@.service to manipulate
if
[
-f
${
rootfs
}
/lib/systemd/system/getty
\@
.service
]
;
then
if
[
-f
${
rootfs
}
/lib/systemd/system/getty
\@
.service
]
;
then
...
@@ -206,7 +206,10 @@ configure_debian_systemd()
...
@@ -206,7 +206,10 @@ configure_debian_systemd()
# Fix getty-static-service as debootstrap does not install dbus
# Fix getty-static-service as debootstrap does not install dbus
if
[
-e
$rootfs
//lib/systemd/system/getty-static.service
]
;
then
if
[
-e
$rootfs
//lib/systemd/system/getty-static.service
]
;
then
sed
's/ getty@tty[5-9].service//g'
$rootfs
/lib/systemd/system/getty-static.service |
sed
's/\(tty2-tty\)[5-9]/\14/g'
>
$rootfs
/etc/systemd/system/getty-static.service
local
tty_services
=
$(for
i
in
$(
seq
2
$num_tty
)
;
do
echo
-n
"getty@tty
${
i
}
.service "
;
done
;
)
sed
's/ getty@tty.*/'
"
$tty_services
"
'/g'
\
$rootfs
/lib/systemd/system/getty-static.service |
\
sed
's/\(tty2-tty\)[5-9]/\1'
"
${
num_tty
}
"
'/g'
>
$rootfs
/etc/systemd/system/getty-static.service
fi
fi
# This function has been copied and adapted from lxc-fedora
# This function has been copied and adapted from lxc-fedora
...
@@ -216,10 +219,16 @@ configure_debian_systemd()
...
@@ -216,10 +219,16 @@ configure_debian_systemd()
chroot
${
rootfs
}
ln
-s
/lib/systemd/system/multi-user.target /etc/systemd/system/default.target
chroot
${
rootfs
}
ln
-s
/lib/systemd/system/multi-user.target /etc/systemd/system/default.target
# Make systemd honor SIGPWR
# Make systemd honor SIGPWR
chroot
${
rootfs
}
ln
-s
/lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
chroot
${
rootfs
}
ln
-s
/lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
# Setup getty service on the
4
ttys we are going to allow in the
# Setup getty service on the ttys we are going to allow in the
# default config. Number should match lxc.tty
# default config. Number should match lxc.tty
(
cd
${
rootfs
}
/etc/systemd/system/getty.target.wants
(
cd
${
rootfs
}
/etc/systemd/system/getty.target.wants
for
i
in
1 2 3 4
;
do
ln
-sf
../getty
\@
.service getty@tty
${
i
}
.service
;
done
)
for
i
in
$(
seq
1
$num_tty
)
;
do
ln
-sf
../getty
\@
.service getty@tty
${
i
}
.service
;
done
)
# Since we use static-getty.target; we need to mask container-getty@.service generated by
# container-getty-generator, so we don't get multiple instances of agetty running.
# See https://github.com/lxc/lxc/issues/520 and https://github.com/lxc/lxc/issues/484
(
cd
${
rootfs
}
/etc/systemd/system/getty.target.wants
for
i
in
$(
seq
0
$num_tty
)
;
do
ln
-sf
/dev/null container-getty
\@
${
i
}
.service
;
done
)
return
0
return
0
}
}
...
@@ -353,6 +362,7 @@ copy_configuration()
...
@@ -353,6 +362,7 @@ copy_configuration()
rootfs
=
$2
rootfs
=
$2
hostname
=
$3
hostname
=
$3
arch
=
$4
arch
=
$4
num_tty
=
$5
# Generate the configuration file
# Generate the configuration file
# if there is exactly one veth network entry, make sure it has an
# if there is exactly one veth network entry, make sure it has an
...
@@ -378,6 +388,7 @@ copy_configuration()
...
@@ -378,6 +388,7 @@ copy_configuration()
grep
-q
"^lxc.rootfs"
$path
/config 2> /dev/null
||
echo
"lxc.rootfs =
$rootfs
"
>>
$path
/config
grep
-q
"^lxc.rootfs"
$path
/config 2> /dev/null
||
echo
"lxc.rootfs =
$rootfs
"
>>
$path
/config
cat
<<
EOF
>>
$path
/config
cat
<<
EOF
>>
$path
/config
lxc.tty =
$num_tty
lxc.utsname =
$hostname
lxc.utsname =
$hostname
lxc.arch =
$arch
lxc.arch =
$arch
EOF
EOF
...
@@ -608,31 +619,38 @@ fi
...
@@ -608,31 +619,38 @@ fi
config
=
"
$path
/config"
config
=
"
$path
/config"
if
[
-z
"
$rootfs
"
]
;
then
if
[
-z
"
$rootfs
"
]
;
then
if
grep
-q
'^lxc.rootfs'
$config
2> /dev/null
;
then
if
grep
-q
'^lxc.rootfs'
$config
2> /dev/null
;
then
rootfs
=
$(
awk
-F
=
'/^lxc.rootfs
=/{ print $2 }'
$config
)
rootfs
=
$(
awk
-F
=
'/^lxc.rootfs
[ \t]+
=/{ print $2 }'
$config
)
else
else
rootfs
=
$path
/rootfs
rootfs
=
$path
/rootfs
fi
fi
fi
fi
# determine the number of ttys - default is 4
if
grep
-q
'^lxc.tty'
$config
2> /dev/null
;
then
num_tty
=
$(
awk
-F
=
'/^lxc.tty[ \t]+=/{ print $2 }'
$config
)
else
num_tty
=
4
fi
install_debian
$rootfs
$release
$arch
$LXC_CACHE_PATH
install_debian
$rootfs
$release
$arch
$LXC_CACHE_PATH
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"failed to install debian"
echo
"failed to install debian"
exit
1
exit
1
fi
fi
configure_debian
$rootfs
$name
configure_debian
$rootfs
$name
$num_tty
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"failed to configure debian for a container"
echo
"failed to configure debian for a container"
exit
1
exit
1
fi
fi
copy_configuration
$path
$rootfs
$name
$arch
copy_configuration
$path
$rootfs
$name
$arch
$num_tty
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"failed write configuration file"
echo
"failed write configuration file"
exit
1
exit
1
fi
fi
configure_debian_systemd
$path
$rootfs
configure_debian_systemd
$path
$rootfs
$config
$num_tty
post_process
${
rootfs
}
${
release
}
${
arch
}
${
hostarch
}
${
packages
}
post_process
${
rootfs
}
${
release
}
${
arch
}
${
hostarch
}
${
packages
}
...
...
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