-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·38 lines (36 loc) · 1.04 KB
/
update.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
#!/bin/sh
# this file is meant to be run from cron to update the local git branch with the
# associated upstream branch, then build and install into /var/www/html
# fetch changes from origin
git fetch
# get the number of changes between local and remote (current branch)
CHANGES=$(git rev-list HEAD...@{u} --count)
if [ $CHANGES = "0" ]; then
echo "git repo is current"
else
echo "git repo is not current. updating..."
git pull
if [ $? -eq 0 ]; then
echo "running npm install"
npm i
if [ $? -eq 0 ]; then
echo "runnin npm rebuild node-sass..."
npm rebuild node-sass
echo "running npm run build..."
npm run build
if [ $? -eq 0 ]; then
echo "npm build successful"
echo "copying new web files"
cp -rf dist/* /var/www/toolbox/wfo/
else
echo "npm failed to run build script"
fi
else
echo "failed npm install"
fi
else
echo "failed to pull repo"
echo "trying to remove package-lock.json and try on next iteration"
rm package-lock.json
fi
fi