-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw5update.sh
121 lines (87 loc) · 2.1 KB
/
sw5update.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# path to shopware installation path
docroot=""
# temp path
temp=""
# db name
dbname=""
if [[ ! -d $docroot ]]; then
echo "docroot path not not found"
exit
fi
if [[ ! -d $temp ]]; then
echo "temp path not not found"
exit
fi
if [[ -z $dbname ]]; then
echo "dbname not not set"
exit
fi
if [[ ! $(which curl) ]]; then
echo "curl not installed"
exit
fi
if [[ ! $(which jq) ]]; then
echo "jq not installed"
exit
fi
if [[ ! $(which unp) ]]; then
echo "unp not installed"
exit
fi
if [[ ! $(which sha1sum) ]]; then
echo "sha1sum not installed"
exit
fi
if [[ ! $(which sha256sum) ]]; then
echo "sha256sum not installed"
exit
fi
if [[ ! $(which mysqldump) ]]; then
echo "mysqldump not installed"
exit
fi
# backup
mysqldump -Q $dbname > ${temp}/${dbname}.sql
tar -zcf ${temp}/shop_docroot.tar.gz ${docroot}/
# download
upjson_uri="https://update-api.shopware.com/v1/release/update?channel=stable&shopware_version=5.99"
curl -s ${upjson_uri} -o ${temp}/update.json
updl_version=$(cat update.json | jq '.version' | tr -d \" )
updl_uri=$(cat update.json | jq '.uri' | tr \\/ / | tr -d \" )
updl_sha1=$(cat update.json | jq '.sha1' | tr -d \" )
updl_sha256=$(cat update.json | jq '.sha256' | tr -d \" )
updl_file="update_${updl_version}_${updl_sha1}.zip"
curl -s "${updl_uri}" -o ${temp}/${updl_file}
# checksum
if [[ $(sha1sum ${temp}/${updl_file} | cut -d " " -f1 ) != ${updl_sha1} ]]; then
echo "sha1sum missmatch"
exit
fi
if [[ $(sha256sum ${temp}/${updl_file} | cut -d " " -f1 ) != ${updl_sha256} ]]; then
echo "sha256sum missmatch"
exit
fi
cp "${temp}/${updl_file}" "${docroot}/${updl_file}"
#update
cd ${docroot}
unp "${updl_file}"
#php recovery/update/index.php --no-interaction --quiet
php recovery/update/index.php --no-interaction
# after update
rm UPGRADE-*.md
rm CONTRIBUTING.md
rm eula_en.txt
rm eula.txt
rm license.txt
rm README.md
rm -rf update-assets
rm "${docroot}/${updl_file}"
rm "${temp}/update.json"
chmod 700 bin/console
chgrp www-data bin/console
chmod g+rx bin/console
cd var/cache/
chmod 700 clear_cache.sh
./clear_cache.sh
rm -rf production_*