39 lines
875 B
Bash
Executable File
39 lines
875 B
Bash
Executable File
#!/bin/sh --
|
|
set -ue
|
|
|
|
NAME=i2psnark # container name
|
|
|
|
# host dirs
|
|
DIR="${XDG_DOWNLOAD_DIR:-${HOME}/Downloads}/i2psnark" # root dir
|
|
DL="${DIR}/dl" # downloads dir
|
|
CONF="${DIR}/i2psnark.config.d" # config dir
|
|
|
|
case "${1:-}" in
|
|
fg) set -- --rm ;;
|
|
bg) set -- --restart=always -d ;;
|
|
stop)
|
|
for action in stop rm; do
|
|
docker "${action}" "${NAME}"
|
|
done
|
|
exit
|
|
;;
|
|
*)
|
|
printf 1>&2 '%s\n' \
|
|
"Usage: ${0##*/} {fg,bg,stop}" \
|
|
' fg - run container in foreground' \
|
|
' bg - run container in background (auto restarts)' \
|
|
' stop - stop container runned in bg (and disable restarts)'
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
set -- "${@}" -it \
|
|
--net=host \
|
|
--name="${NAME}" \
|
|
-v "${DL}:/i2psnark/i2psnark" \
|
|
-v "${CONF}:/i2psnark/i2psnark.config.d" \
|
|
-e USER_ID="$(id -u "${USER:-$(whoami)}")" \
|
|
"${NAME}"
|
|
|
|
exec docker run "${@}"
|