summaryrefslogtreecommitdiff
path: root/functions/stagefile.sh
blob: 23c3a3429f479593a2d64692064d6e3430a49f1c (plain)
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
#!/bin/sh

# stagefile.sh - handle stage files

set -e

Check_stagefile ()
{
	STAGEFILE="${1}"
	STAGENAME="`basename ${1}`"

	# Checking stage file
	if [ -f "${STAGEFILE}" ]
	then
		echo "W: skipping ${STAGENAME}"
		exit 0
	fi
}

Create_stagefile ()
{
	STAGEFILE="${1}"
	STAGEDIRECTORY="`dirname ${1}`"

	# Creating stage directory
	if [ ! -d "${STAGEDIRECTORY}" ]
	then
		mkdir -p "${STAGEDIRECTORY}"
	fi

	# Creating stage file
	touch "${STAGEFILE}"
}

Require_stagefile ()
{
	STAGEFILE="${1}"
	STAGENAME="`basename ${1}`"

	# Checking stage file
	if [ ! -f "${STAGEFILE}" ]
	then
		echo "E: ${STAGENAME} missing"
		exit 1
	fi
}