-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharchives.sh
executable file
·106 lines (84 loc) · 3.32 KB
/
archives.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# Description: Creates localized firmware archives
# License: GPLv3
# Requirements: /usr/bin/zip
# Variables ##################################################################
IMAGE_PATH="/home/michael/fflip-fw/firmware/images-stable"
ARCHIVE_PATH="/home/michael/fflip-fw/firmware/archives"
ERROR_LOG="/home/michael/fflip-fw/firmware/logs/error.log"
VERSION="1.5.0"
D1=( lip spz tst )
# Functions ##################################################################
usage()
{
cat << EOF
usage: $0 OPTIONS
Description: Creates localized firmware archives
OPTIONS:
-h Shows this help
-I <"String"> Sets the path where to look for the image binaries.
-A <"String"> Sets the path where to create the Zip-Archives.
-L <"String"> Sets the path for the error log.
-v <"String"> Sets version information.
EOF
}
# Main #######################################################################
if [ ! -x /usr/bin/zip ]; then
echo "\nERROR: Das Paket 'zip' ist nicht installiert.\n"
exit 1
fi
while getopts .hI:A:L:v:. OPTION
do
case $OPTION in
h)
usage
exit;;
I)
IMAGE_PATH="${OPTARG}"
;;
A)
ARCHIVE_PATH="${OPTARG}"
;;
L)
ERROR_LOG="${OPTARG}"
;;
v)
VERSION="${OPTARG}"
;;
?)
usage
exit;;
esac
done
if [ ! -d "${ARCHIVE_PATH}" ]; then
mkdir -p "${ARCHIVE_PATH}"
fi
for town in "${D1[@]}"
do
if [ -e "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip ]
then
/bin/rm "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip
fi
if [ -e "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip ]
then
/bin/rm "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip
fi
if [ ${town} = lip ]; then
/usr/bin/zip -j "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/factory/*.bin > /dev/null 2> "${ERROR_LOG}"
/usr/bin/zip -j "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/sysupgrade/*.bin > /dev/null 2> "${ERROR_LOG}"
fi
if [ ${town} = spz ]; then
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/factory/*.bin > /dev/null 2> "${ERROR_LOG}"
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/sysupgrade/*.bin > /dev/null 2> "${ERROR_LOG}"
fi
if [ ${town} = tst ]; then
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/factory/*.bin > /dev/null 2> "${ERROR_LOG}"
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/sysupgrade/*.bin > /dev/null 2> "${ERROR_LOG}"
fi
if [ ${town} = mon ]; then
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_factory_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/factory/*.bin > /dev/null 2> "${ERROR_LOG}"
/usr/bin/zip -P 1MsiWgsus -j "${ARCHIVE_PATH}/all_sysupgrade_images_${town}_${VERSION}".zip "${IMAGE_PATH}"/"${town}"/sysupgrade/*.bin > /dev/null 2> "${ERROR_LOG}"
fi
done
md5sum "${ARCHIVE_PATH}"/* > "${ARCHIVE_PATH}"/pruefsummen.md5
sed -i -r "s/ .*\/(.+)/ \1/g" "${ARCHIVE_PATH}"/pruefsummen.md5