|
12 | 12 |
|
13 | 13 | ## If you need a custom hook file, create a file with the same name in |
14 | 14 | ## /usr/local/ispconfig/server/conf-custom/scripts/ |
| 15 | +## |
| 16 | +## End the file with 'return 124' to signal that this script should not terminate. |
| 17 | +## |
| 18 | +## Eg. you can override the ispc_letsencrypt_firewall_enable() function then 'return 124' |
| 19 | +## to customize the firewall setup. |
15 | 20 | if [ -e "/usr/local/ispconfig/server/conf-custom/scripts/letsencrypt_pre_hook.sh" ] ; then |
16 | | - . /usr/local/ispconfig/server/conf-custom/scripts/letsencrypt_pre_hook.sh && exit 0 || exit 1 ; |
| 21 | + . /usr/local/ispconfig/server/conf-custom/scripts/letsencrypt_pre_hook.sh |
| 22 | + ret=$? |
| 23 | + if [ $ret != 124 ]; then exit $ret; fi |
17 | 24 | fi |
18 | 25 |
|
19 | | -# You can add support to other firewall |
| 26 | +declare -F ispc_letsencrypt_firewall_enable &>/dev/null || ispc_letsencrypt_firewall_enable() { |
| 27 | + # create 'ispc-letsencrypt' chain with ACCEPT policy and send port 80 there |
| 28 | + iptables -N ispc-letsencrypt |
| 29 | + iptables -I ispc-letsencrypt -p tcp --dport 80 -j ACCEPT |
| 30 | + iptables -A ispc-letsencrypt -j RETURN |
| 31 | + iptables -I INPUT -p tcp --dport 80 -j ispc-letsencrypt |
| 32 | +} |
| 33 | + |
| 34 | +ispc_letsencrypt_firewall_enable |
20 | 35 |
|
21 | 36 | # For RHEL, Centos or derivatives |
22 | 37 | if which yum &> /dev/null 2>&1 ; then |
23 | 38 | # Check if web server software is installed, stop it if any |
24 | 39 | if [ rpm -q nginx ]; then service nginx stop; fi |
25 | 40 | if [ rpm -q httpd ]; then service httpd stop; fi |
26 | | - # If using firewalld |
27 | | - if [ rpm -q firewalld ] && [ `firewall-cmd --state` = running ]; then |
28 | | - firewall-cmd --zone=public --permanent --add-service=http |
29 | | - firewall-cmd --reload |
30 | | - fi |
31 | | - # If using UFW |
32 | | - if [ rpm -q ufw ]; then ufw --force enable && ufw allow http; fi |
| 41 | +# # If using firewalld |
| 42 | +# if [ rpm -q firewalld ] && [ `firewall-cmd --state` = running ]; then |
| 43 | +# firewall-cmd --zone=public --permanent --add-service=http |
| 44 | +# firewall-cmd --reload |
| 45 | +# fi |
| 46 | +# # If using UFW |
| 47 | +# if [ rpm -q ufw ]; then ufw --force enable && ufw allow http; fi |
33 | 48 |
|
34 | 49 | # For Debian, Ubuntu or derivatives |
35 | 50 | elif apt-get -v >/dev/null 2>&1 ; then |
36 | 51 | # Check if web server software is installed, stop it if any |
37 | 52 | if [ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 1 ]; then service nginx stop; fi |
38 | 53 | if [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 1 ]; then service apache2 stop; fi |
39 | | - # If using UFW |
40 | | - if [ $(dpkg-query -W -f='${Status}' ufw 2>/dev/null | grep -c "ok installed") -eq 1 ]; then ufw --force enable && ufw allow http; fi |
| 54 | +# # If using UFW |
| 55 | +# if [ $(dpkg-query -W -f='${Status}' ufw 2>/dev/null | grep -c "ok installed") -eq 1 ]; then ufw --force enable && ufw allow http; fi |
41 | 56 |
|
42 | | -# Try iptables as a final attempt |
43 | | -else |
44 | | - iptables -I INPUT -p tcp --dport 80 -j ACCEPT |
45 | | - service iptables save |
| 57 | +## Try iptables as a final attempt |
| 58 | +#else |
| 59 | +# iptables -I INPUT -p tcp --dport 80 -j ACCEPT |
| 60 | +# service iptables save |
46 | 61 | fi |
0 commit comments