github.com/nguyentm83/docker@v1.5.0/contrib/host-integration/manager.sh (about)

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