forked from 0k/0k-charms
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
921 B
38 lines
921 B
#!/bin/bash
|
|
|
|
exname=$(basename "$0")
|
|
usage="$exname [-h|--help] CONTAINER SIGNAL"
|
|
|
|
container=
|
|
signal=
|
|
while [ "$1" ]; do
|
|
case "$1" in
|
|
"--help"|"-h")
|
|
echo "$usage" >&2
|
|
exit 0
|
|
;;
|
|
*)
|
|
[ -z "$container" ] && { container=$1 ; shift ; continue ; }
|
|
[ -z "$signal" ] && { signal=$1 ; shift ; continue ; }
|
|
echo "Unexpected argument '$1'." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -z "$container" ]; then
|
|
echo "You must provide a container name/id as first argument." >&2
|
|
echo "$usage" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$signal" ]; then
|
|
echo "You must provide a signal to send to $container aargument." >&2
|
|
echo "$usage" >&2
|
|
exit 1
|
|
fi
|
|
|
|
container_id="$(docker inspect --format="{{ .Id }}" "$container")"
|
|
|
|
echo -e "POST /containers/$container_id/kill?signal=$signal HTTP/1.0\r\n" | nc -U /var/run/docker.sock
|