-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
43 lines (38 loc) · 1013 Bytes
/
entrypoint.sh
File metadata and controls
43 lines (38 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
log_info() {
echo "[ $(date '+%Y-%m-%d %H:%M:%S') ] [INFO] $1"
}
INIT="/var/init"
SSHD_PID=""
handle_stop() {
log_info "Container stop requested. Stopping SSH server..."
if [ -n "$SSHD_PID" ] && kill -0 "$SSHD_PID" 2>/dev/null; then
kill "$SSHD_PID"
wait "$SSHD_PID"
log_info "SSH server stopped. Container will now exit."
fi
exit 0
}
trap handle_stop SIGTERM SIGINT
if [ ! -e $INIT ]; then
touch $INIT
log_info "Verify SSH Server"
ssh-keygen -A
log_info "Add Docker socket permissions"
chmod 666 /var/run/docker.sock
chgrp docker /var/run/docker.sock
log_info "Start SSH Server"
/usr/sbin/sshd -D &
SSHD_PID=$!
wait $SSHD_PID
log_info "Stopped SSH Server"
else
log_info "Add Docker socket permissions"
chmod 666 /var/run/docker.sock
chgrp docker /var/run/docker.sock
log_info "Start SSH Server"
/usr/sbin/sshd -D &
SSHD_PID=$!
wait $SSHD_PID
log_info "Stopped SSH Server"
fi