-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_git_files.sh
executable file
·65 lines (48 loc) · 1.1 KB
/
generate_git_files.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
HASH=$(git show --pretty='format:%H' HEAD | head -1)
UPSTREAM=$(git remote get-url origin)
DIRNAME=$(basename $UPSTREAM '.git')
cat > download_update.sh << EOF
#!/bin/bash
## GENERATED FILE, DO NOT MODIFY
# Utility methods
function do_cleanup() {
if [[ -d /staging/$DIRNAME ]]
then
rm -rf /staging/$DIRNAME
fi
}
# Start with cleanup
do_cleanup
# Clone the repository
mkdir -p /staging
cd /staging
git clone $UPSTREAM
cd $DIRNAME
# Check if update needed. If not, clean up and exit
# the script
NEW_HASH=\$(git show --pretty='format:%H' HEAD | head -1)
if [[ '$HASH' == \$NEW_HASH ]]
then
do_cleanup
exit 0
fi
# Install the new version of the thermostat
./install.sh
INSTALL_RESULT=\$?
# Clean up and return
do_cleanup
exit \$INSTALL_RESULT
EOF
chmod +x download_update.sh
cat > management_service/build_info.py << EOF
## GENERATED FILE, DO NOT MODIFY
BUILD_VER = '$HASH'
EOF
cat > update_service/git_info.py << EOF
## GENERATED FILE, DO NOT MODIFY
GIT_ORIGIN = '$UPSTREAM'
EOF
cat > user_interface/git_info.js << EOF
// GENERATED FILE, DO NOT MODIFY
const BUILD_VER = '$HASH'
EOF