Browse code

Initial commit

Benjamin Roth authored on26/11/2015 10:33:32
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,72 @@
1
+#!/bin/bash
2
+
3
+#+++++++++++++++++++++++++++++++++++++++++++++++++++
4
+# eSales Media Merger Script
5
+#
6
+# Author: Benjamin Roth
7
+# Version: 20151112
8
+#+++++++++++++++++++++++++++++++++++++++++++++++++++
9
+
10
+
11
+
12
+
13
+##########################
14
+#     CONFIG SECTION     #
15
+##########################
16
+SCRIPT=${BASH_SOURCE[o]}
17
+SCRIPTPATH=`dirname $SCRIPT`/
18
+EXPORTPATH=${SCRIPTPATH}csv/
19
+IMPORTPATH=${SCRIPTPATH}src/
20
+
21
+
22
+#############################
23
+#     UTILITY FUNCTIONS     #
24
+#############################
25
+function progress() {
26
+	echo -n " ..."
27
+	#ps ax | awk '{ print $1 }' | grep -w $$ > /dev/null
28
+	while true
29
+	do
30
+		echo -n "."
31
+		sleep 3
32
+	done
33
+}
34
+
35
+function run() {
36
+	srcfile=$1
37
+	destfile=$2
38
+	if [ -f ${IMPORTPATH}${srcfile} ]
39
+	then
40
+		echo -n "Merging file $srcfile..."
41
+		cat ${IMPORTPATH}${srcfile} >> ${EXPORTPATH}$destfile
42
+		if [ $? -ne 0 ]
43
+    then
44
+      echo "ERROR: Could not merge $srcfile into $destfile!"
45
+      exit $?
46
+    fi
47
+
48
+    rm ${IMPORTPATH}${srcfile}
49
+    if [ $? -ne 0 ]
50
+    then
51
+      echo "ERROR: Could not delete source file $srcfile!"
52
+      exit $?
53
+    fi
54
+
55
+    echo -n " done"
56
+    echo
57
+	else
58
+    echo -e "Source file $srcfile not found."
59
+	fi
60
+}
61
+
62
+
63
+###############
64
+#     RUN     #
65
+###############
66
+if [ $1 ] && [ $2 ]
67
+then
68
+	run $1 $2
69
+else
70
+	echo "ERROR: Wrong parameter count!"
71
+	echo "Run $0 \$srcfile \$destfile"
72
+fi