-
Notifications
You must be signed in to change notification settings - Fork 1
/
datapack-archive.sh
executable file
·85 lines (85 loc) · 5.31 KB
/
datapack-archive.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#--posix:information leak, -H ustar no and leak and better compression
RANDOMNUMBERTOKEN=`/usr/bin/openssl rand -hex 14`
find datapack/ -type d -exec chmod 700 "{}" \;
find datapack/ -type f -exec chmod 600 "{}" \;
find datapack/ -type f -print | grep -F -v 'datapack/pack/' | grep -F -v 'map/main/' | grep -F -v '.git' | grep -F -v '.xcf' | sort > /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
tar --owner=0 --group=0 --mtime='2010-01-01' -H ustar -c -f - -T /tmp/temporary_file_list${RANDOMNUMBERTOKEN} > /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}
rm /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
mkdir -p /tmp/datapack/pack/
if [ ! -e /tmp/datapack-new.tar${RANDOMNUMBERTOKEN} ] || [ "`sha256sum /tmp/datapack-new.tar${RANDOMNUMBERTOKEN} | awk '{print $1}'`" != "`sha256sum /tmp/datapack.tar | awk '{print $1}'`" ]
then
echo 'regen datapack'
cat /tmp/datapack-new.tar${RANDOMNUMBERTOKEN} | /usr/bin/zstd -22 --ultra > /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}.zst
if [ $? -eq 0 ]
then
mv /tmp/datapack-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack.tar
/usr/bin/zstd --test /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}.zst > /dev/null 2>&1
if [ $? -eq 0 ]
then
mv /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}.zst /tmp/datapack.tar.zst
else
rm /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}.zst
fi
else
mv /tmp/datapack-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack.tar
fi
else
echo 'already ok datapack'
rm /tmp/datapack-new.tar${RANDOMNUMBERTOKEN}
fi
PATHB=`pwd`
for main in $(ls ${PATHB}/datapack/map/main); do
cd ${PATHB}/datapack/map/main/
find ${main}/ -type f -print | grep -F -v 'sub/' | grep -F -v '.git' | grep -F -v '.xcf' | sort > /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
tar --owner=0 --group=0 --mtime='2010-01-01' -H ustar -c -f - -T /tmp/temporary_file_list${RANDOMNUMBERTOKEN} > /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}
rm /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
if [ ! -e /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN} ] || [ "`sha256sum /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN} | awk '{print $1}'`" != "`sha256sum /tmp/datapack-main-${main}.tar | awk '{print $1}'`" ]
then
echo 'regen datapack main' ${main}
cat /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN} | /usr/bin/zstd -22 --ultra > /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}.zst
if [ $? -eq 0 ]
then
mv /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack-main-${main}.tar
/usr/bin/zstd --test /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}.zst > /dev/null 2>&1
if [ $? -eq 0 ]
then
mv /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}.zst /tmp/datapack-main-${main}.tar.zst
else
rm /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}.zst
fi
else
mv /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack-main-${main}.tar
fi
else
echo 'already ok datapack main' ${main}
rm /tmp/datapack-main-${main}-new.tar${RANDOMNUMBERTOKEN}
fi
for sub in $(ls ${PATHB}/datapack/map/main/${main}/sub/); do
cd ${PATHB}/datapack/map/main/${main}/sub/
find ${sub}/ -type f -print | grep -F -v '.git' | grep -F -v '.xcf' | sort > /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
tar --owner=0 --group=0 --mtime='2010-01-01' -H ustar -c -f - -T /tmp/temporary_file_list${RANDOMNUMBERTOKEN} > /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}
rm /tmp/temporary_file_list${RANDOMNUMBERTOKEN}
if [ ! -e /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN} ] || [ "`sha256sum /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN} | awk '{print $1}'`" != "`sha256sum /tmp/datapack-sub-${main}-${sub}.tar | awk '{print $1}'`" ]
then
echo 'regen datapack sub' ${main} ${sub}
cat /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN} | /usr/bin/zstd --rm -22 --ultra > /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}.zst
if [ $? -eq 0 ]
then
mv /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack-sub-${main}-${sub}.tar
/usr/bin/zstd --test /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}.zst > /dev/null 2>&1
if [ $? -eq 0 ]
then
mv /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}.zst /tmp/datapack-sub-${main}-${sub}.tar.zst
else
rm /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}.zst
fi
else
mv /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN} /tmp/datapack-sub-${main}-${sub}.tar
fi
else
echo 'already ok datapack sub' ${main} ${sub}
rm /tmp/datapack-sub-${main}-${sub}-new.tar${RANDOMNUMBERTOKEN}
fi
done
done