Browse code

Protect the release.sh script against accidental use. Infer VERSION automatically.

Jérôme Petazzoni authored on 2013/08/10 10:08:06
Showing 2 changed files
... ...
@@ -21,7 +21,7 @@ run	apt-get install -y -q reprepro
21 21
 # Install s3cmd 1.0.1 (earlier versions don't support env variables in the config)
22 22
 run	apt-get install -y -q python-pip
23 23
 run	pip install s3cmd
24
-run	/bin/echo -e '[default]\naccess_key=$AWS_ID\nsecret_key=$AWS_KEY\n' > /.s3cfg
24
+run	/bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY\n' > /.s3cfg
25 25
 # Download dependencies
26 26
 run	PKG=github.com/kr/pty REV=27435c699;		 git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
27 27
 run	PKG=github.com/gorilla/context/ REV=708054d61e5; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
... ...
@@ -14,15 +14,33 @@ set -e
14 14
 
15 15
 # Print a usage message and exit.
16 16
 usage() {
17
-	echo "Usage: $0 VERSION BUCKET"
18
-	echo "For example: $0 0.5.1-dev sandbox.get.docker.io"
17
+	cat <<EOF
18
+To run, I need:
19
+- to be in a container generated by the Dockerfile at the top of the Docker
20
+  repository;
21
+- to be provided with the name of an S3 bucket, in environment variable
22
+  AWS_S3_BUCKET;
23
+- to be provided with AWS credentials for this S3 bucket, in environment
24
+  variables AWS_ACCESS_KEY and AWS_SECRET_KEY;
25
+- a generous amount of good will and nice manners.
26
+The canonical way to run me is to run the image produced by the Dockerfile: e.g.:"
27
+
28
+docker run -e AWS_S3_BUCKET=get-staging.docker.io \\
29
+              AWS_ACCESS_KEY=AKI1234... \\
30
+              AWS_SECRET_KEY=sEs3mE... \\
31
+              f0058411
32
+EOF
19 33
 	exit 1
20 34
 }
21 35
 
22
-VERSION=$1
23
-BUCKET=$2
24
-[ -z "$VERSION" ] && usage
25
-[ -z "$BUCKET" ] && usage
36
+[ "$AWS_S3_BUCKET" ] || usage
37
+[ "$AWS_ACCESS_KEY" ] || usage
38
+[ "$AWS_SECRET_KEY" ] || usage
39
+[ -d /go/src/github.com/dotcloud/docker/ ] || usage
40
+cd /go/src/github.com/dotcloud/docker/ 
41
+
42
+VERSION=$(cat VERSION)
43
+BUCKET=s3://$AWS_S3_BUCKET
26 44
 
27 45
 setup_s3() {
28 46
 	# Try creating the bucket. Ignore errors (it might already exist).