-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
58 lines (41 loc) · 896 Bytes
/
upgrade.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
#!/bin/bash
echo ""
echo "### Documents App Upgrade"
echo ""
if [[ "$USER" != "root" ]]; then
echo ""
echo "### Please run this script as root.";
echo ""
exit;
fi
CWD=$PWD
cd /opt/documents
echo ""
echo "### Pulling updates from Github repository."
echo ""
# Credits: http://stackoverflow.com/a/13242127
git fetch
for file in `git diff HEAD..origin/master --name-status | awk '/^A/ {print $2}'`
do rm -f -- "$file"; done
for file in `git diff --name-status | awk '/^[CDMRTUX]/ {print $2}'`
do git checkout -- "$file"; done
git pull
echo ""
echo "### Upgrading NPM packages."
echo ""
npm update
echo ""
echo "### Upgrading Bower packages."
echo ""
cd pub
#bower update -s --allow-root
bower update -s --allow-root --no-interactive | xargs echo
cd ..
echo ""
echo "### Restarting service."
echo ""
systemctl restart documents
echo ""
echo "### All done."
echo ""
cd $CWD