-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-module
More file actions
executable file
·48 lines (42 loc) · 1.63 KB
/
update-module
File metadata and controls
executable file
·48 lines (42 loc) · 1.63 KB
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
#!/bin/bash
#
# Usage: ./update-module path-to-new-module path-to-drupal-root
# Ex: ./update-module ~/drupal-module-updates/moduleName ~/public_html
#
# Assumes that last element of path-to-new-module is folder name that is
# identical to module's folder name under path-to-drupal-root/sites/all/modules
#
# Uses rsync to update <drupal_root>/sites/all/modules/<module_name>
# - will delete files in .../sites/all/modules/module_name that don't exist in new version
# - will not copy files that are the same in both places.
# - will copy files that are in new module but not under old version
#
# Warning: Will blow away any local changes -- that is, assumes that whatever is downloaded as
# module-name.tgz is complete.
# see http://thedrupalblog.com/updating-drupal-module-subversion-integrated-filesystem-using-rsync
print_usage_and_exit () {
echo "Usage: `basename $0` path_to_new_module path_to_drupal_root"
echo " Ex.: `basename $0` ~/module-updates/my_module ~/public_html"
exit 65
}
if [ $# -ne 2 ]
then
echo "wrong number of arguments"
print_usage_and_exit
fi
cwd=`pwd`
newmod_path=$1
root_path=$2
# simple validity check
if [ ! -e ${root_path}/sites/default/settings.php ]
then
echo "${root_path} does not look like a drupal installation."
print_usage_and_exit
fi
modname=`basename $newmod_path`
echo "updating module ${modname}..."
# -a = archive (recursive, links, preserve permissions, preserve times, preserve group, preserve owner, specials
# -v = verbose, -c = checksum-based, -C = auto-ignore
rsync -avcC --delete ${newmod_path}/ ${root_path}/sites/all/modules/${modname}/
echo "don't forget to commit"
exit 0