add helper script

master
dm9pZCAq 2021-12-29 21:23:28 +02:00
parent 0e4a4eaab9
commit 3215010e7a
1 changed files with 38 additions and 0 deletions

38
i2psnark.sh 100755
View File

@ -0,0 +1,38 @@
#!/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 "${@}"