summaryrefslogtreecommitdiff
path: root/functions/stagefile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'functions/stagefile.sh')
-rwxr-xr-xfunctions/stagefile.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/functions/stagefile.sh b/functions/stagefile.sh
new file mode 100755
index 0000000..23c3a34
--- /dev/null
+++ b/functions/stagefile.sh
@@ -0,0 +1,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
+}