forked from Lknechtli/BetterCombatEvolved
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackageMod.sh
67 lines (58 loc) · 1.23 KB
/
packageMod.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
scriptsOnly=false
while getopts ":m:r:b:s" opt; do
case $opt in
m)
modPath=$OPTARG
;;
r)
refPath=$OPTARG
;;
b)
batPath=$OPTARG
;;
s)
scriptsOnly=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
tmpPath="./temp"
#modPath must have a 'content' directory in its first level
echo "Working directory is $modPath (should have content folder one level down"
echo "Reference directory is $refPath. Should include content>scripts as well"
echo "Batch file to repack xml and move scripts is $batPath"
#TODO if temp already exists, abort
if test -e $tmpPath ; then
exit
fi
if $scriptsOnly ; then
echo "Only checking scripts"
modPath="$modPath/content/scripts"
refPath="$refPath/content/scripts"
tmpPath="./temp/content/scripts"
fi
for f in $(find $modPath/*);
do
if [[ -f $f ]]; then
#get file from reference
ref="${f/$modPath/$refPath}"
if ! cmp --silent $ref $f ; then
echo "$f changed!"
dest="${f/$modPath/$tmpPath}"
mkdir -p $(dirname $dest)
cp $f $dest
fi
fi
done
eval "$batPath"
read -p "After packing is complete, press enter to delete temp files!"
#TODO delete temp
rm -r "./temp"