Revision 173745e8
Added by Andreas Kohlbecker almost 3 years ago
scripts/admin/update-dependencies.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
1 |
#!/bin/bash -x
|
|
2 | 2 |
|
3 |
if [ -z "$1" ]; then |
|
4 |
echo "USAGE: update-dependencies.sh [--deactivate-install] [--multisite] [--mailto <ADDRESS>]" |
|
5 |
echo " --deactivate-install : The install.php will be hidden by appending '.off' to the filename" |
|
6 |
echo " --multisite: Do a multisite update. Requires dataportals-drush. See https://dev.e-taxonomy.eu/svn/trunk/server-scripts/dataportal-admin/" |
|
7 |
echo " --mailto <ADDRESS>: send a email to the ADDRESS with a log of the update process" |
|
8 |
exit 1 |
|
9 |
fi |
|
10 | 3 |
|
4 |
# -- options |
|
11 | 5 |
while [[ "$#" -gt 0 ]]; do |
12 | 6 |
case $1 in |
7 |
-h|--help) print_help=1;; |
|
13 | 8 |
--mailto) MAILTO="$2"; shift ;; |
14 | 9 |
--deactivate-install) deactivate_install=1 ;; |
15 | 10 |
--multisite) multisite=1 ;; |
11 |
--site-url) site_url=$2; shift ;; |
|
16 | 12 |
*) echo "Unknown parameter passed: $1"; exit 1 ;; |
17 | 13 |
esac |
18 | 14 |
shift |
19 | 15 |
done |
20 | 16 |
|
17 |
if [[ -n "$site_url" ]]; then |
|
18 |
unset multisite |
|
19 |
fi |
|
20 |
|
|
21 |
# -- help |
|
22 |
if [[ "$print_help" == "1" ]]; then |
|
23 |
echo "USAGE: update-dependencies.sh [--deactivate-install] [--multisite] [--mailto <ADDRESS>]" |
|
24 |
echo " --deactivate-install : The install.php will be hidden by appending '.off' to the filename" |
|
25 |
echo " -h, --help: Print this help text" |
|
26 |
echo " --mailto <ADDRESS>: send a email to the ADDRESS with a log of the update process" |
|
27 |
echo " --multisite: Do a multisite update. Requires dataportals-drush. See https://dev.e-taxonomy.eu/svn/trunk/server-scripts/dataportal-admin/" |
|
28 |
echo " --site-url: The site url to be used with drush. This option disables the --multisite option" |
|
29 |
exit 0 |
|
30 |
fi |
|
31 |
|
|
32 |
# -- tests |
|
21 | 33 |
if [[ -z "$(grep 'cybertaxonomy.org/drupal-7-dataportal' composer.json)" ]]; then |
22 | 34 |
echo "ERROR: This script must be executed in the root of the drupal-7-cdm-dataportal folder" |
23 | 35 |
exit -1 |
24 | 36 |
fi |
25 | 37 |
|
26 |
# configuration |
|
27 |
TMP=$(mktemp) |
|
38 |
# -- setup |
|
39 |
|
|
40 |
TMP=$(mktemp -d) |
|
28 | 41 |
|
29 |
if (( multisite == 1 )); then |
|
42 |
if [[ "$multisite" == "1" ]]; then |
|
43 |
DRUSH=$(which dataportals-drush) |
|
44 |
else |
|
30 | 45 |
DRUSH=./vendor/drush/drush/drush |
31 | 46 |
if [[ ! -e $DRUSH ]]; then |
32 | 47 |
echo "Need to install dependencies first ..." |
33 | 48 |
composer install --no-dev |
34 | 49 |
fi |
35 |
else |
|
36 |
DRUSH=$(which dataportals-drush) |
|
37 | 50 |
fi |
38 | 51 |
|
39 |
DRUSH=$DRUSH -r $(pwd)/web/ |
|
52 |
DRUSH=$DRUSH" -r $(pwd)/web/" |
|
53 |
if [[ -n "$site_url" ]]; then |
|
54 |
DRUSH=$DRUSH" -l $site_url" |
|
55 |
fi |
|
40 | 56 |
|
41 | 57 |
echo "creating full backup ..." |
42 |
|
|
43 | 58 |
archive_file=../drupal-7-cdm-dataportal-backup-$(date -I).tar.gz |
44 | 59 |
tar -czf $archive_file ./ |
45 |
|
|
46 |
echo "backup archive created: "$archive_file |
|
60 |
echo "backup archive created at "$(readlink -f $archive_file) |
|
47 | 61 |
|
48 | 62 |
echo "backing up settings and config files to temp backup ${TMP} ..." |
49 | 63 |
|
50 | 64 |
# backup modified files |
51 |
cp web/.htaccess ${TMP}/ |
|
52 |
cp web/robots*.txt ${TMP}/ |
|
53 |
|
|
54 |
|
|
55 |
exit 0 |
|
65 |
cp -a web/.htaccess* ${TMP}/ |
|
66 |
# .htaccess.dist is provieded by the drupal/drupal package und must not be in the backup |
|
67 |
rm -f ${TMP}/.htaccess.dist |
|
68 |
cp -a web/robots*.txt ${TMP}/ |
|
56 | 69 |
|
57 | 70 |
echo "setting dataportals in update mode ..." |
58 | 71 |
# set all portals into maintainance mode |
... | ... | |
78 | 91 |
# restore original settings and files and disable maintainance mode |
79 | 92 |
rm -f .htaccess.dist |
80 | 93 |
cp web/.htaccess web/.htaccess.dist |
81 |
cp ${TMP}.htaccess web/
|
|
82 |
cp ${TMP}robots*.txt web/
|
|
94 |
cp -a ${TMP}/.htaccess* web/
|
|
95 |
cp -a ${TMP}/robots*.txt web/
|
|
83 | 96 |
|
84 | 97 |
if (( deactivate_install == 1 )); then |
85 | 98 |
# hide the install.php |
Also available in: Unified diff
update script improved