forked from SteKoe/nextcloud-customproperties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (55 loc) · 1.87 KB
/
build.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
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
VERSION=$(xmllint --xpath 'string(/info/version)' appinfo/info.xml)
CONTAINER_ID=
main() {
buildJavaScript
signSource
buildArchive
createSignature
tidyUp
}
buildJavaScript() {
echo "Build JavaScript..."
npm i && npm run build
}
signSource() {
CONTAINER_ID=$(docker run -d --name customproperties-build -v ~/.nextcloud/certificates/:/nextcloud/certificates/ nextcloud)
echo "Copy app to container '$CONTAINER_ID'..."
docker cp $(pwd) $CONTAINER_ID:/customproperties
docker exec -i $CONTAINER_ID /bin/bash -c "cd /customproperties && rm -rf .cache .git .idea node_modules"
echo "Sign sources using container '$CONTAINER_ID'..."
echo "Waiting for NextCloud to be initialized..."
until docker logs $CONTAINER_ID 2>&1 | grep "Initializing finished" >/dev/null; do
sleep 5
echo "Waiting..."
done
echo "NextCloud initialized!"
echo "Sign app app..."
docker exec -i $CONTAINER_ID php occ integrity:sign-app --privateKey=/nextcloud/certificates/customproperties.key --certificate=/nextcloud/certificates/customproperties.crt --path=/customproperties || true
}
buildArchive() {
echo "Build archive..."
docker exec -i $CONTAINER_ID tar -czf customproperties_$VERSION.tar.gz \
--exclude=./src/node_modules/ \
--exclude=./.git/ \
--exclude=./.build/ \
--exclude=./.cache/ \
--exclude=./.idea/ \
--exclude=./src/ \
/customproperties
echo "Copy archive..."
docker cp $CONTAINER_ID:/var/www/html/customproperties_$VERSION.tar.gz $(pwd)
}
createSignature() {
echo "Create signature..."
openssl dgst -sha512 -sign ~/.nextcloud/certificates/customproperties.key customproperties_$VERSION.tar.gz | openssl base64
}
tidyUp() {
echo "Tidy up..."
docker rm -f -v $CONTAINER_ID >/dev/null
}
main $@