mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-05 23:34:31 +00:00
add ability to restart other containers in acme.sh container
easy to reload ssl certificate in other containers.
This commit is contained in:
parent
5c4d1ec035
commit
eb94fdd6f4
@ -63,6 +63,7 @@ RUN for verb in help \
|
||||
; done
|
||||
|
||||
COPY entry.sh /
|
||||
COPY restart-container.sh /usr/local/bin/
|
||||
|
||||
VOLUME /acme.sh
|
||||
|
||||
|
35
docker/restart-container.sh
Executable file
35
docker/restart-container.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Usage:
|
||||
# restart-container.sh <container_name_1> <container_name_2> <container_name_n...>
|
||||
#
|
||||
# The design idea was derived from docker.sh by acmesh-official
|
||||
#
|
||||
# https://github.com/acmesh-official/acme.sh/blob/5b8d7a3/deploy/docker.sh
|
||||
#
|
||||
|
||||
DOCKER_DAEMON_SOCKET="/var/run/docker.sock"
|
||||
|
||||
_get_container_id_by_name() {
|
||||
local container_name="$1"
|
||||
curl --silent --unix-socket "$DOCKER_DAEMON_SOCKET" -X GET "http://localhost/containers/json?filters=%7B%22name%22%3A%5B%22${container_name}%22%5D%7D" |
|
||||
tr '{,' '\n' |
|
||||
grep -i '"id":' |
|
||||
head -n 1 |
|
||||
cut -d '"' -f 4
|
||||
}
|
||||
|
||||
_restart_container_by_id() {
|
||||
local container_name="$1"
|
||||
local container_id="$(_get_container_id_by_name $container_name)"
|
||||
curl --silent --unix-socket "$DOCKER_DAEMON_SOCKET" -X POST http://localhost/containers/${container_id}/restart
|
||||
}
|
||||
|
||||
_restart_container_by_name() {
|
||||
local container_name="$1"
|
||||
curl --silent --unix-socket "$DOCKER_DAEMON_SOCKET" -X POST http://localhost/containers/${container_name}/restart
|
||||
}
|
||||
|
||||
for container_name in "$@"; do
|
||||
_restart_container_by_name "$container_name"
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user