-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtecff-firmware-distribution
executable file
·75 lines (72 loc) · 2.46 KB
/
tecff-firmware-distribution
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
#!/bin/bash
# this script copies gluon firmware images to their public distribution points
# dependencies: rsync
SRVSSH="host03.tecff.de"
SRVSSH_USR="root"
SRVSSH_PATH="/var/www/html/fw"
SRVSSH_DIR="v12"
if [ ! -x "$(which rsync)" ]; then
echo "one of the dependencies is missing!"
exit 1
fi
if [ ! "$#" -eq 1 ] || [ ! -d "$1" ]; then
echo "please specify the source directory as the first parameter"
exit 1
fi
SRC="$1"
if [[ "$SRC" =~ ^.+experimental.+$ ]]; then
BRANCH="experimental"
elif [[ "$SRC" =~ ^.+beta.+$ ]]; then
BRANCH="beta"
elif [[ "$SRC" =~ ^.+stable.+$ ]]; then
BRANCH="stable"
fi
if [ -z "$BRANCH" ]; then
echo "the source directory doesn't seem to be correct, it has to contain either experimental, beta or stable"
exit 1
fi
if [ ! -d "$SRC/packages" ] || [ ! -d "$SRC/images/factory" ] || [ ! -d "$SRC/images/sysupgrade" ]; then
echo "couldn't find at least one of the necessary directories: packages, images/factory, images/sysupgrade"
exit 1
fi
MANIFEST="$SRC/images/sysupgrade/${BRANCH}.manifest"
if [ ! -f "$MANIFEST" ]; then
echo "manifest missing: $MANIFEST"
exit 1
fi
SIGCOUNT="$(sed -e '1,/^---/d' $MANIFEST | wc -l)"
if ([ "$BRANCH" == "experimental" ] && [ "$SIGCOUNT" -lt 1 ]) || \
([ "$BRANCH" == "beta" ] && [ "$SIGCOUNT" -lt 2 ]) || \
([ "$BRANCH" == "stable" ] && [ "$SIGCOUNT" -lt 3 ]); then
echo "can't find enough signatures on the manifest file: $MANIFEST"
exit 1
fi
echo "copy will be done to: $SRVSSH_USR@$SRVSSH:/$SRVSSH_PATH/$SRVSSH_DIR/$BRANCH/"
echo "are you sure you backed up the old $BRANCH firmware on the update servers?"
echo "it will be overwritten if you dont interrupt now!"
sleep 5
# ssh copy
echo "starting ssh copy... (needs ssh agent redirection)"
rsync -rltv --delete $SRC/images/factory/ $SRVSSH_USR@$SRVSSH:/$SRVSSH_PATH/$SRVSSH_DIR/$BRANCH/factory/
if [ $? -ne 0 ]; then
echo "rsync of factory images failed. aborting."
exit 1
fi
rsync -rltv --delete $SRC/images/sysupgrade/ $SRVSSH_USR@$SRVSSH:/$SRVSSH_PATH/$SRVSSH_DIR/$BRANCH/sysupgrade/
if [ $? -ne 0 ]; then
echo "rsync of sysupgrade images failed. aborting."
exit 1
fi
if [ -d "$SRC/images/other/" ]; then
rsync -rltv --delete $SRC/images/other/ $SRVSSH_USR@$SRVSSH:/$SRVSSH_PATH/$SRVSSH_DIR/$BRANCH/other/
if [ $? -ne 0 ]; then
echo "rsync of other images failed. aborting."
exit 1
fi
fi
rsync -rltv $SRC/packages/ $SRVSSH_USR@$SRVSSH:/$SRVSSH_PATH/modules/
if [ $? -ne 0 ]; then
echo "there was an error during rsync of packages/modules".
exit 1
fi
echo "finished."