-
Notifications
You must be signed in to change notification settings - Fork 7
/
update.py
49 lines (41 loc) · 813 Bytes
/
update.py
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
#!/bin/bash
set -e
# Проверить sudo
if [ "$(id -u)" != "0" ]; then
echo "Please run script as root"
exit 1
fi
# Get arguments
while getopts r:b: flag
do
case "${flag}" in
r) repo=${OPTARG};;
b) branch=${OPTARG};;
esac
done
# Цвета
COLOR='\033[92m'
ENDC='\033[0m'
# Go to work dir
cd /usr/src/mtc-jsonrpc
# Adjust repo
if [ -z ${repo+x} ]; then
echo "repo without changes"
else
git remote set-url origin ${repo}
git pull --rebase
fi
# Adjust branch
if [ -z ${branch+x} ]; then
echo "branch without changes"
else
git checkout ${branch}
git branch --set-upstream-to=origin/${branch} ${branch}
git pull --rebase
fi
# Update code
git pull --recurse-submodules
systemctl restart mtc-jsonrpc
# Конец
echo -e "${COLOR}[1/1]${ENDC} mtc-jsonrpc components update completed"
exit 0