|
|
@@ -80,6 +80,7 @@ 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: no
|
|
|
-s, --hostname Set hostname
|
|
|
-e, --email Set admin email
|
|
|
-p, --password Set admin password
|
|
|
@@ -218,6 +219,7 @@ 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 " ;;
|
|
|
@@ -254,6 +256,7 @@ while getopts "a:w:v:j:k: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
|
|
|
@@ -291,6 +294,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' 'no'
|
|
|
set_default_value 'api' 'yes'
|
|
|
set_default_port '8083'
|
|
|
set_default_lang 'en'
|
|
|
@@ -629,10 +633,16 @@ 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
|
|
|
echo "127.0.0.1 $servername" >> /etc/hosts
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ echo "::1 $servername" >> /etc/hosts
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
# Set email if it wasn't set
|
|
|
@@ -1052,6 +1062,19 @@ 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
|
|
|
@@ -1065,6 +1088,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
|
|
|
@@ -1078,6 +1113,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
|
|
|
@@ -1315,11 +1362,6 @@ chown root:mail $HESTIA/ssl/*
|
|
|
chmod 660 $HESTIA/ssl/*
|
|
|
rm /tmp/hst.pem
|
|
|
|
|
|
-# Adding nologin as a valid system shell
|
|
|
-if [ -z "$(grep nologin /etc/shells)" ]; then
|
|
|
- echo "/usr/sbin/nologin" >> /etc/shells
|
|
|
-fi
|
|
|
-
|
|
|
# Install dhparam.pem
|
|
|
cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl
|
|
|
|
|
|
@@ -1363,6 +1405,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
|
|
|
@@ -1373,10 +1419,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.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
|
|
|
- sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
|
|
|
+ if [ "$ipv6" = 'yes' ]; then
|
|
|
+ sed -i "s/1.0.0.1 \[2606:4700:4700::1111\] 1.0.0.1 \[2606:4700:4700::1001\]/$resolver/g" /etc/nginx/nginx.conf
|
|
|
+ sed -i "s/1.0.0.1 \[2606:4700:4700::1111\] 1.0.0.1 \[2606:4700:4700::1001\]/$resolver/g" /usr/local/hestia/nginx/
|
|
|
+ else
|
|
|
+ sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
|
|
|
+ sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
update-rc.d nginx defaults > /dev/null 2>&1
|
|
|
@@ -1399,6 +1455,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
|
|
|
@@ -1494,6 +1554,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
|
|
|
@@ -1953,7 +2016,9 @@ $HESTIA/bin/v-update-sys-ip > /dev/null 2>&1
|
|
|
|
|
|
# Get main IP
|
|
|
ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
|
|
|
+ipv6=$(ip addr|grep 'inet6 '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
|
|
|
local_ip=$ip
|
|
|
+local_ipv6=$ipv6
|
|
|
|
|
|
# Configuring firewall
|
|
|
if [ "$iptables" = 'yes' ]; then
|
|
|
@@ -1963,6 +2028,8 @@ fi
|
|
|
# Get public IP
|
|
|
echo "[ * ] Configuring System 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
|