-
Notifications
You must be signed in to change notification settings - Fork 3
/
magparallel.sh
executable file
·35 lines (29 loc) · 1.4 KB
/
magparallel.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
# +----+----+----+----+
# | | | | |
# Author: Mark David Scott Cunningham | M | D | S | C |
# +----+----+----+----+
# Created: 2014-08-23
# Updated: 2014-08-23
#
#
#!/bin/bash
parallel(){
if [[ -z $@ || $1 == '-h' || $1 == '--help' ]]; then echo -e '\n Usage: parallel <domain> \n'; return 0;
elif [[ -f /etc/httpd/conf.d/vhost_$1.conf ]]; then D=$1;
elif [[ $1 == '.' && -f /etc/httpd/conf.d/vhost_$(pwd | sed 's:^/chroot::' | cut -d/ -f4).conf ]]; then
D=$(pwd | sed 's:^/chroot::' | cut -d/ -f4)
else
echo -e '\nCould not find requested vhost file!\n'; return 1;
fi
# Covert domain into Regex
domain=$(echo $D | sed 's:\.:\\\\\\.:g');
# Place first comment followed by a blank line
sed -i "s:\(.*RewriteCond %{HTTP_HOST}...$domain.\[NC\]\):\1\n \# ----- Magento-Parallel-Downloads -----\n:g" /etc/httpd/conf.d/vhost_$D.conf
# Place logic for parallel downloads
for x in skin media js; do sed -i "s:\(.*RewriteCond %{HTTP_HOST}...$domain.\[NC\]\):\1\n RewriteCond %{HTTP_HOST} \!\^$x\\\.$domain [NC]:g" /etc/httpd/conf.d/vhost_$D.conf; done
# Plase the secone comment preceded by a blank line
sed -i "s:\(.*RewriteCond %{HTTP_HOST}...$domain.\[NC\]\):\1\n\n \# ----- Magento-Parallel-Downloads -----:g" /etc/httpd/conf.d/vhost_$D.conf
# Test and restart Apache
httpd -t && service httpd reload && echo -e "\nParallel Downloads configured for $D\n"
}
parallel "$@"