Use the sinit conventions for init

This should make it easier to switch out `init` for other versions,
although the `getty` config still needs to be removed.

- use `/bin/rc.init` for start
- use `rc.shutdown` for stop
- make `rc.init` run other code.
- merge `containers` and `containerd` startup code

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-05-30 13:27:31 +01:00
parent 063d82c687
commit 08e211df44
6 changed files with 39 additions and 19 deletions

View File

@ -12,3 +12,4 @@ WORKDIR /
COPY --from=mirror /out/ /
COPY init /
COPY etc etc/
COPY bin bin/

View File

@ -110,3 +110,10 @@ mount --make-rshared /var
# make / rshared
mount --make-rshared /
# execute other init processes
INITS="$(find /etc/init.d -type f | sort)"
for f in $INITS
do
$f &
done

13
pkg/init/bin/rc.shutdown Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
[ "$1" = "reboot" ] && exec /sbin/reboot
# poweroff
/usr/sbin/killall5 -15
/bin/sleep 5
/usr/sbin/killall5 -9
/sbin/swapoff -a
/bin/echo "Unmounting filesystems"
/bin/umount -a -r
/sbin/poweroff -f

View File

@ -1,5 +1,19 @@
#!/bin/sh
# set global ulimits TODO move to /etc/limits.conf
ulimit -n 1048576
ulimit -p unlimited
# bring up containerd
printf "\nStarting containerd\n"
/usr/bin/containerd &
# wait for socket to be there
while [ ! -S /run/containerd/containerd.sock ]
do
sleep 0.1
done
# start onboot containers, run to completion
if [ -d /containers/onboot ]

View File

@ -1,9 +0,0 @@
#!/bin/sh
# bring up containerd
ulimit -n 1048576
ulimit -p unlimited
printf "\nStarting containerd\n"
mkdir -p /var/log
exec /usr/bin/containerd

View File

@ -1,15 +1,9 @@
# /etc/inittab
::sysinit:/etc/init.d/rcS
::once:/etc/init.d/containerd
::once:/etc/init.d/containers
::sysinit:/bin/rc.init
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
::ctrlaltdel:/bin/rc.shutdown reboot
# Stuff to do before rebooting
::shutdown:/usr/sbin/killall5 -15
::shutdown:/bin/sleep 5
::shutdown:/usr/sbin/killall5 -9
::shutdown:/bin/echo "Unmounting filesystems"
::shutdown:/bin/umount -a -r
# Stuff to do on shutdown
::shutdown:/bin/rc.shutdown poweroff