-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy.sh
85 lines (67 loc) · 2.26 KB
/
deploy.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 -e
# deploy.sh - Bundle installation data into a tar.gz file and prepend it with
# a bash script for self extracting / installation.
#
# Copyright (C) 2019 Basler AG
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
BASEDIR=`dirname "${0}"`
TMP_FILENAME=hucon-${1}.tar.gz
FILENAME=hucon-${1}.run
RELEASE_DIR=release
TEMP_DIR=$RELEASE_DIR/temp
FILELIST="LICENSE README.md code/ init.d/ python_lib/ webserver/ i2c_led.sh install.sh img_install.sh start_server.sh uninstall.sh update.sh version_compare.sh"
cd "$BASEDIR"
# create release dir, create version file and copy to the release folder
mkdir -p $TEMP_DIR
cp -r ${FILELIST} $TEMP_DIR
cd $TEMP_DIR
echo $1 > __version__
#minification of JS files
find . -type f \
-name "*.js" ! -name "*.min.*" ! -name "vfs_fonts*" \
-exec echo {} \; \
-exec yui-compressor -o {}.min {} \; \
-exec rm {} \; \
-exec mv {}.min {} \;
#minification of CSS files
find . -type f \
-name "*.css" ! -name "*.min.*" \
-exec echo {} \; \
-exec yui-compressor -o {}.min {} \; \
-exec rm {} \; \
-exec mv {}.min {} \;
# compress the needed files into one tar image
tar -czvf "$TMP_FILENAME" __version__ ${FILELIST}
mv "$TMP_FILENAME" ..
cd ..
rm -rf temp
# generate a self extracting tar image
tmp=__extract__$RANDOM
printf "#!/bin/sh -e
PAYLOAD_LINE=\`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' \$0\`
if [[ ! \$(which python3) ]]; then
echo \"Python3 is required for the new HuCon version. You need to update the firmware manually. The latest firmware release can be found at https://github.com/basler/hucon/releases\"
exit 1
fi
path=/opt/hucon
if [ \$1 ]; then
path=\"\$1\"hucon
fi
if [ -d \$path ]; then
echo \"Remove old installation from \$path\"
find \$path -mindepth 1 -maxdepth 1 ! -name '*.run' -exec rm -rf {} \;
fi
echo \"Unpack new files to \$path\"
echo \"This will take some time.\"
mkdir -p \$path | tail -n+\$PAYLOAD_LINE \$0 | tar -xzC \$path
if [ -z \$2 ] || [ \$2 != unpack ]; then
sh \$path/install.sh
fi
exit 0
__PAYLOAD_BELOW__\n" > "$tmp"
cat "$tmp" "$TMP_FILENAME" > "$FILENAME" && rm "$tmp" && rm "$TMP_FILENAME"
chmod +x "$FILENAME"
sha256sum "$FILENAME"