Skip to content

Commit

Permalink
Introduce s6 init
Browse files Browse the repository at this point in the history
  • Loading branch information
hyvs committed Feb 16, 2024
1 parent 02b074e commit faff968
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
34 changes: 8 additions & 26 deletions lazy.ansible/.manala/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,6 @@

set -e

# Ssh agent bridge
if [ -n "${SSH_AUTH_SOCK}" ]; then
sh -c " \
while sleep 1; do \
rm -f /var/run/ssh-auth-bridge.sock ;
socat \
UNIX-LISTEN:/var/run/ssh-auth-bridge.sock,fork,mode=777 \
UNIX-CONNECT:/var/run/ssh-auth.sock ; \
done \
" &
fi

# Docker bridge
if [ -n "${DOCKER_HOST}" ]; then
sh -c " \
while sleep 1; do \
rm -f /var/run/docker-bridge.sock ;
socat -t 600 \
UNIX-LISTEN:/var/run/docker-bridge.sock,fork,mode=777 \
UNIX-CONNECT:/var/run/docker.sock ; \
done \
" &
fi

# As a consequence of running the container as root user,
# tty is not writable by sued user
if [ -t 1 ]; then
Expand All @@ -49,9 +25,15 @@ if [ -d ".manala/etc" ]; then
fi

# Services
if [ $# -eq 0 ] && [ -d "/etc/services.d" ]; then
exec s6-svscan /etc/services.d
## Docker bridge
if [ -n "${DOCKER_HOST}" ]; then
ln -s /etc/services.d/available/docker-bridge /etc/services.d/enabled/
fi
## Ssh agent bridge
if [ -n "${SSH_AUTH_SOCK}" ]; then
ln -s /etc/services.d/available/ssh-agent-bridge /etc/services.d/enabled/
fi
exec s6-svscan /etc/services.d/enabled &

# Command
exec gosu lazy "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec socat -d UNIX-LISTEN:/var/run/docker-bridge.sock,fork,unlink-early,mode=777 UNIX-CONNECT:/var/run/docker.sock
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec socat -d UNIX-LISTEN:/var/run/ssh-auth-bridge.sock,fork,unlink-early,mode=777 UNIX-CONNECT:/var/run/ssh-auth.sock
2 changes: 2 additions & 0 deletions lazy.ansible/.manala/etc/services.d/enabled/.s6-svscan/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0

0 comments on commit faff968

Please sign in to comment.