~canonical-server/+junk/serverstack

« back to all changes in this revision

Viewing changes to admin/images/sstack-mirror

  • Committer: Scott Moser
  • Date: 2014-12-12 17:46:18 UTC
  • Revision ID: smoser@ubuntu.com-20141212174618-gbr6il5db3dl9klt
sstack-mirror: sync with 'cstack-mirror' / update for sstream-mirror-glance

this syncs with cstack-mirror from lp:~smoser/simplestreams/example-sync .
just to keep the changes more obvious if there were additional changes
to be made in the future.

the big adjustment is in how sstream-mirror-glance takes 'filter' options
now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
 
3
3
set -x
 
4
set -f
4
5
 
5
6
CLOUDNAME="serverstack"
6
7
SWIFT_PATH="simplestreams/data/" # production: simplestreams/data/
9
10
XPRE="" # production: set this to empty string for real
10
11
MAX_DAILY=10
11
12
MAX_RELEASED=10
 
13
HOOK_COMMAND="" # set this to full path to a command to run
 
14
#HOOK_COMMAND="$(dirname $0)/image-modify"
 
15
 
 
16
FILTERS="release~(precise|trusty|utopic|vivid|devel) arch~(x86_64|amd64)"
12
17
 
13
18
[ "${TENV_SETUP:-0}" != "0" -o "${NO_TENV:-0}" != "0" ] || {
14
19
   echo "expecting to be run from tenv (simplestreams/tools/tenv)";
22
27
} 1>&2
23
28
 
24
29
gmirror() {
25
 
   local namepre="$1" cid="$2" url="$3" path=${4}
 
30
   local namepre="$1" cid="$2" url="$3"
 
31
   shift 3
 
32
   [ "${MAX}" = "0" ] &&
 
33
      { echo "skipping ${namepre}, MAX=0" 1>&2; return 0; }
26
34
   sstream-mirror-glance -vv \
27
35
      ${MAX:+--max=${MAX}} ${REGION:+"--region=${REGION}"} \
28
36
      "--cloud-name=${CLOUDNAME}" "--output-swift=${SWIFT_PATH}" \
29
37
      "--name-prefix=${XPRE}${namepre%/}/" "--content-id=${CID_COMMON}:$cid" \
30
 
      "--item-filter=arch=amd64" "--item-filter=release~(precise|trusty|utopic|vivid|devel)" \
31
 
      "--item-filter=ftype~(disk1.img|disk.img)" --progress --keep \
32
 
      "${url}" ${path:+"${path}"}
 
38
      ${HOOK_COMMAND:+"--modify-hook=${HOOK_COMMAND}"} \
 
39
      "${url}" $FILTERS "$@"
33
40
}
34
41
fail() { [ $# -eq 0 ] || echo "$@" 1>&2; exit 2; }
35
42
 
36
43
## with cirros data
37
44
## add cirros signing key
38
 
# gpg-import-pubkey examples/keys/cirros.pub
 
45
# gpg-trust-pubkey ./simplestreams/examples/keys/cirros.pub
39
46
## get a local mirror (for quicker iterating)
40
 
# do-mirror -vv http://download.cirros-cloud.net/ ./cirros-mirror
41
 
#MAX=2; gmirror "cirros/" "cirros" ./cirros-mirror/
 
47
# sstream-mirror --progress --max=2 \
 
48
#    http://download.cirros-cloud.net/ ./cirros-mirror \
 
49
#    arch=x86_64 ftype=disk.img
 
50
#MAX=2; gmirror "cirros/" "cirros" ./cirros-mirror/ arch=x86_64 ftype=disk.img
42
51
 
43
52
## released
44
 
export MAX=${MAX_RELEASED};
 
53
MAX=${MAX_RELEASED};
45
54
gmirror "ubuntu-released/" "ubuntu:released" \
46
55
    http://cloud-images.ubuntu.com/releases/ ||
47
56
    fail "failed gmirror for ubuntu-released"
48
57
 
49
 
# daily
50
 
export MAX=${MAX_DAILY};
 
58
## daily
 
59
MAX=${MAX_DAILY};
51
60
gmirror "ubuntu-daily/" "ubuntu:daily" \
52
61
    http://cloud-images.ubuntu.com/daily/ ||
53
62
    fail "failed gmirror for ubuntu-daily"
54
63
 
55
 
# snappy
56
 
export MAX=${MAX_DAILY};
 
64
## ubuntu-core/devel (snappy)
 
65
MAX=2
57
66
gmirror "ubuntu-core/devel/" "ubuntu:core:devel" \
58
 
     http://cloud-images.ubuntu.com/snappy/ ||
59
 
     fail "failed gmirror for ubuntu-snappy"
 
67
    http://cloud-images.ubuntu.com/snappy/ ||
 
68
    fail "failed gmirror for ubuntu-snappy"