-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild-rootfs.sh
More file actions
executable file
·50 lines (41 loc) · 885 Bytes
/
build-rootfs.sh
File metadata and controls
executable file
·50 lines (41 loc) · 885 Bytes
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
#!/bin/bash
set -e
# Check if root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
SCRIPT_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
RPATH="$SCRIPT_DIR/rootfs.ext4"
usage() {
echo "\
Usage: $0 [-t]
-s don't generate a sparse file
"
}
SPARSE=1 # 1 if creating sparse file, 0 if not
while getopts "h?s" opt; do
case "$opt" in
h|\?)
usage
exit 0
;;
s)
echo "Disabled sparse file creation."
SPARSE=0
shift
;;
esac
done
# Check if valid parameter
if [[ ! -d "$SCRIPT_DIR/type-$1" ]]; then
types=`ls -d1 ./type* | cut -d'-' -f2`
echo -e "$1 is not a rootfs type. Try one of:\n$types"
fi
# Clean up old files
if [[ -f "$RPATH" ]]; then
rm -rf "$RPATH"
fi
export SPARSE="$SPARSE"
"type-$1/init-rootfs.sh" "$RPATH"
"type-$1/run-container.sh" "$RPATH"