-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-sub.sh
69 lines (49 loc) · 2.26 KB
/
update-sub.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
#!/bin/bash
endScriptError() {
kdialog --title "Error" --error "An error occurred. See the console for details"
qdbus $dbusRef close 2> /dev/null > /dev/null
exit 1
}
if [[ -z "$(which kdialog)" ]]; then
echo "kdialog not found."
exit 1
fi
if [[ -z "$(which wget)" ]]; then
echo "wget not found."
exit 1
fi
dbusRef=$(kdialog --geometry 600x100 --title "Updating project's files..." --progressbar "Creating a backup... " 4)
#if find . -maxdepth 0 -empty | read; then
qdbus $dbusRef setLabelText "Creating a backup..." 2> /dev/null > /dev/null
dir="../$(basename $(pwd))-$(date +%F#%T|tr ':' '-')"
if [[ -d "$dir" ]]; then
echo "Can not create backup ! $dir already exists."
endScriptError
fi
echo "Backuping to $dir..."
mkdir "$dir"
cp -r . "$dir/" || (echo "Can not create backup !"; endScriptError)
rmdir "$dir" 2>/dev/null >/dev/null
#fi
#dbusRef=$(kdialog --title "Downloading files..." --progressbar "Updating project's files... " 4)
arch=$(uname -m)
rm -rf update
mkdir -p update
qdbus $dbusRef setLabelText "Downloading files..." 2> /dev/null > /dev/null
qdbus $dbusRef Set "" value 1 2> /dev/null > /dev/null
wget -q --no-check-certificate https://storage.projectsforge.org/update/c/base-$arch.tar.gz -O update/base.tar.gz || endScriptError
qdbus $dbusRef Set "" value 2 2> /dev/null > /dev/null
wget -q --no-check-certificate https://storage.projectsforge.org/update/c/doc.tar.gz -O update/doc.tar.gz 2>&1 || endScriptError
qdbus $dbusRef Set "" value 3 2> /dev/null > /dev/null
wget -q --no-check-certificate https://storage.projectsforge.org/update/c/user-$arch.tar.gz -O update/user.tar.gz || endScriptError
qdbus $dbusRef setLabelText "Extracting files..." 2> /dev/null > /dev/null
qdbus $dbusRef Set "" value 4 2> /dev/null > /dev/null
tar -xzf update/base.tar.gz || endScriptError
tar -xzf update/doc.tar.gz || endScriptError
echo "XXXXXXXXXXXXXXXXXXX"
tar -xzkf update/user.tar.gz
echo "Error between here and XXXXXXXXXXXXXXXXXXX are normal !!"
# || endScriptError
rm -rf update
qdbus $dbusRef close 2> /dev/null > /dev/null
exit 0