summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-unpack_tar_gz.inc
blob: a5c88524421e8313d8d34046dafb1f2eb223e636 (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
unpack_tar_gz() {
	local dir
	echo
	echo -n "# Unpacking given tar file $1, using extra options $2 ..."
	# Check whether the given directory (via -C) exists; if not mkdir it:
	if [ "${2:0:2}" == "-C" ]; then
		dir="${2:3}"
		if [ "${dir:0:1}" != '/' ]; then
			echo -n " (Warning: Path $dir has no preceding slash - not an absolute path!) "
		fi
		[ ! -d "$dir" ] && mkdir -p "$dir"	# well, mkdir it.
	fi

	tar xzf "$1" $2
	ERR=$?
	if [ "$ERR" -ne 0 ]; then
		echo
		echo "# Could not unpack tar file $1!"
		# Fehlerbehandlung?
	else
		echo "ok."
	fi
}