manager.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. set -e
  3. usage() {
  4. echo >&2 "usage: $0 [-a author] [-d description] container [manager]"
  5. echo >&2 " ie: $0 -a 'John Smith' 4ec9612a37cd systemd"
  6. echo >&2 " ie: $0 -d 'Super Cool System' 4ec9612a37cd # defaults to upstart"
  7. exit 1
  8. }
  9. auth='<none>'
  10. desc='<none>'
  11. have_auth=
  12. have_desc=
  13. while getopts a:d: opt; do
  14. case "$opt" in
  15. a)
  16. auth="$OPTARG"
  17. have_auth=1
  18. ;;
  19. d)
  20. desc="$OPTARG"
  21. have_desc=1
  22. ;;
  23. esac
  24. done
  25. shift $(($OPTIND - 1))
  26. [ $# -ge 1 -a $# -le 2 ] || usage
  27. cid="$1"
  28. script="${2:-upstart}"
  29. if [ ! -e "manager/$script" ]; then
  30. echo >&2 "Error: manager type '$script' is unknown (PRs always welcome!)."
  31. echo >&2 'The currently supported types are:'
  32. echo >&2 " $(cd manager && echo *)"
  33. exit 1
  34. fi
  35. # TODO https://github.com/docker/docker/issues/734 (docker inspect formatting)
  36. #if command -v docker > /dev/null 2>&1; then
  37. # image="$(docker inspect -f '{{.Image}}' "$cid")"
  38. # if [ "$image" ]; then
  39. # if [ -z "$have_auth" ]; then
  40. # auth="$(docker inspect -f '{{.Author}}' "$image")"
  41. # fi
  42. # if [ -z "$have_desc" ]; then
  43. # desc="$(docker inspect -f '{{.Comment}}' "$image")"
  44. # fi
  45. # fi
  46. #fi
  47. exec "manager/$script" "$cid" "$auth" "$desc"