-
Notifications
You must be signed in to change notification settings - Fork 2
/
lxc-create-base__8_jessie.sh
74 lines (64 loc) · 2.33 KB
/
lxc-create-base__8_jessie.sh
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
#!/bin/bash
# exit immediately on any error
set -e
usage_exit() {
echo
echo "Usage:"
echo
echo " $0 container_name /path/to/ssh_pubkey_or_authorized_keys"
echo
exit "$1"
}
SCRIPTS_DIR="$(dirname "$0")/lxc-create.d"
echo -e "\\n>>>>>> Processing scripts in [${SCRIPTS_DIR}/]..."
for INC in "${SCRIPTS_DIR}"/[0-9][0-9]_*\.inc\.sh ; do
echo -e "\\n>>> Sourcing [$INC]"
source "$INC"
done
echo -e "\\n>>>>>> Finished processing scripts in [${SCRIPTS_DIR}/].\\n"
#############################################################
# LXC base setup
#############################################################
echo
echo ------------------------ settings ------------------------
echo SUITE="$SUITE"
echo VM_HOSTNAME="$VM_HOSTNAME"
echo TGT_ROOT="$TGT_ROOT"
echo TGT_LOCALE="$TGT_LOCALE"
echo BRIDGE_IP="$BRIDGE_IP"
echo -------------------- lxc-create command ------------------
echo lxc-create --lxcpath="$BASEDIR" --name="$VM_HOSTNAME" -t "$DISTRIBUTION" -- --release="$SUITE"
echo
if [ -n "$DRY_RUN" ] ; then
echo ">>> dry-run requested, stopping here! <<<"
exit 0
fi
lxc-create --lxcpath="$BASEDIR" --name="$VM_HOSTNAME" -t "$DISTRIBUTION" -- --release="$SUITE"
# set EATMYDATA to empty, will be overridden in one of the sourced scripts if enabled:
EATMYDATA=""
# read distribution-specific default settings:
source "$(dirname "$0")/debian_defaults.inc.sh"
# run (source) post-create scripts:
SCRIPTS_DIR="$(dirname "$0")/lxc-post-create.d"
echo -e "\\n>>>>>> Processing post-create scripts in [${SCRIPTS_DIR}/]..."
for INC in "${SCRIPTS_DIR}"/[0-9][0-9]_*\.inc\.sh ; do
echo -e "\\n>>> Sourcing [$INC]"
source "$INC"
done
echo -e "\\n>>>>>> Finished processing post-create scripts in [${SCRIPTS_DIR}/].\\n"
#############################################################
# prepare finalization scripts to be run after startup
#############################################################
FINALIZE_D="$(dirname "$0")/finalize.d"
if [ -d "$FINALIZE_D" ] ; then
SETUP_SCRIPTS="$TGT_ROOT"/root/lxc-finalize-setup
mkdir -v "$SETUP_SCRIPTS"
cp -vL "$FINALIZE_D"/* "$SETUP_SCRIPTS"/
echo "Scripts to finalize the LXC container setup have been placed here:"
echo " > $SETUP_SCRIPTS"
echo
echo "Log in as user 'root', then just launch:"
echo
echo " # bash $SETUP_SCRIPTS/do_finalize_setup.sh"
echo
fi