This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
forked from camptocamp/build-debian-cloud
-
Notifications
You must be signed in to change notification settings - Fork 43
/
gce
93 lines (80 loc) · 4.5 KB
/
gce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Google cloud info
gcs_dest=
gce_project=
# Image details
image_name_suffix=v$(date +%Y%m%d)
build_date=$(date +%Y-%m-%d)
volume_size='10'
apt_mirrors='http://gce_debian_mirror.storage.googleapis.com/ http://http.debian.net/debian'
backports_mirrors='http://gce_debian_mirror.storage.googleapis.com/ http://ftp.debian.org/debian'
use_backports_kernel=false
gce_kernel=projects/google/global/kernels/gce-v20130813
# $description is set later if it has no value yet. This is
# just for the help output.
default_description="Debian GNU/Linux X.Y.Z (codename) built on YYYY-MM-DD"
# List of options for gce subcommand
help="build-debian-cloud gce
This script creates a Debian Squeeze Amazon Machine Image.
Options (defaults in ${txtbld}bold${txtdef}):
${txtund}Bootstrapping${txtdef}
--arch ARCH [i386|amd64] Processor architecture of the image (${txtbld}${arch}${txtdef})
--codename C [squeeze|wheezy] Debian version codename to bootstrap (${txtbld}${codename}${txtdef})
--filesystem FS [ext2..4|xfs] Filesystem of the root volume (${txtbld}${filesystem}${txtdef})
--volume-size SIZE Default size of the root volume in GB (${txtbld}${volume_size}${txtdef})
--plugin FILE Path to plugin script.
Can be specified more than once.
--timezone ZONE Standard timezone (${txtbld}${timezone}${txtdef})
--locale LOCALE Standard locale (${txtbld}${locale}${txtdef})
--charmap CHARMAP Standard charmap (${txtbld}${charmap}${txtdef})
--name SUFFIX Image name suffix (${txtbld}${name_suffix}${txtdef})
--description DESC Description of the image (${txtbld}${default_description}${txtdef})
--apt-mirrors \"URL[ URL...]\" APT mirror URLs, space-separated (${txtbld}${apt_mirrors}${txtdef})
--backports-mirrors \"URL[ URL...]\" Backports APT mirror URLs, space-separated (${txtbld}${apt_mirrors}${txtdef})
--use-backports-kernel [true|false] True if backports kernel should be used (${txtbld}${apt_mirrors}${txtdef})
${txtund}GCE${txtdef}
--gcs-dest URL Google Cloud Storage image destination URL prefix (${txtbld}${gcs_dest}${txtdef})
--gce-project PROJECT Google Compute Engine image destination project (${txtbld}${gce_project}${txtdef})
--gce-kernel KERNEL Google Compute Engine image kernel (${txtbld}${gce_kernel}${txtdef})
${txtund}Other options${txtdef}
--debug Print debugging information
--help Prints this help message
"
# Run through the parameters and save them to variables.
while [ $# -gt 0 ]; do
case $1 in
--arch) arch=$2; shift 2 ;;
--codename) codename=$2; shift 2 ;;
--filesystem) filesystem=$2; shift 2 ;;
--volume-size) volume_size=$2; shift 2 ;;
--name) name_suffix=$2; shift 2 ;;
--description) description=$2; shift 2 ;;
--apt-mirrors) apt_mirrors=$2; shift 2 ;;
--backports-mirrors) backports_mirrors=$2; shift 2 ;;
--use-backports-kernel) use_backports_kernel=$2; shift 2 ;;
--gcs-dest) gcs_dest=$2; shift 2 ;;
--gce-project) gce_project=$2; shift 2 ;;
--gce-kernel) gce_kernel=$2; shift 2 ;;
--timezone) timezone=$2; shift 2 ;;
--locale) locale=$2; shift 2 ;;
--charmap) charmap=$2; shift 2 ;;
--plugin) plugins+=("$2"); shift 2 ;;
--debug) set -x; shift ;;
-h|--help) printf -- "$help"; exit 0 ;;
*) die "Unrecognized option: $1" \
"Type '$0 --help' to see a list of possible options"; ;;
esac
done
# Specify points in the bootstrapping process, which the plugins can latch onto.
# This way plugins don't need fixing if we rename files.
TASK_PACKAGES="01-packages"
TASK_CREATE_VOLUME="10-create-volume"
TASK_MOUNT_VOLUME="13-mount-volume"
TASK_BOOTSTRAP="14-bootstrap"
TASK_MOUNT_SPECIALS="15-mount-specials"
TASK_APT_SOURCES="21-apt-sources"
TASK_APT_UPGRADE="22-apt-upgrade"
TASK_UNMOUNT_SPECIALS="71-unmount-specials"
TASK_UNMOUNT_VOLUME="72-unmount-volume"
TASK_DELETE_VOLUME="73-delete-loopback"
TASK_REGISTER_IMAGE="95-register-image"