forked from UbuntuBudgie/iso-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterraform.sh
More file actions
executable file
·103 lines (84 loc) · 2.22 KB
/
terraform.sh
File metadata and controls
executable file
·103 lines (84 loc) · 2.22 KB
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
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -e
CONFIG_PATH="etc/terraform.conf"
# Call getopt to validate the provided input.
options=$(getopt -o '' -l 'config-path:' -- "$@")
[ $? -eq 0 ] || {
echo "Incorrect options provided"
exit 1
}
eval set -- "$options"
while true; do
case "$1" in
--config-path)
shift; # The arg is next in position args
CONFIG_PATH=$1
;;
--)
shift
break
;;
esac
shift
done
check_permissions () {
if [[ "$(id -u)" != 0 ]]; then
echo "E: Requires root permissions" > /dev/stderr
exit 1
fi
}
check_dependencies () {
PACKAGES="live-build"
for PACKAGE in $PACKAGES; do
dpkg -L "$PACKAGE" >/dev/null 2>&1 || MISSING_PACKAGES="$MISSING_PACKAGES $PACKAGE"
done
if [[ "$MISSING_PACKAGES" != "" ]]; then
echo "E: Missing dependencies! Please install the following packages: $MISSING_PACKAGES" > /dev/stderr
exit 1
fi
}
read_config () {
BASE_DIR="$PWD"
source "$BASE_DIR"/"$CONFIG_PATH"
}
build () {
BUILD_ARCH="$1"
mkdir -p "$BASE_DIR/tmp/$BUILD_ARCH"
cd "$BASE_DIR/tmp/$BUILD_ARCH" || exit
# remove old configs and copy over new
rm -rf config auto
cp -r "$BASE_DIR"/etc/* .
# Make sure conffile specified as arg has correct name
cp -f "$BASE_DIR"/"$CONFIG_PATH" terraform.conf
# Symlink chosen package lists to where live-build will find them
ln -s "package-lists.$PACKAGE_LISTS_SUFFIX" "config/package-lists"
echo -e "
#------------------#
# LIVE-BUILD CLEAN #
#------------------#
"
lb clean
echo -e "
#-------------------#
# LIVE-BUILD CONFIG #
#-------------------#
"
lb config
echo -e "
#------------------#
# LIVE-BUILD BUILD #
#------------------#
"
lb build
YYYYMMDD="$(date +%Y%m%d)"
OUTPUT_DIR="$BASE_DIR/builds/$BUILD_ARCH"
mkdir -p "$OUTPUT_DIR"
FNAME="cinnamonremix-$VERSION-$CHANNEL.$YYYYMMDD$OUTPUT_SUFFIX"
mv "$BASE_DIR/tmp/$BUILD_ARCH/live-image-$BUILD_ARCH.hybrid.iso" "$OUTPUT_DIR/${FNAME}.iso"
md5sum "$OUTPUT_DIR/${FNAME}.iso" > "$OUTPUT_DIR/${FNAME}.md5.txt"
sha256sum "$OUTPUT_DIR/${FNAME}.iso" > "$OUTPUT_DIR/${FNAME}.sha256.txt"
}
check_permissions
check_dependencies
read_config
build "$ARCH"