|
|
@@ -75,11 +75,13 @@ help() {
|
|
|
-r, --port Change Backend Port default: 8083
|
|
|
-l, --lang Default language default: en
|
|
|
-y, --interactive Interactive install [yes|no] default: yes
|
|
|
+ -6, --ipv6 Enable IPv6 Support [yes|no] default: yes
|
|
|
-s, --hostname Set hostname
|
|
|
-e, --email Set admin email
|
|
|
-p, --password Set admin password
|
|
|
-D, --with-debs Path to Hestia debs
|
|
|
-f, --force Force installation
|
|
|
+ -O, --override Override checks (dangerous!)
|
|
|
-h, --help Print this help
|
|
|
|
|
|
Example: bash $0 -e [email protected] -p p4ssw0rd --multiphp yes"
|
|
|
@@ -219,11 +221,13 @@ for arg; do
|
|
|
--port) args="${args}-r " ;;
|
|
|
--lang) args="${args}-l " ;;
|
|
|
--interactive) args="${args}-y " ;;
|
|
|
+ --ipv6) args="${args}-6 " ;;
|
|
|
--api) args="${args}-d " ;;
|
|
|
--hostname) args="${args}-s " ;;
|
|
|
--email) args="${args}-e " ;;
|
|
|
--password) args="${args}-p " ;;
|
|
|
--force) args="${args}-f " ;;
|
|
|
+ --override) args="${args}-O " ;;
|
|
|
--with-debs) args="${args}-D " ;;
|
|
|
--help) args="${args}-h " ;;
|
|
|
*)
|
|
|
@@ -235,7 +239,7 @@ done
|
|
|
eval set -- "$args"
|
|
|
|
|
|
# Parsing arguments
|
|
|
-while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
|
|
|
+while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:6:s:e:p:D:fOh" Option; do
|
|
|
case $Option in
|
|
|
a) apache=$OPTARG ;; # Apache
|
|
|
w) phpfpm=$OPTARG ;; # PHP-FPM
|
|
|
@@ -258,11 +262,13 @@ while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
|
|
|
l) lang=$OPTARG ;; # Language
|
|
|
d) api=$OPTARG ;; # Activate API
|
|
|
y) interactive=$OPTARG ;; # Interactive install
|
|
|
+ 6) ipv6=$OPTARG ;; # IPv6
|
|
|
s) servername=$OPTARG ;; # Hostname
|
|
|
e) email=$OPTARG ;; # Admin email
|
|
|
p) vpass=$OPTARG ;; # Admin password
|
|
|
D) withdebs=$OPTARG ;; # Hestia debs path
|
|
|
f) force='yes' ;; # Force install
|
|
|
+ O) override='yes' ;; # Override checks
|
|
|
h) help ;; # Help
|
|
|
*) help ;; # Print help (default)
|
|
|
esac
|
|
|
@@ -296,6 +302,7 @@ set_default_value 'iptables' 'yes'
|
|
|
set_default_value 'fail2ban' 'yes'
|
|
|
set_default_value 'quota' 'no'
|
|
|
set_default_value 'interactive' 'yes'
|
|
|
+set_default_value 'ipv6' 'yes'
|
|
|
set_default_value 'api' 'yes'
|
|
|
set_default_port '8083'
|
|
|
set_default_lang 'en'
|
|
|
@@ -327,7 +334,7 @@ if [ "x$(id -u)" != 'x0' ]; then
|
|
|
check_result 1 "Script can be run executed only by root"
|
|
|
fi
|
|
|
|
|
|
-if [ -d "/usr/local/hestia" ]; then
|
|
|
+if [ -d "/usr/local/hestia" -a -z "$override" ]; then
|
|
|
check_result 1 "Hestia install detected. Unable to continue"
|
|
|
fi
|
|
|
|
|
|
@@ -644,6 +651,9 @@ if ! [[ "$servername" =~ ^${mask1}${mask2}$ ]]; then
|
|
|
servername="example.com"
|
|
|
fi
|
|
|
echo "127.0.0.1 $servername" >> /etc/hosts
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ echo "::1 $servername" >> /etc/hosts
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
if [[ -z $(grep -i "$servername" /etc/hosts) ]]; then
|
|
|
@@ -1058,6 +1068,18 @@ if [ ! -e "/sbin/iptables" ]; then
|
|
|
ln -s "$autoiptables" /sbin/iptables
|
|
|
fi
|
|
|
fi
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ if which ip6tables; then
|
|
|
+ ln -s "$(which ip6tables)" /sbin/ip6tables
|
|
|
+ elif [ -e "/usr/sbin/ip6tables" ]; then
|
|
|
+ ln -s /usr/sbin/ip6tables /sbin/ip6tables
|
|
|
+ elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ip6tables; then
|
|
|
+ autoip6tables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ip6tables | cut -d '' -f 2)
|
|
|
+ if [ -x "$autoip6tables" ]; then
|
|
|
+ ln -s "$autoip6tables" /sbin/ip6tables
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
if [ ! -e "/sbin/iptables-save" ]; then
|
|
|
@@ -1071,6 +1093,18 @@ if [ ! -e "/sbin/iptables-save" ]; then
|
|
|
ln -s "$autoiptables_save" /sbin/iptables-save
|
|
|
fi
|
|
|
fi
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ if which ip6tables-save; then
|
|
|
+ ln -s "$(which ip6tables-save)" /sbin/ip6tables-save
|
|
|
+ elif [ -e "/usr/sbin/ip6tables-save" ]; then
|
|
|
+ ln -s /usr/sbin/ip6tables-save /sbin/ip6tables-save
|
|
|
+ elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ip6tables-save; then
|
|
|
+ autoip6tables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d '' -f 2)
|
|
|
+ if [ -x "$autoip6tables_save" ]; then
|
|
|
+ ln -s "$autoip6tables_save" /sbin/ip6tables-save
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
if [ ! -e "/sbin/iptables-restore" ]; then
|
|
|
@@ -1084,6 +1118,18 @@ if [ ! -e "/sbin/iptables-restore" ]; then
|
|
|
ln -s "$autoiptables_restore" /sbin/iptables-restore
|
|
|
fi
|
|
|
fi
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ if which ip6tables-restore; then
|
|
|
+ ln -s "$(which ip6tables-restore)" /sbin/ip6tables-restore
|
|
|
+ elif [ -e "/usr/sbin/ip6tables-restore" ]; then
|
|
|
+ ln -s /usr/sbin/ip6tables-restore /sbin/ip6tables-restore
|
|
|
+ elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b ip6tables-restore; then
|
|
|
+ autoip6tables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d '' -f 2)
|
|
|
+ if [ -x "$autoip6tables_restore" ]; then
|
|
|
+ ln -s "$autoip6tables_restore" /sbin/ip6tables-restore
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
# Restrict access to /proc fs
|
|
|
@@ -1362,6 +1408,10 @@ cp -f $HESTIA_INSTALL_DIR/nginx/agents.conf /etc/nginx/conf.d/
|
|
|
cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
|
|
|
cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
|
|
|
cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
|
|
|
+if [ "$ipv6" = 'yes' ]; then
|
|
|
+ cp -f $HESTIA_INSTALL_DIR/nginx/nginx-ipv6.conf /etc/nginx/nginx.conf
|
|
|
+ cp -f $HESTIA_INSTALL_DIR/nginx/status-ipv6.conf /etc/nginx/conf.d/status.conf
|
|
|
+fi
|
|
|
mkdir -p /etc/nginx/conf.d/domains
|
|
|
mkdir -p /etc/nginx/modules-enabled
|
|
|
mkdir -p /var/log/nginx/domains
|
|
|
@@ -1372,10 +1422,20 @@ for ip in $dns_resolver; do
|
|
|
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
resolver="$ip $resolver"
|
|
|
fi
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ if [[ $ip =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
|
|
|
+ resolver="[$ip] $resolver"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
done
|
|
|
if [ -n "$resolver" ]; then
|
|
|
- sed -i "s/1.1.1.1 8.8.8.8/$resolver/g" /etc/nginx/nginx.conf
|
|
|
- sed -i "s/1.1.1.1 8.8.8.8/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ sed -i "s/1.1.1.1 \[2606:4700:4700::1111\] 1.1.1.1 \[2606:4700:4700::1001\]/$resolver/g" /etc/nginx/nginx.conf
|
|
|
+ sed -i "s/1.1.1.1 \[2606:4700:4700::1111\] 1.1.1.1 \[2606:4700:4700::1001\]/$resolver/g" /usr/local/hestia/nginx/
|
|
|
+ else
|
|
|
+ sed -i "s/1.1.1.1 8.8.8.8/$resolver/g" /etc/nginx/nginx.conf
|
|
|
+ sed -i "s/1.1.1.1 8.8.8.8/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
# https://github.com/ergin/nginx-cloudflare-real-ip/
|
|
|
@@ -1420,6 +1480,10 @@ if [ "$apache" = 'yes' ]; then
|
|
|
cp -f /etc/apache2/mods-available/status.load /etc/apache2/mods-available/hestia-status.load
|
|
|
cp -f $HESTIA_INSTALL_DIR/logrotate/apache2 /etc/logrotate.d/
|
|
|
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ cp -f $HESTIA_INSTALL_DIR/apache2/status-ipv6.conf /etc/apache2/mods-available/hestia-status.conf
|
|
|
+ fi
|
|
|
+
|
|
|
# Enable needed modules
|
|
|
a2enmod rewrite > /dev/null 2>&1
|
|
|
a2enmod suexec > /dev/null 2>&1
|
|
|
@@ -1512,6 +1576,9 @@ chmod 755 /etc/cron.daily/php-session-cleanup
|
|
|
if [ "$vsftpd" = 'yes' ]; then
|
|
|
echo "[ * ] Configuring Vsftpd server..."
|
|
|
cp -f $HESTIA_INSTALL_DIR/vsftpd/vsftpd.conf /etc/
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ cp -f $HESTIA_INSTALL_DIR/vsftpd/vsftpd-ipv6.conf /etc/vsftpd.conf
|
|
|
+ fi
|
|
|
touch /var/log/vsftpd.log
|
|
|
chown root:adm /var/log/vsftpd.log
|
|
|
chmod 640 /var/log/vsftpd.log
|
|
|
@@ -2025,6 +2092,8 @@ fi
|
|
|
|
|
|
# Get public IP
|
|
|
pub_ip=$(curl --ipv4 -s https://ip.hestiacp.com/)
|
|
|
+pub_ipv6=$(curl --ipv6 -s https://ip.hestiacp.com/)
|
|
|
+
|
|
|
if [ -n "$pub_ip" ] && [ "$pub_ip" != "$ip" ]; then
|
|
|
if [ -e /etc/rc.local ]; then
|
|
|
sed -i '/exit 0/d' /etc/rc.local
|