summaryrefslogtreecommitdiffstats
path: root/packager/openslx
blob: a71a1db6332363eb469ee5fe5b47d43953727c33 (plain) (blame)
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
#!/bin/bash
# ------------------------------------------------------------------------------
#
#                        OpenSLX Toolkit Next Gen
#
# ------------------------------------------------------------------------------
#
# The next generation toolkit to build a stateless linux system bootable
# over the network. Composed of dracut-built initramfs and a full system clone.
#
# ------------------------------------------------------------------------------
#
#                           OpenSLX-NG Main Code
#
# ------------------------------------------------------------------------------

declare -rg ARG0="$0"
declare -rg SELF="$(readlink -f "$ARG0")"
declare -rg ROOT_DIR="$(dirname "${SELF}")"
declare -rg SELF_PID="$$"

# let's keep it simple for now, just source our config/functions file
. "${ROOT_DIR}/$ARG0".functions || perror "Could not source functions."
. "${ROOT_DIR}/$ARG0".config || perror "Could not source config."

# root check
if [ "$(id -u)" -ne 0 ]; then
	perror "ERROR: You need to be root to use this toolkit."
else
	banner
fi

# do we even have tools?
for TOOL in qemu-img qemu-nbd mkfs.ext4; do
	which $TOOL &>/dev/null || perror "Could not find '$TOOL'."
done


read_params $@
if [ "x$ACTION" == "xCLONE" ]; then
	clone_stage4 || perror "Cloning stage4 failed with: $?"
elif [ "x$ACTION" == "xPACKAGE" ]; then
	pack_qcow2 || perror "Packing as QCoW2 failed with: $?"
else
	pwarning "No action given."
	print_usage
fi