Revision dcd7b382

b/common.sh.in
147 147

  
148 148
# only if the user want to specify a mirror in the defaults file we
149 149
# will use it, this declaration is to make sure the variable is set
150
: ${MIRROR:=""}
151
: ${PROXY:=""}
152
: ${SUITE:="lenny"}
150
: ${BARE:="no"}
151
: ${IMAGE:=""}
153 152
: ${ARCH:=""}
154
: ${EXTRA_PKGS:=""}
155 153
: ${CUSTOMIZE_DIR:="@sysconfdir@/ganeti/instance-debootstrap.d"}
156 154
: ${VARIANTS_DIR:="@sysconfdir@/ganeti/instance-debootstrap/variants"}
157
: ${GENERATE_CACHE:="yes"}
158
: ${CLEAN_CACHE:="14"} # number of days to keep a cache file
159 155
if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
160 156
  DEFAULT_PARTITION_STYLE="none"
161 157
else
......
163 159
fi
164 160
: ${PARTITION_STYLE:=$DEFAULT_PARTITION_STYLE} # disk partition style
165 161

  
166
CACHE_DIR="@localstatedir@/cache/ganeti-instance-debootstrap"
167

  
168 162
SCRIPT_NAME=$(basename $0)
169 163

  
170 164
if [ -f /sbin/blkid -a -x /sbin/blkid ]; then
b/create
21 21

  
22 22
. common.sh
23 23

  
24
if [ "$GENERATE_CACHE" = "yes" -a ! -d "$CACHE_DIR" ]; then
25
  $MKDIR "$CACHE_DIR"
26
fi
27

  
28 24
DPKG_ARCH=${ARCH:-`dpkg --print-architecture`}
29
CACHE_FILE="$CACHE_DIR/cache-${SUITE}-${DPKG_ARCH}.tar"
30 25

  
31 26
# If the target device is not a real block device we'll first losetup it.
32 27
# This is needed for file disks.
......
62 57
mount $filesystem_dev $TMPDIR
63 58
CLEANUP+=("umount $TMPDIR")
64 59

  
65
# remove the cache file if it's old (> 2 weeks) and writable by the owner (the
66
# default due to the standard umask)
67
if [ "$CLEAN_CACHE" -a -d "$CACHE_DIR" ]; then
68
  find "$CACHE_DIR" -name 'cache-*.tar' -type f \
69
    -daystart -mtime "+${CLEAN_CACHE}" -print0 | \
70
    xargs -r0 rm -f
71
fi
72

  
73
if [ -f "$CACHE_FILE" ]; then
74
  tar xf "$CACHE_FILE" -C $TMPDIR
75
else
76
  if [ "$PROXY" ]; then
77
    export http_proxy="$PROXY"
78
  fi
79
  # INCLUDE will be empty if EXTRA_PKGS is null/empty, otherwise we
80
  # build the full parameter format from it
81
  INCLUDE=${EXTRA_PKGS:+"--include=$EXTRA_PKGS"}
82
  debootstrap \
83
    --arch "$DPKG_ARCH" \
84
    $INCLUDE \
85
    "$SUITE" $TMPDIR $MIRROR
86

  
87
  # remove the downloaded debs, as they are no longer needed
88
  find "$TMPDIR/var/cache/apt/archives" -type f -name '*.deb' -print0 | \
89
    xargs -r0 rm -f
90

  
91
  # remove the persistent-net rules, otherwise it will remember the node's
92
  # interfaces as eth0, eth1, ...
93
  rm -f "$TMPDIR/etc/udev/rules.d/z25_persistent-net.rules"
94

  
95
  if [ "$GENERATE_CACHE" = "yes" ]; then
96
    TMP_CACHE=`mktemp "${CACHE_FILE}.XXXXXX"`
97
    tar cf "$TMP_CACHE" -C $TMPDIR .
98
    mv -f "$TMP_CACHE" "$CACHE_FILE"
99
  fi
100
fi
101

  
102 60
cp -p /etc/hosts $TMPDIR/etc/hosts
103 61
cp -p /etc/resolv.conf $TMPDIR/etc/resolv.conf
104 62
echo $instance > $TMPDIR/etc/hostname
b/defaults
42 42
# By default /etc/ganeti/instance-debootstrap.d
43 43
# CUSTOMIZE_DIR="/etc/ganeti/instance-debootstrap.d"
44 44

  
45
# GENERATE_CACHE: if set to yes (the default), create new cache files;
46
# any other value will disable the generation of cache files (but they
47
# will still be used if they exist)
48
GENERATE_CACHE="yes"
49

  
50
# CLEAN_CACHE: should be set to the number of days after which to
51
# clean the cache; the default is 14 (two weeks); to disable cache
52
# cleaning, set it to an empty value ("")
53
CLEAN_CACHE="14"
54

  
55 45
# PARTITION_STYLE: whether and how the target device should be partitioned.
56 46
# Allowed values:
57 47
# 'none': just format the device, but don't partition it

Also available in: Unified diff