Error unable to detect netplan configuration

Troubleshooting Troubleshooting networking issues Networking issues in netplan are commonly caused by incorrect configuration of the backend in use. Some features may not be supported by the chosen backend. Always refer to the netplan reference documentation when unsure, features that are only supported on some backends should be clearly marked as such. If you […]

Содержание

  1. Troubleshooting
  2. Troubleshooting networking issues
  3. Debugging netplan
  4. Debugging issues with the networkd backend
  5. Debugging issues with the NetworkManager backend
  6. Troubleshooting
  7. Troubleshooting networking issues
  8. Debugging netplan
  9. Debugging issues with the networkd backend
  10. Debugging issues with the NetworkManager backend
  11. netplan configuration not active — ubuntu 18.04
  12. Ошибка конфигурации Netplan: & ldquo; Недопустимый YAML & hellip; не нашел ожидаемого ключа. & rdquo;
  13. 12 ответов
  14. Настройка сети через netplan в Ubuntu 18.04

Troubleshooting

Troubleshooting networking issues

Networking issues in netplan are commonly caused by incorrect configuration of the backend in use. Some features may not be supported by the chosen backend.

Always refer to the netplan reference documentation when unsure, features that are only supported on some backends should be clearly marked as such.

If you think something is a bug, it might well be one. Please don’t hesitate to report bugs on netplan.

Debugging netplan

Refer to your netplan YAML configuration to know what backend is in use. Netplan configuration will be in *.yaml files under /etc/netplan, /run/netplan, or /lib/netplan.

Check that the backend configuration was generated correctly for the configuration provided in the netplan YAML by comparing the files generated by netplan under /run for the backend in use (see below).

Further investigate backend behavior if the issue persists and the configuration is as expected. To do this, start the backend in debug mode, reproduce the issue, and revise the logs. Identify any missing configuration options that need to be added.

Debugging issues with the networkd backend

Verify that configuration in /run/systemd/network includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching 10-netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. Some of the options may be written in a different file: each interface may have any of the *.network, *.netdev or *.link files.

The settings contained in these files are generally pretty self-explanatory, and are documented in systemd manpages systemd.network(5), systemd.netdev(5) and systemd.link(5). If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, systemd-networkd may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of systemd-networkd will be required. You may refer to the Ubuntu DebuggingSystemd page for more information on how to debug these issues.

Debugging issues with the NetworkManager backend

Verify that configuration in /run/NetworkManager/system-configuration includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. The name of options should be recognizable, compared to the configuration in your netplan YAML.

If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, NetworkManager may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of NetworkManager will be required. You may refer to the Ubuntu DebuggingNetworkManager page for more information on how to debug these issues.

Источник

Troubleshooting

Troubleshooting networking issues

Networking issues in netplan are commonly caused by incorrect configuration of the backend in use. Some features may not be supported by the chosen backend.

Always refer to the netplan reference documentation when unsure, features that are only supported on some backends should be clearly marked as such.

If you think something is a bug, it might well be one. Please don’t hesitate to report bugs on netplan.

Debugging netplan

Refer to your netplan YAML configuration to know what backend is in use. Netplan configuration will be in *.yaml files under /etc/netplan, /run/netplan, or /lib/netplan.

Check that the backend configuration was generated correctly for the configuration provided in the netplan YAML by comparing the files generated by netplan under /run for the backend in use (see below).

Further investigate backend behavior if the issue persists and the configuration is as expected. To do this, start the backend in debug mode, reproduce the issue, and revise the logs. Identify any missing configuration options that need to be added.

Debugging issues with the networkd backend

Verify that configuration in /run/systemd/network includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching 10-netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. Some of the options may be written in a different file: each interface may have any of the *.network, *.netdev or *.link files.

The settings contained in these files are generally pretty self-explanatory, and are documented in systemd manpages systemd.network(5), systemd.netdev(5) and systemd.link(5). If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, systemd-networkd may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of systemd-networkd will be required. You may refer to the Ubuntu DebuggingSystemd page for more information on how to debug these issues.

Debugging issues with the NetworkManager backend

Verify that configuration in /run/NetworkManager/system-configuration includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. The name of options should be recognizable, compared to the configuration in your netplan YAML.

If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, NetworkManager may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of NetworkManager will be required. You may refer to the Ubuntu DebuggingNetworkManager page for more information on how to debug these issues.

Источник

netplan configuration not active — ubuntu 18.04

trying to set up a fixed IP address on one of two NIC. I try using netplan. Not working at all.

Not an expert on this, I am out of my wits and ready to roll back to some other way (networkd). Maybe someone has a useful advice in any direction. Any help/ comment greatly appreciated !

(A) PROBLEM:

1) after boot, enp2s0 has no ip4 address assigned

2) this also cannot be achieved by

as a side note, tried changing interface names previously which also takes no effect.

(B) SYSTEM CONFIG:

This down here remains completely unchanged, despite whatever I try with netplan (just omitting addresses for privacy):

Netplan seems to be the «official» setup:

This is my netplan config, it seems to validate, as netplan invocations don’t throw errors. there is only one yaml file.

(C) FINDINGS/INVESTIGATIONS:

I looked at this stuff, but to no avail

netplan seems to have generated what I wanted:

Note the generate output — anything obvious ?

Please look at these outputs, they seem to carry the only hints:

Note it first says «netplan generated networkd configuration changed. » but then in next line «no netplan generated NM configuration exists». Sounds like some networkd config is still active ?

Also, it seems to have some problem on application level (syntax accepted) with the yaml: enp2s0 not found in <>, also in line just below that. But why ?

Источник

Ошибка конфигурации Netplan: & ldquo; Недопустимый YAML & hellip; не нашел ожидаемого ключа. & rdquo;

Я пытаюсь подключиться к интернету с помощью статического IP-адреса, но когда я вхожу в команду sudo netplan apply, консоль возвращает следующую ошибку:

Invalid YAML at //etc/netplan/01-netcfg.yaml line 8 column 5: did not find expected key.

Как это исправить? Содержимое моего 01-netcfg.yaml выглядит так:

network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no dhcp6: no addresses: [10.0.2.15/64] gateway4: 10.0.2.0 nameservers: addresses: [8.8.8.8,8.8.4.4]

12 ответов

Итак, что касается конкретной ошибки, которую вы получаете, вы провалили базовый синтаксис YAML и отступы, что является одной из причин, по которым жалуется netplan. YAML чрезвычайно ориентирован на углубление для того, как он интерпретирует команды, аргументы конфигурации и т. Д. Для правильной обработки конфигураций YAML необходимо иметь правильный отступ. Сюрприз, вы не делаете этого вообще и не нарушаете синтаксис YAML. Вот почему netplan жалуется, потому что вы не предоставляете надлежащий YAML.

Но что еще более важно, чем синтаксис YAML, который заставит Netplan работать, крайне , и вам действительно нужно исправлять их независимо. Эти сбои, в частности:

10.0.2.15/64 не являются допустимым диапазоном CIDR IPv4. Допустимые диапазоны CIDR находятся между /0 (для всех IPv4) и /32 (для одного адреса) для IPv4. Большинство сетей /24 для диапазона CIDR (с этим диапазоном IP, который будет охватывать 10.0.2.1 — 10.0.2.255 как удобное адресное пространство, хотя я бы предположил, что .1 является шлюзом, а .255 является широковещательной, но это может отличаются в вашей сети, поэтому дважды проверьте все значения!). Необходим правильный диапазон CIDR, поэтому система знает, что такое сетевая маска и доступное пространство IP. 10.0.2.0 не является надлежащим адресом шлюза. Адрес .0 не является удобным для использования адресом в подсети IP, поскольку он обычно удерживается только сетевым префиксом. И поскольку ваша конфигурация netowrk пытается сделать /24, но ужасно терпит неудачу, этот шлюз должен быть, вероятно, 10.0.2.1, но опять же дважды проверьте эти значения с помощью сетевого администратора.

Итак, исправление вашего отступа более важно , фиксирующего сеть, чтобы предположить, что это /24 на основе попыток IP и шлюза, которые вы указали, ваш YAML должен выглядеть следующим образом: соответствующие углубления. И по сравнению с существующим, вам действительно нужно узнать, как работает отступ.

network: version: 2 ethernets: enp0s3: dhcp4: no dhcp6: no addresses: [10.0.2.15/24] gateway4: 10.0.2.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]

Итак, что касается конкретной ошибки, которую вы получаете, вы провалили базовый синтаксис YAML и отступы, что является одной из причин, по которым жалуется netplan. YAML чрезвычайно ориентирован на углубление для того, как он интерпретирует команды, аргументы конфигурации и т. Д. Для правильной обработки конфигураций YAML необходимо иметь правильный отступ. Сюрприз, вы не делаете этого вообще и не нарушаете синтаксис YAML. Вот почему netplan жалуется, потому что вы не предоставляете надлежащий YAML.

Но что еще более важно, чем синтаксис YAML, который заставит Netplan работать, крайне , и вам действительно нужно исправлять их независимо. Эти сбои, в частности:

10.0.2.15/64 не являются допустимым диапазоном CIDR IPv4. Допустимые диапазоны CIDR находятся между /0 (для всех IPv4) и /32 (для одного адреса) для IPv4. Большинство сетей /24 для диапазона CIDR (с этим диапазоном IP, который будет охватывать 10.0.2.1 — 10.0.2.255 как удобное адресное пространство, хотя я бы предположил, что .1 является шлюзом, а .255 является широковещательной, но это может отличаются в вашей сети, поэтому дважды проверьте все значения!). Необходим правильный диапазон CIDR, поэтому система знает, что такое сетевая маска и доступное пространство IP. 10.0.2.0 не является надлежащим адресом шлюза. Адрес .0 не является удобным для использования адресом в подсети IP, поскольку он обычно удерживается только сетевым префиксом. И поскольку ваша конфигурация netowrk пытается сделать /24, но ужасно терпит неудачу, этот шлюз должен быть, вероятно, 10.0.2.1, но опять же дважды проверьте эти значения с помощью сетевого администратора.

Итак, исправление вашего отступа более важно , фиксирующего сеть, чтобы предположить, что это /24 на основе попыток IP и шлюза, которые вы указали, ваш YAML должен выглядеть следующим образом: соответствующие углубления. И по сравнению с существующим, вам действительно нужно узнать, как работает отступ.

network: version: 2 ethernets: enp0s3: dhcp4: no dhcp6: no addresses: [10.0.2.15/24] gateway4: 10.0.2.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]

Источник

Настройка сети через netplan в Ubuntu 18.04

Как я понял, теперь в Ubuntu 18.04 за основную утилиту для настройки сетевых настроек из командной строки — это netplan. Настройка работы интерфейсов сводится к правильному конфигурированию через абстракцию YAML.

На заметку: При настройке конфигурационного файла netplan самое глачное не использовать символы табуляции, только символы пробела. Именно это и есть абстракция использования YAML (Yet Another Markup Language» — «Ещё один язык разметки»)

$ sudo apt remove ifupdown -y

Отобразить все сетевые интерфейсы системы:

  • интерфейс в выводе: epn0s3 → это сетевой интерфейс на который настроена система
  • интерфейс в выводе: lo → интерфейс обратной петли (loopback)

Если система установлена, а интерфейс не назначен системой или системе, то при просмотре конфигурационного файла утилиты netplan содержимое ничего не содержит, нужно его сформировать:

$ sudo netplan generate

Чтобы установить статический IP-адрес:

$ sudo nano /etc/netplan/01-netcfg.yaml

# имя сетевого интерфейса

# активация или дезактивация получения настроек от DHCP-сервиса для IPv4

# можно указывать, как no/yes так и true/false

# активация или дезактивация получения настроек от DHCP-сервиса для IPv6

# можно указывать, как no/yes так и true/false

# установка статического адреса с указанием действующей маски подсети

# установка шлюза для IPv4 (по умолчанию)

# установка DNS-серверов, если в доменной сети, то указываем IP адреса контроллеров домена, если без домена, то адрес Вашего маршрутизатора или же публичные DNS: 8.8.8.8, 8.8.4.4 или DNS провайдера.

Не забываем сохранить внесенные изменения и применить:

$ sudo netplan apply

Error in network definition //etc/netplan/01-netcfg.yaml line 7 column 14: expected sequence

Если в файле конфигурации присутствует ошибка она будет выведена на консоль и ее нужно исправить т.к. изменения не будут применены. Подсказка: седьмая строка и четырнадцатый символ в моем случае.

Addresses: [172.40.40.25/24] → нужны квадратные скобки

Итоговый конфигурационный файл:

# Выбор сетевого рендера. Выбран networkd

# Блок с настройкой сетевых интерфейсов

Чтобы установить динамический IP-адрес:

$ sudo nano /etc/netplan/01-netcfg.yaml

$ sudo netplan apply

На заметку: как всегда расширенную информацию по использованию следует черпать в справочном файле: ekzorchik@srv-bionic:

Чтобы установить несколько сетевых интерфейсов, то их можно либо разбить, как каждый конфигурационный файл с расширением yaml или все указать в едином. Просто начав с новой строки именованием второго или более сетевым интерфейсом:

$ sudo nano /etc/netplan/01-netcfg.yaml

$ sudo netplan apply

Чтобы проверить правильность конфигурационного файла на ошибки:

$ sudo netplan try

Warning: Stopping systemd-networkd.service, but it can still be activated by:

Do you want to keep these settings?

Press ENTER before the timeout to accept the new configuration

Changes will revert in 118 seconds

И если все правильно сказать системе нажатием клавиши Enter применить их.

А после проверяем, что интерфейс поднялся и получил или был назначен:

Установить сетевой интерфейс использую NetworkManager если настройка ведется через интерфейс wifi:

$ sudo nano /etc/netplan/01-network-manager-all.yaml

$ sudo netplan apply

$ sudo ifconfig -a | egrep -E «wlp3s0|inet»

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10

wlp3s0: flags=4163 mtu 1500

inet 172.40.40.7 netmask 255.255.255.0 broadcast 172.40.40.255

inet6 fe80::96d1:8a4e:ed15:9be8 prefixlen 64 scopeid 0x20

И если все правильно указано для подключения к точке доступа, то интерфейс поднимется и подключиться к Wi-Fi и в зависимости от настроек получит сетевой адрес, как у меня. Для справки Wi-Fi подключение работает на базе Mikrotik. Скорее всего у Вас также как у меня при подключении к Wi-Fi сетевой адрес выдает от DHCP-сервиса и тогда конфигурационный файл можно сократить до вида:

Дабы не мудрить с правильность настройки конфигурационного файла под интерфейса за основу можно взять один из примеров прилагаемых вместе с утилитой netplan:

bonding_router.yaml direct_connect_gateway.yaml static.yaml

bonding.yaml loopback_interface.yaml vlan.yaml

bridge_vlan.yaml network_manager.yaml windows_dhcp_server.yaml

bridge.yaml source_routing.yaml wireless.yaml

$ sudo cp /usr/share/doc/netplan.io/examples/wireless.yaml /etc/netplan/01-networkd.yaml

На заметку: любой настроечный файл в каталоге /etc/netplan будет обрабатываться утилитой netplan имеющий расширение yaml.

Вот мой рабочий конфиг с ноутбука Lenovo E555 системы Ubuntu 18.04 Desktop amd64, если нажать клавишу F8 то выключаем Wi-Fi, если подключен кабель ethernet, то настройки автоматически присваиваются и интернет и локальная сеть есть, если вытаскиваю кабель, а включаю Wi-Fi то также интернет есть, если оба интерфейса включены то интернет также есть:

$ sudo nano /etc/netplan/01-networkd.yaml

ekzorchik@navy:/etc/netplan$ sudo netplan apply

На заметку: в файле ekzorchik@navy:

$ cat /etc/network/interfaces все закомментировано, за исключением:

iface lo inet loopback

Итого, я для себя разобрал, как настраивается сетевой интерфейс(ы) через утилиту netplan в системе Ubuntu 18.04 независимо от используемой редакции, как Server или Desktop. На этом я прощаюсь, с уважением автор блога Олло Александр aka ekzorchik.

Используйте прокси ((заблокировано роскомнадзором, используйте vpn или proxy)) при использовании Telegram клиента:

Поблагодари автора и новые статьи

будут появляться чаще 🙂

Карта МКБ: 4432 7300 0040 4626

Большое спасибо тем кто благодарит автора за практические заметки небольшими пожертвованиями. С уважением, Олло Александр aka ekzorchik.

Источник

#!/bin/bash # ======================================================== # # # Hestia Control Panel Installer for Ubuntu # https://www.hestiacp.com/ # # Currently Supported Versions: # Ubuntu 18.04 LTS, 20.04, 22.04 LTS # # ======================================================== # #———————————————————-# # Variables&Functions # #———————————————————-# export PATH=$PATH:/sbin export DEBIAN_FRONTEND=noninteractive RHOST=apt.hestiacp.com GPG=gpg.hestiacp.com VERSION=ubuntu HESTIA=/usr/local/hestia LOG=«/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log« memory=$(grep MemTotal /proc/meminfo | tr n | grep [0-9]) hst_backups=«/root/hst_install_backups/$(date +%d%m%Y%H%M)« spinner=«/-|« os=ubuntu release=«$(lsb_release -s -r)« codename=«$(lsb_release -s -c)« architecture=«$(arch)« HESTIA_INSTALL_DIR=«$HESTIA/install/deb« HESTIA_COMMON_DIR=«$HESTIA/install/common« VERBOSE=no # Define software versions HESTIA_INSTALL_VER=1.7.0~alpha # Dependencies multiphp_v=(«5.6« «7.0« «7.1« «7.2« «7.3« «7.4« «8.0« «8.1« «8.2«) fpm_v=«8.0« mariadb_v=«10.6« # Defining software pack for all distros software=«apache2 apache2.2-common apache2-suexec-custom apache2-utils apparmor-utils awstats bc bind9 bsdmainutils bsdutils clamav-daemon cron curl dnsutils dovecot-imapd dovecot-pop3d dovecot-sieve dovecot-managesieved e2fslibs e2fsprogs exim4 exim4-daemon-heavy expect fail2ban flex ftp git idn2 imagemagick libapache2-mod-fcgid libapache2-mod-php$fpm_v libapache2-mod-rpaf lsof mc mariadb-client mariadb-common mariadb-server mysql-client mysql-common mysql-server nginx php$fpm_v php$fpm_v-cgi php$fpm_v-common php$fpm_v-curl php$fpm_v-mysql php$fpm_v-imap php$fpm_v-ldap php$fpm_v-apcu phppgadmin php$fpm_v-pgsql php$fpm_v-zip php$fpm_v-bz2 php$fpm_v-cli php$fpm_v-gd php$fpm_v-imagick php$fpm_v-intl php$fpm_v-mbstring php$fpm_v-opcache php$fpm_v-pspell php$fpm_v-readline php$fpm_v-xml postgresql postgresql-contrib proftpd-basic quota rrdtool spamassassin sudo hestia=${HESTIA_INSTALL_VER} hestia-nginx hestia-php vim-common vsftpd whois unzip zip acl sysstat setpriv rsyslog ipset libonig5 libzip4 openssh-server lsb-release zstd jq« installer_dependencies=«apt-transport-https curl dirmngr gnupg wget software-properties-common ca-certificates« # Defining help function help() { echo «Usage: $0 [OPTIONS] -a, —apache Install Apache [yes|no] default: yes -w, —phpfpm Install PHP-FPM [yes|no] default: yes -o, —multiphp Install Multi-PHP [yes|no] default: no -v, —vsftpd Install Vsftpd [yes|no] default: yes -j, —proftpd Install ProFTPD [yes|no] default: no -k, —named Install Bind [yes|no] default: yes -m, —mysql Install MariaDB [yes|no] default: yes -M, —mysql-classic Install MySQL [yes|no] default: no -g, —postgresql Install PostgreSQL [yes|no] default: no -x, —exim Install Exim [yes|no] default: yes -z, —dovecot Install Dovecot [yes|no] default: yes -Z, —sieve Install Sieve [yes|no] default: no -c, —clamav Install ClamAV [yes|no] default: yes -t, —spamassassin Install SpamAssassin [yes|no] default: yes -i, —iptables Install Iptables [yes|no] default: yes -b, —fail2ban Install Fail2ban [yes|no] default: yes -q, —quota Filesystem Quota [yes|no] default: no -d, —api Activate API [yes|no] default: yes -r, —port Change Backend Port default: 8083 -l, —lang Default language default: en -y, —interactive Interactive install [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 -h, —help Print this help Example: bash $0 -e demo@hestiacp.com -p p4ssw0rd —multiphp yes« exit 1 } # Defining file download function download_file() { wget $1 -q —show-progress —progress=bar:force } # Defining password-gen function gen_pass() { matrix=$1 length=$2 if [ -z «$matrix« ]; then matrix=«A-Za-z0-9« fi if [ -z «$length« ]; then length=16 fi head /dev/urandom | tr -dc $matrix | head -c$length } # Defining return code check function check_result() { if [ $1 -ne 0 ]; then echo «Error: $2« exit $1 fi } # Defining function to set default value set_default_value() { eval variable=$$1 if [ -z «$variable« ]; then eval $1=$2 fi if [ «$variable« != yes ] && [ «$variable« != no ]; then eval $1=$2 fi } # Defining function to set default language value set_default_lang() { if [ -z «$lang« ]; then eval lang=$1 fi lang_list=«ar az bg bn bs ckb cs da de el en es fa fi fr hr hu id it ja ka ko nl no pl pt pt-br ro ru sk sr sv th tr uk ur vi zh-cn zh-tw« if ! (echo $lang_list | grep -w $lang > /dev/null 2>&1); then eval lang=$1 fi } # Define the default backend port set_default_port() { if [ -z «$port« ]; then eval port=$1 fi } # Write configuration KEY/VALUE pair to $HESTIA/conf/hestia.conf write_config_value() { local key=«$1« local value=«$2« echo «$key=’$value« >> $HESTIA/conf/hestia.conf } # Sort configuration file values # Write final copy to $HESTIA/conf/hestia.conf for active usage # Duplicate file to $HESTIA/conf/defaults/hestia.conf to restore known good installation values sort_config_file() { sort $HESTIA/conf/hestia.conf -o /tmp/updconf mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak mv /tmp/updconf $HESTIA/conf/hestia.conf rm -f $HESTIA/conf/hestia.conf.bak if [ ! -d «$HESTIA/conf/defaults/« ]; then mkdir -p «$HESTIA/conf/defaults/« fi cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf } # Validate hostname according to RFC1178 validate_hostname() { # remove extra . servername=$(echo «$servername« | sed -e «s/[.]*$//g«) servername=$(echo «$servername« | sed -e «s/^[.]*//«) if [[ $(echo «$servername« | grep -o «.« | wc -l) -gt 1 ]] && [[ ! $servername =~ ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$ ]]; then # Hostname valid return 1 else # Hostname invalid return 0 fi } validate_email() { if [[ ! «$email« =~ ^[A-Za-z0-9._%+-]+@[[:alnum:].-]+.[A-Za-z]{2,63}$ ]]; then # Email invalid return 0 else # Email valid return 1 fi } #———————————————————-# # Verifications # #———————————————————-# # Creating temporary file tmpfile=$(mktemp -p /tmp) # Translating argument to —gnu-long-options for arg; do delim=«« case «$arg« in —apache) args=«${args}-a « ;; —phpfpm) args=«${args}-w « ;; —vsftpd) args=«${args}-v « ;; —proftpd) args=«${args}-j « ;; —named) args=«${args}-k « ;; —mysql) args=«${args}-m « ;; —mysql-classic) args=«${args}-M « ;; —postgresql) args=«${args}-g « ;; —exim) args=«${args}-x « ;; —dovecot) args=«${args}-z « ;; —sieve) args=«${args}-Z « ;; —clamav) args=«${args}-c « ;; —spamassassin) args=«${args}-t « ;; —iptables) args=«${args}-i « ;; —fail2ban) args=«${args}-b « ;; —multiphp) args=«${args}-o « ;; —quota) args=«${args}-q « ;; —port) args=«${args}-r « ;; —lang) args=«${args}-l « ;; —interactive) args=«${args}-y « ;; —api) args=«${args}-d « ;; —hostname) args=«${args}-s « ;; —email) args=«${args}-e « ;; —password) args=«${args}-p « ;; —force) args=«${args}-f « ;; —with-debs) args=«${args}-D « ;; —help) args=«${args}-h « ;; *) [[ «${arg:0:1}« == «« ]] || delim=««« args=«${args}${delim}${arg}${delim} « ;; esac 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 case $Option in a) apache=$OPTARG ;; # Apache w) phpfpm=$OPTARG ;; # PHP-FPM o) multiphp=$OPTARG ;; # Multi-PHP v) vsftpd=$OPTARG ;; # Vsftpd j) proftpd=$OPTARG ;; # Proftpd k) named=$OPTARG ;; # Named m) mysql=$OPTARG ;; # MariaDB M) mysqlclassic=$OPTARG ;; # MySQL g) postgresql=$OPTARG ;; # PostgreSQL x) exim=$OPTARG ;; # Exim z) dovecot=$OPTARG ;; # Dovecot Z) sieve=$OPTARG ;; # Sieve c) clamd=$OPTARG ;; # ClamAV t) spamd=$OPTARG ;; # SpamAssassin i) iptables=$OPTARG ;; # Iptables b) fail2ban=$OPTARG ;; # Fail2ban q) quota=$OPTARG ;; # FS Quota r) port=$OPTARG ;; # Backend Port l) lang=$OPTARG ;; # Language d) api=$OPTARG ;; # Activate API y) interactive=$OPTARG ;; # Interactive install 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 h) help ;; # Help *) help ;; # Print help (default) esac done # Defining default software stack set_default_value nginx yes set_default_value apache yes set_default_value phpfpm yes set_default_value multiphp no set_default_value vsftpd yes set_default_value proftpd no set_default_value named yes set_default_value mysql yes set_default_value mysqlclassic no set_default_value postgresql no set_default_value exim yes set_default_value dovecot yes set_default_value sieve no if [ $memory -lt 1500000 ]; then set_default_value clamd no set_default_value spamd no elif [ $memory -lt 3000000 ]; then set_default_value clamd no set_default_value spamd yes else set_default_value clamd yes set_default_value spamd yes fi set_default_value iptables yes set_default_value fail2ban yes set_default_value quota no set_default_value interactive yes set_default_value api yes set_default_port 8083 set_default_lang en # Checking software conflicts if [ «$proftpd« = yes ]; then vsftpd=no fi if [ «$exim« = no ]; then clamd=no spamd=no dovecot=no sieve=no fi if [ «$dovecot« = no ]; then sieve=no fi if [ «$iptables« = no ]; then fail2ban=no fi if [ «$apache« = «no« ]; then phpfpm=yes fi if [ «$mysql« = yes ] && [ «$mysqlclassic« = yes ]; then mysql=no fi # Checking root permissions if [ «x$(id -u)« != x0 ]; then check_result 1 «Script can be run executed only by root« fi if [ -d «/usr/local/hestia« ]; then check_result 1 «Hestia install detected. Unable to continue« fi # Checking admin user account if [ -n «$(grep ^admin: /etc/passwd /etc/group)« ] && [ -z «$force« ]; then echo Please remove admin user account before proceeding. echo If you want to do it automatically run installer with -f option: echo -e «Example: bash $0 —forcen« check_result 1 «User admin exists« fi # Clear the screen once launch permissions have been verified clear # Configure apt to retry downloading on error if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then echo «APT::Acquire::Retries «3«;« > /etc/apt/apt.conf.d/80-retries fi # Welcome message echo «Welcome to the Hestia Control Panel installer!« echo echo «Please wait, the installer is now checking for missing dependencies…« echo # Update apt repository apt-get -qq update # Creating backup directory mkdir -p «$hst_backups« # Pre-install packages echo «[ * ] Installing dependencies…« apt-get -y install $installer_dependencies >> $LOG check_result $? «Package installation failed, check log file for more details.« # Check repository availability wget —quiet «https://$GPG/deb_signing.key« -O /dev/null check_result $? «Unable to connect to the Hestia APT repository« # Check installed packages tmpfile=$(mktemp -p /tmp) dpkg —get-selections > $tmpfile conflicts_pkg=«exim4 mariadb-server apache2 nginx hestia postfix ufw« # Drop postfix from the list if exim should not be installed if [ «$exim« = no ]; then conflicts_pkg=$(echo $conflicts_pkg | sed s/postfix//g | xargs) fi for pkg in $conflicts_pkg; do if [ -n «$(grep $pkg $tmpfile)« ]; then conflicts=«$pkg* $conflicts« fi done rm -f $tmpfile if [ -n «$conflicts« ] && [ -z «$force« ]; then echo !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! echo echo WARNING: The following packages are already installed echo «$conflicts« echo echo It is highly recommended that you remove them before proceeding. echo echo !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! echo read -p Would you like to remove the conflicting packages? [y/n] answer if [ «$answer« = y ] || [ «$answer« = Y ]; then apt-get -qq purge $conflicts -y check_result $? apt-get remove failed unset $answer else check_result 1 «Hestia Control Panel should be installed on a clean server.« fi fi # Check network configuration if [ -d /etc/netplan ] && [ -z «$force« ]; then if [ -z «$(ls -A /etc/netplan)« ]; then echo !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! echo echo WARNING: Your network configuration may not be set up correctly. echo Details: The netplan configuration directory is empty. echo echo You may have a network configuration file that was created using echo systemd-networkd. echo echo It is strongly recommended to migrate to netplan, which is now the echo default network configuration system in newer releases of Ubuntu. echo echo While you can leave your configuration as-is, please note that you echo will not be able to use additional IPs properly. echo echo If you wish to continue and force the installation, echo run this script with -f option: echo «Example: bash $0 —force« echo echo !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! echo check_result 1 «Unable to detect netplan configuration.« fi fi # Validate whether installation script matches release version before continuing with install if [ -z «$withdebs« ] || [ ! -d «$withdebs« ]; then release_branch_ver=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/release/src/deb/hestia/control | grep «Version:« | awk {print $2}) if [ «$HESTIA_INSTALL_VER« != «$release_branch_ver« ]; then echo echo -e «e[91mInstallation abortede[0m« echo «====================================================================« echo -e «e[33mERROR: Install script version does not match package version!e[0m« echo -e «e[33mPlease download the installer from the release branch in order to continue:e[0m« echo «« echo -e «e[33mhttps://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.she[0m« echo «« echo -e «e[33mTo test pre-release versions, build the .deb packages and re-run the installer:e[0m« echo -e « e[33m./hst_autocompile.sh e[1m—hestia branchname noe[21me[0m« echo -e « e[33m./hst-install.sh .. e[1m—with-debs /tmp/hestiacp-src/debse[21me[0m« echo «« check_result 1 «Installation aborted« fi fi case $architecture in x86_64) ARCH=«amd64« ;; aarch64) ARCH=«arm64« ;; *) echo echo -e «e[91mInstallation abortede[0m« echo «====================================================================« echo -e «e[33mERROR: $architecture is currently not supported!e[0m« echo -e «e[33mPlease verify the achitecture used is currenlty supportede[0m« echo «« echo -e «e[33mhttps://github.com/hestiacp/hestiacp/blob/main/README.mde[0m« echo «« check_result 1 «Installation aborted« ;; esac #———————————————————-# # Brief Info # #———————————————————-# install_welcome_message() { DISPLAY_VER=$(echo $HESTIA_INSTALL_VER | sed «s|~alpha||g« | sed «s|~beta||g«) echo echo _ _ _ _ ____ ____ echo | | | | ___ ___| |_(_) __ _ / ___| _ echo | |_| |/ _ / __| __| |/ _` | | | |_) | echo | _ | __/__ |_| | (_| | |___| __/ echo |_| |_|___||___/__|_|__,_|____|_| echo « « echo « Hestia Control Panel « if [[ «$HESTIA_INSTALL_VER« =~ «beta« ]]; then echo « BETA RELEASE « fi if [[ «$HESTIA_INSTALL_VER« =~ «alpha« ]]; then echo « DEVELOPMENT SNAPSHOT « echo « NOT INTENDED FOR PRODUCTION USE « echo « USE AT YOUR OWN RISK « fi echo « ${DISPLAY_VER} « echo « www.hestiacp.com « echo echo «========================================================================« echo echo «Thank you for downloading Hestia Control Panel! In a few moments,« echo «we will begin installing the following components on your server:« echo } # Printing nice ASCII logo clear install_welcome_message # Web stack echo — NGINX Web / Proxy Server if [ «$apache« = yes ]; then echo — Apache Web Server (as backend) fi if [ «$phpfpm« = yes ] && [ «$multiphp« = no ]; then echo — PHP-FPM Application Server fi if [ «$multiphp« = yes ]; then phpfpm=yes echo — Multi-PHP Environment fi # DNS stack if [ «$named« = yes ]; then echo — Bind DNS Server fi # Mail stack if [ «$exim« = yes ]; then echo -n — Exim Mail Server if [ «$clamd« = yes ] || [ «$spamd« = yes ]; then echo -n + if [ «$clamd« = yes ]; then echo -n ClamAV fi if [ «$spamd« = yes ]; then if [ «$clamd« = yes ]; then echo -n + fi echo -n SpamAssassin fi fi echo if [ «$dovecot« = yes ]; then echo -n — Dovecot POP3/IMAP Server if [ «$sieve« = yes ]; then echo -n + Sieve fi fi fi echo # Database stack if [ «$mysql« = yes ]; then echo — MariaDB Database Server fi if [ «$mysqlclassic« = yes ]; then echo — MySQL8 Database Server fi if [ «$postgresql« = yes ]; then echo — PostgreSQL Database Server fi # FTP stack if [ «$vsftpd« = yes ]; then echo — Vsftpd FTP Server fi if [ «$proftpd« = yes ]; then echo — ProFTPD FTP Server fi # Firewall stack if [ «$iptables« = yes ]; then echo -n — Firewall (iptables) fi if [ «$iptables« = yes ] && [ «$fail2ban« = yes ]; then echo -n + Fail2Ban Access Monitor fi echo -e «n« echo «========================================================================« echo -e «n« # Asking for confirmation to proceed if [ «$interactive« = yes ]; then read -p Would you like to continue with the installation? [Y/N]: answer if [ «$answer« != y ] && [ «$answer« != Y ]; then echo Goodbye exit 1 fi fi # Validate Email / Hostname even when interactive = no # Asking for contact email if [ -z «$email« ]; then while validate_email; do echo -e «nPlease use a valid emailadress (ex. info@domain.tld).« read -p Please enter admin email address: email done else if validate_email; then echo «Please use a valid emailadress (ex. info@domain.tld).« exit 1 fi fi # Asking to set FQDN hostname if [ -z «$servername« ]; then # Ask and validate FQDN hostname. read -p «Please enter FQDN hostname [$(hostname -f)]: « servername # Set hostname if it wasn’t set if [ -z «$servername« ]; then servername=$(hostname -f) fi # Validate Hostname, go to loop if the validation fails. while validate_hostname; do echo -e «nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld).« read -p «Please enter FQDN hostname [$(hostname -f)]: « servername done else # Validate FQDN hostname if it is preset if validate_hostname; then echo «Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld).« exit 1 fi fi # Generating admin password if it wasn’t set displaypass=«The password you chose during installation.« if [ -z «$vpass« ]; then vpass=$(gen_pass) displaypass=$vpass fi # Set FQDN if it wasn’t set mask1=(([[:alnum:]](-?[[:alnum:]])*).) mask2=*[[:alnum:]](-?[[:alnum:]])+.[[:alnum:]]{2,} if ! [[ «$servername« =~ ^${mask1}${mask2}$ ]]; then if [[ -n «$servername« ]]; then servername=«$servername.example.com« else servername=«example.com« fi echo «127.0.0.1 $servername« >> /etc/hosts fi if [[ -z $(grep -i «$servername« /etc/hosts) ]]; then echo «127.0.0.1 $servername« >> /etc/hosts fi # Set email if it wasn’t set if [[ -z «$email« ]]; then email=«admin@$servername« fi # Defining backup directory echo -e «Installation backup directory: $hst_backups« # Print Log File Path echo «Installation log file: $LOG« # Print new line echo #———————————————————-# # Checking swap # #———————————————————-# # Checking swap on small instances if [ -z «$(swapon -s)« ] && [ «$memory« -lt 1000000 ]; then fallocate -l 1G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo «/swapfile none swap sw 0 0« >> /etc/fstab fi #———————————————————-# # Install repository # #———————————————————-# # Define apt conf location apt=/etc/apt/sources.list.d # Create new folder if not all-ready exists mkdir -p /root/.gnupg/ && chmod 700 /root/.gnupg/ # Updating system echo «Adding required repositories to proceed with installation:« echo # Installing Nginx repo echo «[ * ] NGINX« echo «deb [arch=$ARCH signed-by=/usr/share/keyrings/nginx-keyring.gpg] https://nginx.org/packages/mainline/$VERSION/ $codename nginx« > $apt/nginx.list curl -s https://nginx.org/keys/nginx_signing.key | gpg —dearmor | tee /usr/share/keyrings/nginx-keyring.gpg > /dev/null 2>&1 #add-apt-repository does not support it yet see #https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1862764 # Installing sury PHP repo echo «[ * ] PHP« LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php > /dev/null 2>&1 # Installing sury Apache2 repo if [ «$apache« = yes ]; then echo «[ * ] Apache2« echo «deb http://ppa.launchpad.net/ondrej/apache2/ubuntu $codename main« > $apt/apache2.list fi # Installing MariaDB repo if [ «$mysql« = yes ]; then echo «[ * ] MariaDB« if [ «$release« != 22.04 ]; then echo «deb [arch=$ARCH signed-by=/usr/share/keyrings/mariadb-keyring.gpg] https://dlm.mariadb.com/repo/mariadb-server/$mariadb_v/repo/$VERSION $codename main« > $apt/mariadb.list else echo «#deb [arch=$ARCH signed-by=/usr/share/keyrings/mariadb-keyring.gpg] https://dlm.mariadb.com/repo/mariadb-server/$mariadb_v/repo/$VERSION $codename main« > $apt/mariadb.list fi curl -s https://mariadb.org/mariadb_release_signing_key.asc | gpg —dearmor | tee /usr/share/keyrings/mariadb-keyring.gpg > /dev/null 2>&1 fi # Installing HestiaCP repo echo «[ * ] Hestia Control Panel« echo «deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-keyring.gpg] https://$RHOST/ $codename main« > $apt/hestia.list gpg —no-default-keyring —keyring /usr/share/keyrings/hestia-keyring.gpg —keyserver hkp://keyserver.ubuntu.com:80 —recv-keys A189E93654F0B0E5 > /dev/null 2>&1 # Installing PostgreSQL repo if [ «$postgresql« = yes ]; then echo «[ * ] PostgreSQL« echo «deb [arch=$ARCH signed-by=/usr/share/keyrings/postgresql-keyring.gpg] https://apt.postgresql.org/pub/repos/apt/ $codename-pgdg main« > $apt/postgresql.list curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg —dearmor | tee /usr/share/keyrings/postgresql-keyring.gpg > /dev/null 2>&1 fi # Echo for a new line echo # Updating system echo -ne «Updating currently installed packages, please wait… « apt-get -qq update apt-get -y upgrade >> $LOG & BACK_PID=$! # Check if package installation is done, print a spinner spin_i=1 while kill -0 $BACK_PID > /dev/null 2>&1; do printf «b${spinner:spin_i++%${#spinner}:1}« sleep 0.5 done # Do a blank echo to get the n back echo # Check Installation result wait $BACK_PID check_result $? apt-get upgrade failed #———————————————————-# # Backup # #———————————————————-# # Creating backup directory tree mkdir -p $hst_backups cd $hst_backups mkdir nginx apache2 php vsftpd proftpd bind exim4 dovecot clamd mkdir spamassassin mysql postgresql hestia # Backup nginx configuration systemctl stop nginx > /dev/null 2>&1 cp -r /etc/nginx/* $hst_backups/nginx > /dev/null 2>&1 # Backup Apache configuration systemctl stop apache2 > /dev/null 2>&1 cp -r /etc/apache2/* $hst_backups/apache2 > /dev/null 2>&1 rm -f /etc/apache2/conf.d/* > /dev/null 2>&1 # Backup PHP-FPM configuration systemctl stop php*-fpm > /dev/null 2>&1 cp -r /etc/php/* $hst_backups/php/ > /dev/null 2>&1 # Backup Bind configuration systemctl stop bind9 > /dev/null 2>&1 cp -r /etc/bind/* $hst_backups/bind > /dev/null 2>&1 # Backup Vsftpd configuration systemctl stop vsftpd > /dev/null 2>&1 cp /etc/vsftpd.conf $hst_backups/vsftpd > /dev/null 2>&1 # Backup ProFTPD configuration systemctl stop proftpd > /dev/null 2>&1 cp /etc/proftpd/* $hst_backups/proftpd > /dev/null 2>&1 # Backup Exim configuration systemctl stop exim4 > /dev/null 2>&1 cp -r /etc/exim4/* $hst_backups/exim4 > /dev/null 2>&1 # Backup ClamAV configuration systemctl stop clamav-daemon > /dev/null 2>&1 cp -r /etc/clamav/* $hst_backups/clamav > /dev/null 2>&1 # Backup SpamAssassin configuration systemctl stop spamassassin > /dev/null 2>&1 cp -r /etc/spamassassin/* $hst_backups/spamassassin > /dev/null 2>&1 # Backup Dovecot configuration systemctl stop dovecot > /dev/null 2>&1 cp /etc/dovecot.conf $hst_backups/dovecot > /dev/null 2>&1 cp -r /etc/dovecot/* $hst_backups/dovecot > /dev/null 2>&1 # Backup MySQL/MariaDB configuration and data systemctl stop mysql > /dev/null 2>&1 killall -9 mysqld > /dev/null 2>&1 mv /var/lib/mysql $hst_backups/mysql/mysql_datadir > /dev/null 2>&1 cp -r /etc/mysql/* $hst_backups/mysql > /dev/null 2>&1 mv -f /root/.my.cnf $hst_backups/mysql > /dev/null 2>&1 # Backup Hestia systemctl stop hestia > /dev/null 2>&1 cp -r $HESTIA/* $hst_backups/hestia > /dev/null 2>&1 apt-get -y purge hestia hestia-nginx hestia-php > /dev/null 2>&1 rm -rf $HESTIA > /dev/null 2>&1 #———————————————————-# # Package Includes # #———————————————————-# if [ «$phpfpm« = yes ]; then fpm=«php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl php$fpm_v-mysql php$fpm_v-soap php$fpm_v-xml php$fpm_v-zip php$fpm_v-mbstring php$fpm_v-bz2 php$fpm_v-pspell php$fpm_v-imagick« software=«$software $fpm« fi #———————————————————-# # Package Excludes # #———————————————————-# # Excluding packages software=$(echo «$software« | sed -e «s/apache2.2-common//«) if [ «$apache« = no ]; then software=$(echo «$software« | sed -e «s/apache2 //«) software=$(echo «$software« | sed -e «s/apache2-bin//«) software=$(echo «$software« | sed -e «s/apache2-utils//«) software=$(echo «$software« | sed -e «s/apache2-suexec-custom//«) software=$(echo «$software« | sed -e «s/apache2.2-common//«) software=$(echo «$software« | sed -e «s/libapache2-mod-rpaf//«) software=$(echo «$software« | sed -e «s/libapache2-mod-fcgid//«) software=$(echo «$software« | sed -e «s/libapache2-mod-php$fpm_v//«) fi if [ «$vsftpd« = no ]; then software=$(echo «$software« | sed -e «s/vsftpd//«) fi if [ «$proftpd« = no ]; then software=$(echo «$software« | sed -e «s/proftpd-basic//«) software=$(echo «$software« | sed -e «s/proftpd-mod-vroot//«) fi if [ «$named« = no ]; then software=$(echo «$software« | sed -e «s/bind9//«) fi if [ «$exim« = no ]; then software=$(echo «$software« | sed -e «s/exim4 //«) software=$(echo «$software« | sed -e «s/exim4-daemon-heavy//«) software=$(echo «$software« | sed -e «s/dovecot-imapd//«) software=$(echo «$software« | sed -e «s/dovecot-pop3d//«) software=$(echo «$software« | sed -e «s/clamav-daemon//«) software=$(echo «$software« | sed -e «s/spamassassin//«) software=$(echo «$software« | sed -e «s/dovecot-sieve//«) software=$(echo «$software« | sed -e «s/dovecot-managesieved//«) fi if [ «$clamd« = no ]; then software=$(echo «$software« | sed -e «s/clamav-daemon//«) fi if [ «$spamd« = no ]; then software=$(echo «$software« | sed -e «s/spamassassin//«) fi if [ «$dovecot« = no ]; then software=$(echo «$software« | sed -e «s/dovecot-imapd//«) software=$(echo «$software« | sed -e «s/dovecot-pop3d//«) fi if [ «$sieve« = no ]; then software=$(echo «$software« | sed -e «s/dovecot-sieve//«) software=$(echo «$software« | sed -e «s/dovecot-managesieved//«) fi if [ «$mysql« = no ]; then software=$(echo «$software« | sed -e «s/mariadb-server//«) software=$(echo «$software« | sed -e «s/mariadb-client//«) software=$(echo «$software« | sed -e «s/mariadb-common//«) fi if [ «$mysqlclassic« = no ]; then software=$(echo «$software« | sed -e «s/mysql-server//«) software=$(echo «$software« | sed -e «s/mysql-client//«) software=$(echo «$software« | sed -e «s/mysql-common//«) fi if [ «$mysql« = no ] && [ «$mysqlclassic« = no ]; then software=$(echo «$software« | sed -e «s/php$fpm_v-mysql//«) if [ «$multiphp« = yes ]; then for v in «${multiphp_v[@]}«; do software=$(echo «$software« | sed -e «s/php$v-mysql//«) software=$(echo «$software« | sed -e «s/php$v-bz2//«) done fi fi if [ «$postgresql« = no ]; then software=$(echo «$software« | sed -e «s/postgresql-contrib//«) software=$(echo «$software« | sed -e «s/postgresql//«) software=$(echo «$software« | sed -e «s/php$fpm_v-pgsql//«) if [ «$multiphp« = yes ]; then for v in «${multiphp_v[@]}«; do software=$(echo «$software« | sed -e «s/php$v-pgsql//«) done fi software=$(echo «$software« | sed -e «s/phppgadmin//«) fi if [ «$fail2ban« = no ]; then software=$(echo «$software« | sed -e «s/fail2ban//«) fi if [ «$iptables« = no ]; then software=$(echo «$software« | sed -e «s/ipset//«) software=$(echo «$software« | sed -e «s/fail2ban//«) fi if [ «$phpfpm« = yes ]; then software=$(echo «$software« | sed -e «s/php$fpm_v-cgi//«) software=$(echo «$software« | sed -e «s/libapache2-mod-ruid2//«) software=$(echo «$software« | sed -e «s/libapache2-mod-php$fpm_v//«) fi if [ -d «$withdebs« ]; then software=$(echo «$software« | sed -e «s/hestia-nginx//«) software=$(echo «$software« | sed -e «s/hestia-php//«) software=$(echo «$software« | sed -e «s/hestia=${HESTIA_INSTALL_VER}//«) fi if [ «$release« = 18.04 ]; then software=$(echo «$software« | sed -e «s/libonig5/libonig4/«) fi if [ «$release« = 20.04 ]; then software=$(echo «$software« | sed -e «s/setpriv/util-linux/«) software=$(echo «$software« | sed -e «s/libzip4/libzip5/«) fi if [ «$release« = 22.04 ]; then software=$(echo «$software« | sed -e «s/setpriv/util-linux/«) fi #———————————————————-# # Disable Apparmor on LXC # #———————————————————-# if grep —quiet lxc /proc/1/environ; then if [ -f /etc/init.d/apparmor ]; then systemctl stop apparmor > /dev/null 2>&1 systemctl disable apparmor > /dev/null 2>&1 fi fi #———————————————————-# # Install packages # #———————————————————-# # Disabling daemon autostart on apt-get install echo -e #!/bin/shnexit 101 > /usr/sbin/policy-rc.d chmod a+x /usr/sbin/policy-rc.d # Installing apt packages echo «The installer is now downloading and installing all required packages.« echo -ne «NOTE: This process may take 10 to 15 minutes to complete, please wait… « echo apt-get -y install $software > $LOG BACK_PID=$! # Check if package installation is done, print a spinner spin_i=1 while kill -0 $BACK_PID > /dev/null 2>&1; do printf «b${spinner:spin_i++%${#spinner}:1}« sleep 0.5 done # Do a blank echo to get the n back echo # Check Installation result wait $BACK_PID check_result $? «apt-get install failed« echo echo «========================================================================« echo # Install Hestia packages from local folder if [ -n «$withdebs« ] && [ -d «$withdebs« ]; then echo «[ * ] Installing local package files…« echo « — hestia core package« dpkg -i $withdebs/hestia_*.deb > /dev/null 2>&1 if [ -z $(ls $withdebs/hestia-php_*.deb 2> /dev/null) ]; then echo « — hestia-php backend package (from apt)« apt-get -y install hestia-php > /dev/null 2>&1 else echo « — hestia-php backend package« dpkg -i $withdebs/hestia-php_*.deb > /dev/null 2>&1 fi if [ -z $(ls $withdebs/hestia-nginx_*.deb 2> /dev/null) ]; then echo « — hestia-nginx backend package (from apt)« apt-get -y install hestia-nginx > /dev/null 2>&1 else echo « — hestia-nginx backend package« dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1 fi fi # Restoring autostart policy rm -f /usr/sbin/policy-rc.d #———————————————————-# # Configure system # #———————————————————-# echo «[ * ] Configuring system settings…« # Enable SFTP subsystem for SSH sftp_subsys_enabled=$(grep -iE «^#?.*subsystem.+(sftp )?sftp-server« /etc/ssh/sshd_config) if [ -n «$sftp_subsys_enabled« ]; then sed -i -E «s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g« /etc/ssh/sshd_config fi # Reduce SSH login grace time sed -i «s/[#]LoginGraceTime [[:digit:]]m/LoginGraceTime 1m/g« /etc/ssh/sshd_config # Disable SSH suffix broadcast if [ -z «$(grep «^DebianBanner no« /etc/ssh/sshd_config)« ]; then sed -i /^[#]Banner .*/a DebianBanner no /etc/ssh/sshd_config if [ -z «$(grep «^DebianBanner no« /etc/ssh/sshd_config)« ]; then # If first attempt fails just add it echo >> /etc/ssh/sshd_config echo DebianBanner no >> /etc/ssh/sshd_config fi fi # Restart SSH daemon systemctl restart ssh # Disable AWStats cron rm -f /etc/cron.d/awstats # Set directory color if [ -z «$(grep LS_COLORS=»$LS_COLORS:di=00;33″ /etc/profile)« ]; then echo LS_COLORS=»$LS_COLORS:di=00;33″ >> /etc/profile fi # Registering /usr/sbin/nologin if [ -z «$(grep nologin /etc/shells)« ]; then echo «/usr/sbin/nologin« >> /etc/shells fi # Configuring NTP sed -i s/#NTP=/NTP=pool.ntp.org/ /etc/systemd/timesyncd.conf systemctl enable systemd-timesyncd systemctl start systemd-timesyncd # Check iptables paths and add symlinks when necessary if [ ! -e «/sbin/iptables« ]; then if which iptables > /dev/null; then ln -s «$(which iptables)« /sbin/iptables elif [ -e «/usr/sbin/iptables« ]; then ln -s /usr/sbin/iptables /sbin/iptables elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables; then autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables | cut -d -f 2) if [ -x «$autoiptables« ]; then ln -s «$autoiptables« /sbin/iptables fi fi fi if [ ! -e «/sbin/iptables-save« ]; then if which iptables-save > /dev/null; then ln -s «$(which iptables-save)« /sbin/iptables-save elif [ -e «/usr/sbin/iptables-save« ]; then ln -s /usr/sbin/iptables-save /sbin/iptables-save elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save; then autoiptables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d -f 2) if [ -x «$autoiptables_save« ]; then ln -s «$autoiptables_save« /sbin/iptables-save fi fi fi if [ ! -e «/sbin/iptables-restore« ]; then if which iptables-restore > /dev/null; then ln -s «$(which iptables-restore)« /sbin/iptables-restore elif [ -e «/usr/sbin/iptables-restore« ]; then ln -s /usr/sbin/iptables-restore /sbin/iptables-restore elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore; then autoiptables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d -f 2) if [ -x «$autoiptables_restore« ]; then ln -s «$autoiptables_restore« /sbin/iptables-restore fi fi fi # Restrict access to /proc fs # — Prevent unpriv users from seeing each other running processes mount -o remount,defaults,hidepid=2 /proc > /dev/null 2>&1 if [ $? -ne 0 ]; then echo «Info: Cannot remount /proc (LXC containers require additional perm added to host apparmor profile)« else echo «@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc« > /etc/cron.d/hestia-proc fi #———————————————————-# # Configure Hestia # #———————————————————-# echo «[ * ] Configuring Hestia Control Panel…« # Installing sudo configuration mkdir -p /etc/sudoers.d cp -f $HESTIA_INSTALL_DIR/sudo/admin /etc/sudoers.d/ chmod 440 /etc/sudoers.d/admin # Add Hestia global config if [[ ! -e /etc/hestiacp/hestia.conf ]]; then mkdir -p /etc/hestiacp echo -e «# Do not edit this file, will get overwritten on next upgrade, use /etc/hestiacp/local.conf insteadnnexport HESTIA=’/usr/local/hestia’nn[[ -f /etc/hestiacp/local.conf ]] && source /etc/hestiacp/local.conf« > /etc/hestiacp/hestia.conf fi # Configuring system env echo «export HESTIA=’$HESTIA« > /etc/profile.d/hestia.sh echo PATH=$PATH:$HESTIA/bin >> /etc/profile.d/hestia.sh echo export PATH >> /etc/profile.d/hestia.sh chmod 755 /etc/profile.d/hestia.sh source /etc/profile.d/hestia.sh # Configuring logrotate for Hestia logs cp -f $HESTIA_INSTALL_DIR/logrotate/hestia /etc/logrotate.d/hestia # Create log path and symbolic link rm -f /var/log/hestia mkdir -p /var/log/hestia ln -s /var/log/hestia $HESTIA/log # Building directory tree and creating some blank files for Hestia mkdir -p $HESTIA/conf $HESTIA/ssl $HESTIA/data/ips $HESTIA/data/queue $HESTIA/data/users $HESTIA/data/firewall $HESTIA/data/sessions touch $HESTIA/data/queue/backup.pipe $HESTIA/data/queue/disk.pipe $HESTIA/data/queue/webstats.pipe $HESTIA/data/queue/restart.pipe $HESTIA/data/queue/traffic.pipe $HESTIA/data/queue/daily.pipe $HESTIA/log/system.log $HESTIA/log/nginx-error.log $HESTIA/log/auth.log $HESTIA/log/backup.log chmod 750 $HESTIA/conf $HESTIA/data/users $HESTIA/data/ips $HESTIA/log chmod -R 750 $HESTIA/data/queue chmod 660 /var/log/hestia/* chmod 770 $HESTIA/data/sessions # Generating Hestia configuration rm -f $HESTIA/conf/hestia.conf > /dev/null 2>&1 touch $HESTIA/conf/hestia.conf chmod 660 $HESTIA/conf/hestia.conf # Write default port value to hestia.conf # If a custom port is specified it will be set at the end of the installation process. write_config_value «BACKEND_PORT« «8083« # Web stack if [ «$apache« = yes ]; then write_config_value «WEB_SYSTEM« «apache2« write_config_value «WEB_RGROUPS« «www-data« write_config_value «WEB_PORT« «8080« write_config_value «WEB_SSL_PORT« «8443« write_config_value «WEB_SSL« «mod_ssl« write_config_value «PROXY_SYSTEM« «nginx« write_config_value «PROXY_PORT« «80« write_config_value «PROXY_SSL_PORT« «443« write_config_value «STATS_SYSTEM« «awstats« fi if [ «$apache« = no ]; then write_config_value «WEB_SYSTEM« «nginx« write_config_value «WEB_PORT« «80« write_config_value «WEB_SSL_PORT« «443« write_config_value «WEB_SSL« «openssl« write_config_value «STATS_SYSTEM« «awstats« fi if [ «$phpfpm« = yes ] || [ «$multiphp« = yes ]; then write_config_value «WEB_BACKEND« «php-fpm« fi # Database stack if [ «$mysql« = yes ] || [ «$mysqlclassic« = yes ]; then installed_db_types=mysql fi if [ «$postgresql« = yes ]; then installed_db_types=«$installed_db_types,pgsql« fi if [ -n «$installed_db_types« ]; then db=$(echo «$installed_db_types« | sed «s/,/n/g« | sort -r -u | sed «/^$/d« | sed :a;N;$!ba;s/n/,/g) write_config_value «DB_SYSTEM« «$db« fi # FTP stack if [ «$vsftpd« = yes ]; then write_config_value «FTP_SYSTEM« «vsftpd« fi if [ «$proftpd« = yes ]; then write_config_value «FTP_SYSTEM« «proftpd« fi # DNS stack if [ «$named« = yes ]; then write_config_value «DNS_SYSTEM« «bind9« fi # Mail stack if [ «$exim« = yes ]; then write_config_value «MAIL_SYSTEM« «exim4« if [ «$clamd« = yes ]; then write_config_value «ANTIVIRUS_SYSTEM« «clamav-daemon« fi if [ «$spamd« = yes ]; then write_config_value «ANTISPAM_SYSTEM« «spamassassin« fi if [ «$dovecot« = yes ]; then write_config_value «IMAP_SYSTEM« «dovecot« fi if [ «$sieve« = yes ]; then write_config_value «SIEVE_SYSTEM« «yes« fi fi # Cron daemon write_config_value «CRON_SYSTEM« «cron« # Firewall stack if [ «$iptables« = yes ]; then write_config_value «FIREWALL_SYSTEM« «iptables« fi if [ «$iptables« = yes ] && [ «$fail2ban« = yes ]; then write_config_value «FIREWALL_EXTENSION« «fail2ban« fi # Disk quota if [ «$quota« = yes ]; then write_config_value «DISK_QUOTA« «yes« else write_config_value «DISK_QUOTA« «no« fi # Backups write_config_value «BACKUP_SYSTEM« «local« write_config_value «BACKUP_GZIP« «4« write_config_value «BACKUP_MODE« «zstd« # Language write_config_value «LANGUAGE« «$lang« # Login in screen write_config_value «LOGIN_STYLE« «default« # Theme write_config_value «THEME« «dark« # Inactive session timeout write_config_value «INACTIVE_SESSION_TIMEOUT« «60« # Version & Release Branch write_config_value «VERSION« «${HESTIA_INSTALL_VER}« write_config_value «RELEASE_BRANCH« «release« # Email notifications after upgrade write_config_value «UPGRADE_SEND_EMAIL« «true« write_config_value «UPGRADE_SEND_EMAIL_LOG« «false« # Installing hosting packages cp -rf $HESTIA_COMMON_DIR/packages $HESTIA/data/ # Update nameservers in hosting package IFS=. read -r -a domain_elements <<< «$servername« if [ -n «${domain_elements[-2]}« ] && [ -n «${domain_elements[-1]}« ]; then serverdomain=«${domain_elements[-2]}.${domain_elements[-1]}« sed -i s/«domain.tld«/«$serverdomain«/g $HESTIA/data/packages/*.pkg fi # Installing templates cp -rf $HESTIA_INSTALL_DIR/templates $HESTIA/data/ cp -rf $HESTIA_COMMON_DIR/templates/web/ $HESTIA/data/templates cp -rf $HESTIA_COMMON_DIR/templates/dns/ $HESTIA/data/templates mkdir -p /var/www/html mkdir -p /var/www/document_errors # Install default success page cp -rf $HESTIA_COMMON_DIR/templates/web/unassigned/index.html /var/www/html/ cp -rf $HESTIA_COMMON_DIR/templates/web/skel/document_errors/* /var/www/document_errors/ # Installing firewall rules cp -rf $HESTIA_COMMON_DIR/firewall $HESTIA/data/ # Installing apis cp -rf $HESTIA_COMMON_DIR/api $HESTIA/data/ # Configuring server hostname $HESTIA/bin/v-change-sys-hostname $servername > /dev/null 2>&1 # Generating SSL certificate echo «[ * ] Generating default self-signed SSL certificate…« if [ «$release« = «18.04« ]; then $HESTIA/bin/v-generate-ssl-cert $(hostname) $email US California San Francisco Hestia Control Panel IT > /tmp/hst.pem else $HESTIA/bin/v-generate-ssl-cert $(hostname) US California San Francisco Hestia Control Panel IT > /tmp/hst.pem fi # Parsing certificate file crt_end=$(grep -n «END CERTIFICATE-« /tmp/hst.pem | cut -f 1 -d:) if [ «$release« = «22.04« ]; then key_start=$(grep -n «BEGIN PRIVATE KEY« /tmp/hst.pem | cut -f 1 -d:) key_end=$(grep -n «END PRIVATE KEY« /tmp/hst.pem | cut -f 1 -d:) else key_start=$(grep -n «BEGIN RSA« /tmp/hst.pem | cut -f 1 -d:) key_end=$(grep -n «END RSA« /tmp/hst.pem | cut -f 1 -d:) fi # Adding SSL certificate echo «[ * ] Adding SSL certificate to Hestia Control Panel…« cd $HESTIA/ssl sed -n «1,${crt_end}p« /tmp/hst.pem > certificate.crt sed -n «$key_start,${key_end}p« /tmp/hst.pem > certificate.key chown root:mail $HESTIA/ssl/* chmod 660 $HESTIA/ssl/* rm /tmp/hst.pem # Install dhparam.pem cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl # Deleting old admin user if [ -n «$(grep ^admin: /etc/passwd)« ] && [ «$force« = yes ]; then chattr -i /home/admin/conf > /dev/null 2>&1 userdel -f admin > /dev/null 2>&1 chattr -i /home/admin/conf > /dev/null 2>&1 mv -f /home/admin $hst_backups/home/ > /dev/null 2>&1 rm -f /tmp/sess_* > /dev/null 2>&1 fi if [ -n «$(grep ^admin: /etc/group)« ] && [ «$force« = yes ]; then groupdel admin > /dev/null 2>&1 fi # Remove sudo «default» sudo permission admin user group should not exists any way sed -i «s/%admin ALL=(ALL) ALL/#%admin ALL=(ALL) ALL/g« /etc/sudoers # Enable sftp jail echo «[ * ] Enable SFTP jail…« $HESTIA/bin/v-add-sys-sftp-jail > /dev/null 2>&1 check_result $? «can’t enable sftp jail« # Adding Hestia admin account echo «[ * ] Create admin account…« $HESTIA/bin/v-add-user admin $vpass $email «system« «System Administrator« check_result $? «can’t create admin user« $HESTIA/bin/v-change-user-shell admin nologin $HESTIA/bin/v-change-user-role admin admin $HESTIA/bin/v-change-user-language admin $lang $HESTIA/bin/v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN yes locale-gen «en_US.utf8« > /dev/null 2>&1 #———————————————————-# # Configure Nginx # #———————————————————-# echo «[ * ] Configuring NGINX…« rm -f /etc/nginx/conf.d/*.conf cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/ cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/ 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/ mkdir -p /etc/nginx/conf.d/domains mkdir -p /etc/nginx/modules-enabled mkdir -p /var/log/nginx/domains # Update dns servers in nginx.conf dns_resolver=$(cat /etc/resolv.conf | grep -i ^nameserver | cut -d -f2 | tr rn | xargs) for ip in $dns_resolver; do if [[ $ip =~ ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$ ]]; then resolver=«$ip $resolver« 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 fi update-rc.d nginx defaults > /dev/null 2>&1 systemctl start nginx >> $LOG check_result $? «nginx start failed« #———————————————————-# # Configure Apache # #———————————————————-# if [ «$apache« = yes ]; then echo «[ * ] Configuring Apache Web Server…« mkdir -p /etc/apache2/conf.d mkdir -p /etc/apache2/conf.d/domains # Copy configuration files cp -f $HESTIA_INSTALL_DIR/apache2/apache2.conf /etc/apache2/ cp -f $HESTIA_INSTALL_DIR/apache2/status.conf /etc/apache2/mods-available/hestia-status.conf 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/ # Enable needed modules a2enmod rewrite > /dev/null 2>&1 a2enmod suexec > /dev/null 2>&1 a2enmod ssl > /dev/null 2>&1 a2enmod actions > /dev/null 2>&1 a2dismod —quiet status > /dev/null 2>&1 a2enmod —quiet hestia-status > /dev/null 2>&1 # Enable mod_ruid/mpm_itk or mpm_event if [ «$phpfpm« = yes ]; then # Disable prefork and php, enable event a2dismod php$fpm_v > /dev/null 2>&1 a2dismod mpm_prefork > /dev/null 2>&1 a2enmod mpm_event > /dev/null 2>&1 cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/ else a2enmod ruid2 > /dev/null 2>&1 fi echo «# Powered by hestia« > /etc/apache2/sites-available/default echo «# Powered by hestia« > /etc/apache2/sites-available/default-ssl echo «# Powered by hestia« > /etc/apache2/ports.conf echo -e «/homenpublic_html/cgi-bin« > /etc/apache2/suexec/www-data touch /var/log/apache2/access.log /var/log/apache2/error.log mkdir -p /var/log/apache2/domains chmod a+x /var/log/apache2 chmod 640 /var/log/apache2/access.log /var/log/apache2/error.log chmod 751 /var/log/apache2/domains # Prevent remote access to server-status page sed -i /Allow from all/d /etc/apache2/mods-available/hestia-status.conf update-rc.d apache2 defaults > /dev/null 2>&1 systemctl start apache2 >> $LOG check_result $? «apache2 start failed« else update-rc.d apache2 disable > /dev/null 2>&1 systemctl stop apache2 > /dev/null 2>&1 fi #———————————————————-# # Configure PHP-FPM # #———————————————————-# if [ «$phpfpm« = «yes« ]; then if [ «$multiphp« = yes ]; then for v in «${multiphp_v[@]}«; do echo «[ * ] Install PHP $v« $HESTIA/bin/v-add-web-php «$v« > /dev/null 2>&1 done else echo «[ * ] Install PHP $fpm_v« $HESTIA/bin/v-add-web-php «$fpm_v« > /dev/null 2>&1 fi echo «[ * ] Configuring PHP-FPM $fpm_v« # Create www.conf for webmail and php(*)admin cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/www.conf update-rc.d php$fpm_v-fpm defaults > /dev/null 2>&1 systemctl start php$fpm_v-fpm >> $LOG check_result $? «php-fpm start failed« # Set default php version to $fpm_v update-alternatives —set php /usr/bin/php$fpm_v > /dev/null 2>&1 fi #———————————————————-# # Configure PHP # #———————————————————-# echo «[ * ] Configuring PHP…« ZONE=$(timedatectl > /dev/null 2>&1 | grep Timezone | awk {print $2}) if [ -z «$ZONE« ]; then ZONE=UTC fi for pconf in $(find /etc/php* -name php.ini); do sed -i «s%;date.timezone =%date.timezone = $ZONE%g« $pconf sed -i s%_open_tag = Off%_open_tag = On%g $pconf done # Cleanup php session files not changed in the last 7 days (60*24*7 minutes) echo #!/bin/sh > /etc/cron.daily/php-session-cleanup echo «find -O3 /home/*/tmp/ -ignore_readdir_race -depth -mindepth 1 -name ‘sess_*’ -type f -cmin ‘+10080’ -delete > /dev/null 2>&1« >> /etc/cron.daily/php-session-cleanup echo «find -O3 $HESTIA/data/sessions/ -ignore_readdir_race -depth -mindepth 1 -name ‘sess_*’ -type f -cmin ‘+10080’ -delete > /dev/null 2>&1« >> /etc/cron.daily/php-session-cleanup chmod 755 /etc/cron.daily/php-session-cleanup #———————————————————-# # Configure Vsftpd # #———————————————————-# if [ «$vsftpd« = yes ]; then echo «[ * ] Configuring Vsftpd server…« cp -f $HESTIA_INSTALL_DIR/vsftpd/vsftpd.conf /etc/ touch /var/log/vsftpd.log chown root:adm /var/log/vsftpd.log chmod 640 /var/log/vsftpd.log touch /var/log/xferlog chown root:adm /var/log/xferlog chmod 640 /var/log/xferlog update-rc.d vsftpd defaults systemctl start vsftpd >> $LOG check_result $? «vsftpd start failed« fi #———————————————————-# # Configure ProFTPD # #———————————————————-# if [ «$proftpd« = yes ]; then echo «[ * ] Configuring ProFTPD server…« echo «127.0.0.1 $servername« >> /etc/hosts cp -f $HESTIA_INSTALL_DIR/proftpd/proftpd.conf /etc/proftpd/ cp -f $HESTIA_INSTALL_DIR/proftpd/tls.conf /etc/proftpd/ if [ «$release« = 22.04 ]; then sed -i s|IdentLookups off|#IdentLookups off|g /etc/proftpd/proftpd.conf fi update-rc.d proftpd defaults > /dev/null 2>&1 systemctl start proftpd >> $LOG check_result $? «proftpd start failed« if [ «$release« = 22.04 ]; then unit_files=«$(systemctl list-unit-files | grep proftpd)« if [[ «$unit_files« =~ «disabled« ]]; then systemctl enable proftpd fi fi fi #———————————————————-# # Configure MariaDB / MySQL # #———————————————————-# if [ «$mysql« = yes ] || [ «$mysqlclassic« = yes ]; then [ «$mysql« = yes ] && mysql_type=«MariaDB« || mysql_type=«MySQL« echo «[ * ] Configuring $mysql_type database server…« mycnf=«my-small.cnf« if [ $memory -gt 1200000 ]; then mycnf=«my-medium.cnf« fi if [ $memory -gt 3900000 ]; then mycnf=«my-large.cnf« fi if [ «$mysql_type« = MariaDB ]; then # Run mysql_install_db mysql_install_db >> $LOG fi # Remove symbolic link rm -f /etc/mysql/my.cnf # Configuring MariaDB cp -f $HESTIA_INSTALL_DIR/mysql/$mycnf /etc/mysql/my.cnf # Switch MariaDB inclusions to the MySQL if [ «$mysql_type« = MySQL ]; then sed -i /query_cache_size/d /etc/mysql/my.cnf sed -i s|mariadb.conf.d|mysql.conf.d|g /etc/mysql/my.cnf fi update-rc.d mysql defaults > /dev/null 2>&1 systemctl start mysql >> $LOG check_result $? «${mysql_type,,} start failed« # Securing MariaDB/MySQL installation mpass=$(gen_pass) echo -e «[client]npassword=’$mpass‘n« > /root/.my.cnf chmod 600 /root/.my.cnf # Alter root password mysql -e «ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘$mpass‘; FLUSH PRIVILEGES;« if [ «$mysql_type« = MariaDB ]; then # Allow mysql access via socket for startup mysql -e «UPDATE mysql.global_priv SET priv=json_set(priv, ‘$.password_last_changed’, UNIX_TIMESTAMP(), ‘$.plugin’, ‘mysql_native_password’, ‘$.authentication_string’, ‘invalid’, ‘$.auth_or’, json_array(json_object(), json_object(‘plugin’, ‘unix_socket’))) WHERE User=’root’;« # Disable anonymous users mysql -e «DELETE FROM mysql.global_priv WHERE User=»;« else mysql -e «ALTER USER ‘root’@’localhost’ IDENTIFIED WITH caching_sha2_password BY ‘$mpass‘;« mysql -e «DELETE FROM mysql.user WHERE User=»;« mysql -e «DELETE FROM mysql.user WHERE User=’root’ AND Host NOT IN (‘localhost’, ‘127.0.0.1’, ‘::1’);« fi # Drop test database mysql -e «DROP DATABASE IF EXISTS test« mysql -e «DELETE FROM mysql.db WHERE Db=’test’ OR Db=’test\_%’« # Flush privileges mysql -e «FLUSH PRIVILEGES;« fi #———————————————————-# # Configure phpMyAdmin # #———————————————————-# # Source upgrade.conf with phpmyadmin versions # shellcheck source=/usr/local/hestia/install/upgrade/upgrade.conf source $HESTIA/install/upgrade/upgrade.conf if [ «$mysql« = yes ] || [ «$mysqlclassic« = yes ]; then # Display upgrade information echo «[ * ] Installing phpMyAdmin version v$pma_v« # Download latest phpmyadmin release wget —retry-connrefused —quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz # Unpack files tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz # Create folders mkdir -p /usr/share/phpmyadmin mkdir -p /etc/phpmyadmin mkdir -p /etc/phpmyadmin/conf.d/ mkdir /usr/share/phpmyadmin/tmp # Configuring Apache2 for PHPMYADMIN if [ «$apache« = yes ]; then touch /etc/apache2/conf.d/phpmyadmin.inc fi # Overwrite old files cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin # Create copy of config file cp -f $HESTIA_INSTALL_DIR/phpmyadmin/config.inc.php /etc/phpmyadmin/ mkdir -p /var/lib/phpmyadmin/tmp chmod 770 /var/lib/phpmyadmin/tmp chown root:www-data /usr/share/phpmyadmin/tmp # Set config and log directory sed -i «s|’configFile’ => ROOT_PATH . ‘config.inc.php’,|’configFile’ => ‘/etc/phpmyadmin/config.inc.php’,|g« /usr/share/phpmyadmin/libraries/vendor_config.php # Create temporary folder and change permission chmod 770 /usr/share/phpmyadmin/tmp chown root:www-data /usr/share/phpmyadmin/tmp # Generate blow fish blowfish=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32) sed -i «s|%blowfish_secret%|$blowfish|« /etc/phpmyadmin/config.inc.php # Clean Up rm -fr phpMyAdmin-$pma_v-all-languages rm -f phpMyAdmin-$pma_v-all-languages.tar.gz write_config_value «DB_PMA_ALIAS« «phpmyadmin« $HESTIA/bin/v-change-sys-db-alias pma «phpmyadmin« # Special thanks to Pavel Galkin (https://skurudo.ru) # https://github.com/skurudo/phpmyadmin-fixer # shellcheck source=/usr/local/hestia/install/deb/phpmyadmin/pma.sh source $HESTIA_INSTALL_DIR/phpmyadmin/pma.sh > /dev/null 2>&1 # limit access to /etc/phpmyadmin/ chown -R root:www-data /etc/phpmyadmin/ chmod -R 640 /etc/phpmyadmin/* chmod 750 /etc/phpmyadmin/conf.d/ fi #———————————————————-# # Configure PostgreSQL # #———————————————————-# if [ «$postgresql« = yes ]; then echo «[ * ] Configuring PostgreSQL database server…« ppass=$(gen_pass) cp -f $HESTIA_INSTALL_DIR/postgresql/pg_hba.conf /etc/postgresql/*/main/ systemctl restart postgresql sudo -iu postgres psql -c «ALTER USER postgres WITH PASSWORD ‘$ppass« > /dev/null 2>&1 # Configuring phpPgAdmin if [ «$apache« = yes ]; then cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.inc fi cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/ write_config_value «DB_PGA_ALIAS« «phppgadmin« $HESTIA/bin/v-change-sys-db-alias pga «phppgadmin« fi #———————————————————-# # Configure Bind # #———————————————————-# if [ «$named« = yes ]; then echo «[ * ] Configuring Bind DNS server…« cp -f $HESTIA_INSTALL_DIR/bind/named.conf /etc/bind/ cp -f $HESTIA_INSTALL_DIR/bind/named.conf.options /etc/bind/ chown root:bind /etc/bind/named.conf chown root:bind /etc/bind/named.conf.options chown bind:bind /var/cache/bind chmod 640 /etc/bind/named.conf chmod 640 /etc/bind/named.conf.options aa-complain /usr/sbin/named > /dev/null 2>&1 echo «/home/** rwm,« >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null if ! grep —quiet lxc /proc/1/environ; then systemctl status apparmor > /dev/null 2>&1 if [ $? -ne 0 ]; then systemctl restart apparmor >> $LOG fi fi if [ «$release« != 18.04 ]; then update-rc.d named defaults systemctl start named else update-rc.d bind9 defaults systemctl start bind9 fi check_result $? «bind9 start failed« # Workaround for OpenVZ/Virtuozzo if [ -e «/proc/vz/veinfo« ] && [ -e «/etc/rc.local« ]; then sed -i «s/^exit 0/service bind9 restartnexit 0/« /etc/rc.local fi fi #———————————————————-# # Configure Exim # #———————————————————-# if [ «$exim« = yes ]; then echo «[ * ] Configuring Exim mail server…« gpasswd -a Debian-exim mail > /dev/null 2>&1 if [ «$release« = «22.04« ]; then # Jammyy uses Exim 4.95 instead but config works with Exim4.94 cp -f $HESTIA_INSTALL_DIR/exim/exim4.conf.4.94.template /etc/exim4/exim4.conf.template else cp -f $HESTIA_INSTALL_DIR/exim/exim4.conf.template /etc/exim4/ fi cp -f $HESTIA_INSTALL_DIR/exim/dnsbl.conf /etc/exim4/ cp -f $HESTIA_INSTALL_DIR/exim/spam-blocks.conf /etc/exim4/ cp -f $HESTIA_INSTALL_DIR/exim/limit.conf /etc/exim4/ cp -f $HESTIA_INSTALL_DIR/exim/system.filter /etc/exim4/ touch /etc/exim4/white-blocks.conf if [ «$spamd« = yes ]; then sed -i «s/#SPAM/SPAM/g« /etc/exim4/exim4.conf.template fi if [ «$clamd« = yes ]; then sed -i «s/#CLAMD/CLAMD/g« /etc/exim4/exim4.conf.template fi chmod 640 /etc/exim4/exim4.conf.template rm -rf /etc/exim4/domains mkdir -p /etc/exim4/domains rm -f /etc/alternatives/mta ln -s /usr/sbin/exim4 /etc/alternatives/mta update-rc.d -f sendmail remove > /dev/null 2>&1 systemctl stop sendmail > /dev/null 2>&1 update-rc.d -f postfix remove > /dev/null 2>&1 systemctl stop postfix > /dev/null 2>&1 update-rc.d exim4 defaults systemctl start exim4 >> $LOG check_result $? «exim4 start failed« fi #———————————————————-# # Configure Dovecot # #———————————————————-# if [ «$dovecot« = yes ]; then echo «[ * ] Configuring Dovecot POP/IMAP mail server…« gpasswd -a dovecot mail > /dev/null 2>&1 cp -rf $HESTIA_COMMON_DIR/dovecot /etc/ cp -f $HESTIA_INSTALL_DIR/logrotate/dovecot /etc/logrotate.d/ rm -f /etc/dovecot/conf.d/15-mailboxes.conf chown -R root:root /etc/dovecot* #Alter config for 2.2 version=$(dovecot —version | cut -f -2 -d .) if [ «$version« = «2.2« ]; then echo «[ * ] Downgrade dovecot config to sync with 2.2 settings« sed -i s|#ssl_dh_parameters_length = 4096|ssl_dh_parameters_length = 4096|g /etc/dovecot/conf.d/10-ssl.conf sed -i s|ssl_dh = </etc/ssl/dhparam.pem|#ssl_dh = </etc/ssl/dhparam.pem|g /etc/dovecot/conf.d/10-ssl.conf sed -i s|ssl_min_protocol = TLSv1.2|ssl_protocols = !SSLv3 !TLSv1 !TLSv1.1|g /etc/dovecot/conf.d/10-ssl.conf fi update-rc.d dovecot defaults systemctl start dovecot >> $LOG check_result $? «dovecot start failed« fi #———————————————————-# # Configure ClamAV # #———————————————————-# if [ «$clamd« = yes ]; then gpasswd -a clamav mail > /dev/null 2>&1 gpasswd -a clamav Debian-exim > /dev/null 2>&1 cp -f $HESTIA_INSTALL_DIR/clamav/clamd.conf /etc/clamav/ update-rc.d clamav-daemon defaults echo -ne «[ * ] Installing ClamAV anti-virus definitions… « /usr/bin/freshclam >> $LOG & BACK_PID=$! spin_i=1 while kill -0 $BACK_PID > /dev/null 2>&1; do printf «b${spinner:spin_i++%${#spinner}:1}« sleep 0.5 done echo systemctl start clamav-daemon >> $LOG check_result $? «clamav-daemon start failed« fi #———————————————————-# # Configure SpamAssassin # #———————————————————-# if [ «$spamd« = yes ]; then echo «[ * ] Configuring SpamAssassin…« update-rc.d spamassassin defaults > /dev/null 2>&1 sed -i «s/ENABLED=0/ENABLED=1/« /etc/default/spamassassin systemctl start spamassassin >> $LOG check_result $? «spamassassin start failed« unit_files=«$(systemctl list-unit-files | grep spamassassin)« if [[ «$unit_files« =~ «disabled« ]]; then systemctl enable spamassassin > /dev/null 2>&1 fi sed -i «s/#CRON=1/CRON=1/« /etc/default/spamassassin fi #———————————————————-# # Configure Fail2Ban # #———————————————————-# if [ «$fail2ban« = yes ]; then echo «[ * ] Configuring fail2ban access monitor…« cp -rf $HESTIA_INSTALL_DIR/fail2ban /etc/ if [ «$dovecot« = no ]; then fline=$(cat /etc/fail2ban/jail.local | grep -n dovecot-iptables -A 2) fline=$(echo «$fline« | grep enabled | tail -n1 | cut -f 1 -d —) sed -i «${fline}s/true/false/« /etc/fail2ban/jail.local fi if [ «$exim« = no ]; then fline=$(cat /etc/fail2ban/jail.local | grep -n exim-iptables -A 2) fline=$(echo «$fline« | grep enabled | tail -n1 | cut -f 1 -d —) sed -i «${fline}s/true/false/« /etc/fail2ban/jail.local fi if [ «$vsftpd« = yes ]; then #Create vsftpd Log File if [ ! -f «/var/log/vsftpd.log« ]; then touch /var/log/vsftpd.log fi fline=$(cat /etc/fail2ban/jail.local | grep -n vsftpd-iptables -A 2) fline=$(echo «$fline« | grep enabled | tail -n1 | cut -f 1 -d —) sed -i «${fline}s/false/true/« /etc/fail2ban/jail.local fi if [ -f /etc/fail2ban/jail.d/defaults-debian.conf ]; then rm -f /etc/fail2ban/jail.d/defaults-debian.conf fi update-rc.d fail2ban defaults # Ubuntu 22.04 doesn’t start F2B by default on boot update-rc.d fail2ban enable systemctl start fail2ban >> $LOG check_result $? «fail2ban start failed« fi # Configuring MariaDB/MySQL host if [ «$mysql« = yes ] || [ «$mysqlclassic« = yes ]; then $HESTIA/bin/v-add-database-host mysql localhost root $mpass fi # Configuring PostgreSQL host if [ «$postgresql« = yes ]; then $HESTIA/bin/v-add-database-host pgsql localhost postgres $ppass fi #———————————————————-# # Install Roundcube # #———————————————————-# # Min requirements Dovecot + Exim + Mysql if ([ «$mysql« == yes ] || [ «$mysqlclassic« == yes ]) && [ «$dovecot« == «yes« ]; then echo «[ * ] Install Roundcube…« $HESTIA/bin/v-add-sys-roundcube write_config_value «WEBMAIL_ALIAS« «webmail« else write_config_value «WEBMAIL_ALIAS« «« write_config_value «WEBMAIL_SYSTEM« «« fi #———————————————————-# # Install Sieve # #———————————————————-# # Min requirements Dovecot + Exim + Mysql + Roundcube if [ «$sieve« = yes ]; then # Folder paths RC_INSTALL_DIR=«/var/lib/roundcube« RC_CONFIG_DIR=«/etc/roundcube« echo «[ * ] Install Sieve…« # dovecot.conf install sed -i «s/namespace/service stats {n unix_listener stats-writer {n group = mailn mode = 0660n user = dovecotn }n}nnnamespace/g« /etc/dovecot/dovecot.conf # dovecot conf files # 10-master.conf sed -i -E -z «s/ }n user = dovecotn}/ }n unix_listener auth-master {n group = mailn mode = 0660n user = dovecotn }n user = dovecotn}/g« /etc/dovecot/conf.d/10-master.conf # 15-lda.conf sed -i «s/#mail_plugins = \$mail_plugins/mail_plugins = $mail_plugins quota sieven auth_socket_path = /var/run/dovecot/auth-master/g« /etc/dovecot/conf.d/15-lda.conf # 20-imap.conf sed -i «s/mail_plugins = quota imap_quota/mail_plugins = quota imap_quota imap_sieve/g« /etc/dovecot/conf.d/20-imap.conf # replace dovecot-sieve config files cp -f $HESTIA_COMMON_DIR/dovecot/sieve/* /etc/dovecot/conf.d # Dovecot default file install echo -e «require [«fileinto«];n# rule:[SPAM]nif header :contains «X-Spam-Flag« «YES« {n fileinto «INBOX.Spam«;n}n« > /etc/dovecot/sieve/default # exim4 install sed -i «s/stransport = local_delivery/ transport = dovecot_virtual_delivery/« /etc/exim4/exim4.conf.template sed -i «s/address_pipe:/dovecot_virtual_delivery:n driver = pipen command = /usr/lib/dovecot/dovecot-lda -e -d $local_part@$domain -f $sender_address -a $original_local_part@$original_domainn delivery_date_addn envelope_to_addn return_path_addn log_output = truen log_defer_output = truen user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/${lookup{$domain}dsearch{/etc/exim4/domains/}}/passwd}}}}n group = mailn return_outputnnaddress_pipe:/g« /etc/exim4/exim4.conf.template # Permission changes chown -R dovecot:mail /var/log/dovecot.log chmod 660 /var/log/dovecot.log if [ -d «/var/lib/roundcube« ]; then # Modify Roundcube config mkdir -p $RC_CONFIG_DIR/plugins/managesieve cp -f $HESTIA_COMMON_DIR/roundcube/plugins/config_managesieve.inc.php $RC_CONFIG_DIR/plugins/managesieve/config.inc.php ln -s $RC_CONFIG_DIR/plugins/managesieve/config.inc.php $RC_INSTALL_DIR/plugins/managesieve/config.inc.php chown -R root:www-data $RC_CONFIG_DIR/ chmod 751 -R $RC_CONFIG_DIR chmod 644 $RC_CONFIG_DIR/*.php chmod 644 $RC_CONFIG_DIR/plugins/managesieve/config.inc.php sed -i «s/’archive’/’archive’, ‘managesieve’/g« $RC_CONFIG_DIR/config.inc.php fi sed -i «s/’archive’/’archive’, ‘managesieve’/g« $RC_CONFIG_DIR/config.inc.php # Restart Dovecot and exim4 systemctl restart dovecot > /dev/null 2>&1 systemctl restart exim4 > /dev/null 2>&1 fi #———————————————————-# # Configure API # #———————————————————-# if [ «$api« = «yes« ]; then # keep legacy api enabled until transition is complete write_config_value «API« «yes« write_config_value «API_SYSTEM« «1« write_config_value «API_ALLOWED_IP« «« else write_config_value «API« «no« write_config_value «API_SYSTEM« «0« write_config_value «API_ALLOWED_IP« «« $HESTIA/bin/v-change-sys-api disable fi #———————————————————-# # Configure File Manager # #———————————————————-# echo «[ * ] Configuring File Manager…« $HESTIA/bin/v-add-sys-filemanager quiet #———————————————————-# # Configure PHPMailer # #———————————————————-# echo «[ * ] Configuring PHP dependencies…« $HESTIA/bin/v-add-sys-dependencies quiet #———————————————————-# # Configure IP # #———————————————————-# # Configuring system IPs $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/) local_ip=$ip # Configuring firewall if [ «$iptables« = yes ]; then $HESTIA/bin/v-update-firewall fi # Get public IP echo «[ * ] Configuring System IP…« pub_ip=$(curl —ipv4 -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 else touch /etc/rc.local fi check_rclocal=$(cat /etc/rc.local | grep «#!«) if [ -z «$check_rclocal« ]; then echo «#!/bin/sh« >> /etc/rc.local fi echo «$HESTIA/bin/v-update-sys-ip« >> /etc/rc.local echo «exit 0« >> /etc/rc.local chmod +x /etc/rc.local systemctl enable rc-local > /dev/null 2>&1 $HESTIA/bin/v-change-sys-ip-nat $ip $pub_ip > /dev/null 2>&1 ip=$pub_ip fi # Configuring libapache2-mod-remoteip if [ «$apache« = yes ] && [ «$nginx« = yes ]; then cd /etc/apache2/mods-available echo «<IfModule mod_remoteip.c>« > remoteip.conf echo « RemoteIPHeader X-Real-IP« >> remoteip.conf if [ «$local_ip« != «127.0.0.1« ] && [ «$pub_ip« != «127.0.0.1« ]; then echo « RemoteIPInternalProxy 127.0.0.1« >> remoteip.conf fi if [ -n «$local_ip« ] && [ «$local_ip« != «$pub_ip« ]; then echo « RemoteIPInternalProxy $local_ip« >> remoteip.conf fi if [ -n «$pub_ip« ]; then echo « RemoteIPInternalProxy $pub_ip« >> remoteip.conf fi echo «</IfModule>« >> remoteip.conf sed -i «s/LogFormat «%h/LogFormat «%a/g« /etc/apache2/apache2.conf a2enmod remoteip >> $LOG systemctl restart apache2 fi # Adding default domain $HESTIA/bin/v-add-web-domain admin $servername $ip check_result $? «can’t create $servername domain« # Adding cron jobs export SCHEDULED_RESTART=«yes« command=«sudo $HESTIA/bin/v-update-sys-queue restart« $HESTIA/bin/v-add-cron-job admin */2 * * * * «$command« systemctl restart cron command=«sudo $HESTIA/bin/v-update-sys-queue daily« $HESTIA/bin/v-add-cron-job admin 10 00 * * * «$command« command=«sudo $HESTIA/bin/v-update-sys-queue disk« $HESTIA/bin/v-add-cron-job admin 15 02 * * * «$command« command=«sudo $HESTIA/bin/v-update-sys-queue traffic« $HESTIA/bin/v-add-cron-job admin 10 00 * * * «$command« command=«sudo $HESTIA/bin/v-update-sys-queue webstats« $HESTIA/bin/v-add-cron-job admin 30 03 * * * «$command« command=«sudo $HESTIA/bin/v-update-sys-queue backup« $HESTIA/bin/v-add-cron-job admin */5 * * * * «$command« command=«sudo $HESTIA/bin/v-backup-users« $HESTIA/bin/v-add-cron-job admin 10 05 * * * «$command« command=«sudo $HESTIA/bin/v-update-user-stats« $HESTIA/bin/v-add-cron-job admin 20 00 * * * «$command« command=«sudo $HESTIA/bin/v-update-sys-rrd« $HESTIA/bin/v-add-cron-job admin */5 * * * * «$command« command=«sudo $HESTIA/bin/v-update-letsencrypt-ssl« min=$(gen_pass 012345 2) hour=$(gen_pass 1234567 1) $HESTIA/bin/v-add-cron-job admin «$min« «$hour« * * * «$command« # Enable automatic updates $HESTIA/bin/v-add-cron-hestia-autoupdate apt # Building initital rrd images $HESTIA/bin/v-update-sys-rrd # Enabling file system quota if [ «$quota« = yes ]; then $HESTIA/bin/v-add-sys-quota fi # Set backend port $HESTIA/bin/v-change-sys-port $port > /dev/null 2>&1 # Create default configuration files $HESTIA/bin/v-update-sys-defaults # Update remaining packages since repositories have changed echo -ne «[ * ] Installing remaining software updates…« apt-get -qq update apt-get -y upgrade >> $LOG & BACK_PID=$! echo # Starting Hestia service update-rc.d hestia defaults systemctl start hestia check_result $? «hestia start failed« chown admin:admin $HESTIA/data/sessions # Create backup folder and set correct permission mkdir -p /backup/ chmod 755 /backup/ # create cronjob to generate ssl echo «@reboot root sleep 10 && rm /etc/cron.d/hestia-ssl && PATH=’/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:’ && /usr/local/hestia/bin/v-add-letsencrypt-host« > /etc/cron.d/hestia-ssl #———————————————————-# # Set hestia.conf default values # #———————————————————-# echo «[ * ] Updating configuration files…« write_config_value «PHPMYADMIN_KEY« «« write_config_value «POLICY_USER_VIEW_SUSPENDED« «no« write_config_value «POLICY_USER_VIEW_LOGS« «yes« write_config_value «POLICY_USER_EDIT_WEB_TEMPLATES« «true« write_config_value «POLICY_USER_EDIT_DNS_TEMPLATES« «yes« write_config_value «POLICY_USER_EDIT_DETAILS« «yes« write_config_value «POLICY_USER_DELETE_LOGS« «yes« write_config_value «POLICY_USER_CHANGE_THEME« «yes« write_config_value «POLICY_SYSTEM_PROTECTED_ADMIN« «no« write_config_value «POLICY_SYSTEM_PASSWORD_RESET« «yes« write_config_value «POLICY_SYSTEM_HIDE_SERVICES« «no« write_config_value «POLICY_SYSTEM_ENABLE_BACON« «no« write_config_value «PLUGIN_APP_INSTALLER« «true« write_config_value «DEBUG_MODE« «no« write_config_value «ENFORCE_SUBDOMAIN_OWNERSHIP« «yes« write_config_value «USE_SERVER_SMTP« «false« write_config_value «SERVER_SMTP_PORT« «« write_config_value «SERVER_SMTP_HOST« «« write_config_value «SERVER_SMTP_SECURITY« «« write_config_value «SERVER_SMTP_USER« «« write_config_value «SERVER_SMTP_PASSWD« «« write_config_value «SERVER_SMTP_ADDR« «« write_config_value «POLICY_CSRF_STRICTNESS« «1« # Add /usr/local/hestia/bin/ to path variable echo if [ «${PATH#*/usr/local/hestia/bin*}» = «$PATH» ]; then . /etc/profile.d/hestia.sh fi >> /root/.bashrc #———————————————————-# # Hestia Access Info # #———————————————————-# # Comparing hostname and IP host_ip=$(host $servername | head -n 1 | awk {print $NF}) if [ «$host_ip« = «$ip« ]; then ip=«$servername« fi echo -e «n« echo «====================================================================« echo -e «n« # Sending notification to admin email echo -e «Congratulations! You have successfully installed Hestia Control Panel on your server. Ready to get started? Log in using the following credentials: Admin URL: https://$ip:$port Username: admin Password: $displaypass Thank you for choosing Hestia Control Panel to power your full stack web server, we hope that you enjoy using it as much as we do! Please feel free to contact us at any time if you have any questions, or if you encounter any bugs or problems: Documentation: https://docs.hestiacp.com/ Forum: https://forum.hestiacp.com/ Discord: https://discord.gg/nXRUZch GitHub: https://www.github.com/hestiacp/hestiacp Note: Automatic updates are enabled by default. If you would like to disable them, please log in and navigate to Server > Updates to turn them off. Help support the Hestia Control Panel project by donating via PayPal: https://www.hestiacp.com/donate Sincerely yours, The Hestia Control Panel development team Made with love & pride by the open-source community around the world. « > $tmpfile send_mail=«$HESTIA/web/inc/mail-wrapper.php« cat $tmpfile | $send_mail -s «Hestia Control Panel« $email # Congrats echo cat $tmpfile rm -f $tmpfile # Add welcome message to notification panel $HESTIA/bin/v-add-user-notification admin Welcome to Hestia Control Panel! <br>You are now ready to begin <a href=»/add/user/»>adding user accounts</a> and <a href=»/add/web/»>domains</a>. For help and assistance, view the <a href=»https://docs.hestiacp.com/» target=»_new»>documentation</a> or visit our <a href=»https://forum.hestiacp.com/» target=»_new»>user forum</a>.<br><br>Please report any bugs or issues via <a href=»https://github.com/hestiacp/hestiacp/issues» target=»_new»><i class=»fab fa-github»></i> GitHub</a>.<br><br><b>Have a wonderful day!</b><br><br><i class=»fas fa-heart icon-red»></i> The Hestia Control Panel development team # Clean-up # Sort final configuration file sort_config_file if [ «$interactive« = yes ]; then echo «[ ! ] IMPORTANT: The system will now reboot to complete the installation process.« read -n 1 -s -r -p «Press any key to continue« reboot else echo «[ ! ] IMPORTANT: You must restart the system before continuing!« fi # EOF
  • Печать

Страницы: [1] 2  Все   Вниз

Тема: NETPLAN, не активируется сетевые настройки после отключения/подключения кабеля  (Прочитано 6399 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
Domitory

Всем форумчанам доброго времени суток!

Столкнулся с непонятной проблемой.

Есть два компьютера. На одном установлена UbuntuServer18 на втором компьютере установлена Kubuntu20.
Эти две машины соединены между собой напрямую пачкордом. Сеть на обоих настроена через Netplan.
Проблема следующая.
Когда включен компьютер с Ubuntu18 и после этого включается компьютер с Kubuntu20 то связь между ними устанавливается.
Если сначала включить компьютер с Kubuntu20 а затем включить компьютер с Ubuntu18 то связь между ними не устанавливается.
На компьютере с Kubuntu20 скидываются настройки сетевой карты и не активируются пока не выполнишь команду sudo netplan apply, после этого соединение работает нормально. 
Также скидываются настройки сетевого интерфейса если при нормально работающей сети между ПК на время отключить и подключить пачкорд.

Что это может быть и как это лечится?

Когда на проблемном компьютере был установлен Kubuntu18 то такой ерунды не происходило.

« Последнее редактирование: 22 Августа 2020, 16:22:17 от Domitory »


Оффлайн
vfiuchcikicshuusrch

посмотри, что происходит с помощью netplan -debug apply
тоже целую неделю борюсь с нетпланом в 20 Ubuntu :(


Оффлайн
Domitory

Создается файл
/run/systemd/network/10-netplan-enp2s0.network

С таким содержимым

[Match]
Name=enp2s0

[Link]
RequiredForOnline=no

[Network]
LinkLocalAddressing=ipv6
Address=192.168.2.110/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Domains=stdds
~             


Пользователь добавил сообщение 22 Августа 2020, 16:23:45:


вот содержимое файла /etc/netplan/01-network-manager-all.yaml

network:
  ethernets:
     wlxc83a35cb2e3f:
         dhcp4: yes
  ethernets:
     enp2s0:
         addresses:
         - 192.168.2.110/24
         gateway4: 192.168.0.1
         nameservers:
            addresses: [8.8.8.8,8.8.4.4]
            search:
            - stdds
         optional: true
  version: 2

« Последнее редактирование: 22 Августа 2020, 22:03:31 от Aleksandru »


Оффлайн
Sly_tom_cat

LinkLocalAddressing=ipv6

как то смущает…. :idiot2:


Оффлайн
vfiuchcikicshuusrch

Domitory,выполни в терминале от рута netplan -debug apply
конфиги никто не просил ещё)


Оффлайн
Domitory

Domitory,выполни в терминале от рута netplan -debug apply
конфиги никто не просил ещё)

Извиняюсь, в предыдущем сообщении не точно написал.
Выполнил netplan -debug apply, создается файл, но он в принципе создается каждый раз и без -debag
/run/systemd/network/10-netplan-enp2s0.network

с содержимым

[Match]
Name=enp2s0

[Link]
RequiredForOnline=no

[Network]
LinkLocalAddressing=ipv6
Address=192.168.2.110/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Domains=stdds
~             


Сетевые настройки поcле команды netplan -debug apply   присваиваются сетевым интерфейсам и сеть работает до первого отключения кабеля ни каких сообщений об ошибках на экран не выводится


Пользователь добавил сообщение 22 Августа 2020, 20:04:58:


    LinkLocalAddressing=ipv6

как то смущает…. :idiot2:

Меня тоже смущает, откуда оно взялось не понимаю.


Пользователь добавил сообщение 22 Августа 2020, 20:47:50:


Мне кажется что не хватает какой то утилиты отвечающей за автоматическое переподключение сетевого интерфейса.
Либо какая та утилита наоборот скидывает сетевые настройки при подключении кабеля.

« Последнее редактирование: 22 Августа 2020, 22:04:29 от Aleksandru »


Оффлайн
vfiuchcikicshuusrch

странно, что ничего не выводится..
у меня выводиться, там как раз и понятно становиться что он делает, а что не делает и почему.


Оффлайн
Domitory

странно, что ничего не выводится..
у меня выводиться, там как раз и понятно становиться что он делает, а что не делает и почему.

Минуса же два нужно указывать перед —debug  :)
Вот вывод после отключения и подключения пачкорда

stdds@stdds-GA-78LMT-S2:~$ sudo netplan --debug apply
** (generate:2887): DEBUG: 00:16:03.894: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:2887): DEBUG: 00:16:03.894: starting new processing pass
** (generate:2887): DEBUG: 00:16:03.895: We have some netdefs, pass them through a final round of validation
** (generate:2887): DEBUG: 00:16:03.895: wlxc83a35cb2e3f: setting default backend to 1
** (generate:2887): DEBUG: 00:16:03.895: Configuration is valid
** (generate:2887): DEBUG: 00:16:03.895: enp2s0: setting default backend to 1
** (generate:2887): DEBUG: 00:16:03.895: Configuration is valid
** (generate:2887): DEBUG: 00:16:03.895: Generating output files..
** (generate:2887): DEBUG: 00:16:03.895: NetworkManager: definition wlxc83a35cb2e3f is not for us (backend 1)
** (generate:2887): DEBUG: 00:16:03.895: NetworkManager: definition enp2s0 is not for us (backend 1)
(generate:2887): GLib-DEBUG: 00:16:03.895: posix_spawn avoided (fd close requested)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:enp2s0 not found in {}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets:
    enp2s0:
      addresses:
      - 192.168.2.110/24
      gateway4: 192.168.0.1
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
        search:
        - stdds
      optional: true
  vlans: {}
  wifis: {}

DEBUG:Skipping non-physical interface: lo
DEBUG:device enp2s0 operstate is up, not changing
DEBUG:Skipping non-physical interface: wlxc83a35cb2e3f
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp2s0
DEBUG:netplan triggering .link rules for wlxc83a35cb2e3f

Правила форума
1.4. Листинги и содержимое текстовых файлов следует добавлять в сообщение с помощью тегов

Показать скрытое содержание
или [code]…[/code], либо прикреплять к сообщению в виде отдельного файла. Длинные гиперссылки следует оформлять при помощи тега [url=]…[/url]

  —Aleksandru

« Последнее редактирование: 22 Августа 2020, 22:05:36 от Aleksandru »


Оффлайн
vfiuchcikicshuusrch

предложение такое, как и сам бы сделал и буду делать — откатывайся на networking. в инете есть статьи как сделать, достаточно просто выглядит.


Оффлайн
Domitory

Да так наверное и сделаю если решения не найдется.
Просто досадно от того что только начал вникать вроде нормально в этот netplan и такая заковыка неприятная.
Он два года работал же нормально.


Оффлайн
vfiuchcikicshuusrch

у меня тоже не было с ним проблем. поставил 20 Ubuntu, т.к. всегда стараюсь новинки осваивать.. и засада на неделю. а время — деньги.


Оффлайн
Domitory

По моему проще временно вернуться на Ubuntu 18 и искать что то более надежно работающее.

Жаль что Ubuntu 20 оказался таким кривым.


Оффлайн
valrust

netplan сам сеть не настраивает, он лишь из конфигурационного файла на языке YAML генерирует настройки для системы управления сетью Systemd-networkd или NetworkManager.

Посмотрите, что творится в логах systemd-networkd, когда отключаете кабель. Запустите команду, потом отключите кабель, а затем подключите его снова.

journalctl -f -u systemd-networkd.service


Оффлайн
Domitory

Посмотрите, что творится в логах systemd-networkd, когда отключаете кабель.

вот что показывает journalctl -f -u systemd-networkd.service

-- Logs begin at Thu 2015-08-20 09:40:00 MSK. --
окт 01 00:05:14 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Link DOWN
окт 01 00:05:14 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Lost carrier
окт 01 00:05:14 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: DHCP lease lost
окт 01 00:05:24 stdds-GA-78LMT-S2 systemd-networkd[386]: wlan0: Interface name change detected, wlan0 has been renamed to wlxc83a35cb2e3f.
окт 01 00:05:25 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Link UP
окт 01 00:05:25 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: IPv6 successfully enabled
окт 01 00:05:26 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Gained carrier
окт 01 00:05:26 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Connected WiFi access point: 10.185.168.257 (1c:bd:b9:ce:38:ec)
окт 01 00:05:27 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: Gained IPv6LL
окт 01 00:05:29 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: DHCPv4 address 192.168.0.5/24 via 192.168.0.1
окт 01 00:08:02 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:04 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier
окт 01 00:08:38 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:41 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier
окт 01 00:08:46 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:48 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier

Вот что заставляет отключаться сетевой интерфейс enp2s0 ?


Пользователь добавил сообщение 30 Сентября 2020, 23:17:58:


А вот что показывает при выполнении команды sudo netplan apply

окт 01 00:08:48 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[386]: wlxc83a35cb2e3f: DHCP lease lost
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd[1]: Stopping Network Service...
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd[1]: systemd-networkd.service: Succeeded.
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd[1]: Stopped Network Service.
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd[1]: Starting Network Service...
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: wlxc83a35cb2e3f: Gained IPv6LL
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: enp2s0: Gained IPv6LL
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: Enumeration completed
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd[1]: Started Network Service.
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: wlxc83a35cb2e3f: Connected WiFi access point: 10.185.168.257 (1c:bd:b9:ce:38:ec)
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: wlxc83a35cb2e3f: IPv6 successfully enabled
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: enp2s0: IPv6 successfully enabled
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: enp2s0: Could not set route: Nexthop has invalid gateway. Network is unreachable
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: enp2s0: Failed
окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: wlxc83a35cb2e3f: DHCPv4 address 192.168.0.5/24 via 192.168.0.1


Пользователь добавил сообщение 30 Сентября 2020, 23:19:05:


Вот содержимое файла /etc/netplan/01-network-manager-all.yaml

network:
  ethernets:
     wlxc83a35cb2e3f:
         dhcp4: yes
# version: 2
#
#network:
  ethernets:
     enp2s0:
         addresses:
         - 192.168.2.110/24
         gateway4: 192.168.0.1
         nameservers:
            addresses: [8.8.8.8,8.8.4.4]
            search:
            - stdds
         optional: true
  version: 2


Пользователь добавил сообщение 30 Сентября 2020, 23:20:44:


Все точно также было настроено в Kubuntu 18 и аналогично настроено на двух других компьютерах с Ubuntu 18 и работает без нареканий.

« Последнее редактирование: 30 Сентября 2020, 23:20:45 от Domitory »


Оффлайн
valrust

окт 01 00:08:02 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:04 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier
окт 01 00:08:38 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:41 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier
окт 01 00:08:46 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Lost carrier
окт 01 00:08:48 stdds-GA-78LMT-S2 systemd-networkd[386]: enp2s0: Gained carrier

Возможно проблема с кабелем.


Пользователь добавил сообщение 01 Октября 2020, 00:07:15:


         addresses:
         — 192.168.2.110/24

У вас локальная сеть включает IP адреса 192.168.2.1 — 192.168.2.254

         gateway4: 192.168.0.1

А шлюз 192.168.0.1 указываете из другой сети. Так не должно быть. Шлюз должен находится в той же сети, возможно должно быть 192.168.2.1.

Поэтому и получаете ошибку.

окт 01 00:13:34 stdds-GA-78LMT-S2 systemd-networkd[3495]: enp2s0: Could not set route: Nexthop has invalid gateway. Network is unreachable

« Последнее редактирование: 01 Октября 2020, 00:09:05 от valrust »


  • Печать

Страницы: [1] 2  Все   Вверх

Troubleshooting networking issues

Networking issues in netplan are commonly caused by incorrect configuration of
the backend in use. Some features may not be supported by the chosen backend.

Always refer to the netplan reference documentation when unsure, features that
are only supported on some backends should be clearly marked as such.

If you think something is a bug, it might well be one. Please don’t hesitate to
report bugs on netplan.

Debugging netplan

  1. Refer to your netplan YAML configuration to know what backend is in use.
    Netplan configuration will be in *.yaml files under /etc/netplan,
    /run/netplan, or /lib/netplan.

  2. Check that the backend configuration was generated correctly for the
    configuration provided in the netplan YAML by comparing the files generated by
    netplan under /run for the backend in use (see below).

  3. Further investigate backend behavior if the issue persists and the
    configuration is as expected. To do this, start the backend in debug mode,
    reproduce the issue, and revise the logs. Identify any missing configuration
    options that need to be added.

  • Debugging issues with the networkd backend
  • Debugging issues with the NetworkManager backend
  1. If all else fails, file a bug in Launchpad.

Debugging issues with the networkd backend

Verify that configuration in /run/systemd/network includes the settings in
your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

addresses: [ 10.10.10.10/24, 10.20.1.1/24 ]

You should find a matching 10-netplan- file for the name of the interface,
which should contain the following lines:

[Network]
Address=10.10.10.10/24
Address=10.20.1.1/24

Along with any other options you may have set. Some of the options may be
written in a different file: each interface may have any of the *.network,
*.netdev or *.link files.

The settings contained in these files are generally pretty self-explanatory,
and are documented in systemd manpages
systemd.network(5),
systemd.netdev(5)
and systemd.link(5).
If the configuration does not match what you expect to see, this is most likely
a bug in netplan. File a bug in Launchpad
about your issue.

If the configuration matches, systemd-networkd may not be able to apply
the configuration correctly. This may happen for a variety of reasons, and
further debugging of systemd-networkd will be required. You may refer to
the Ubuntu DebuggingSystemd page
for more information on how to debug these issues.

Debugging issues with the NetworkManager backend

Verify that configuration in /run/NetworkManager/system-configuration
includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

addresses: [ 10.10.10.10/24, 10.20.1.1/24 ]

You should find a matching netplan- file for the name of the interface,
which should contain the following lines:

[ipv4]
method=manual
address1=10.10.10.10/24
address2=10.20.1.1/24

Along with any other options you may have set. The name of options should be
recognizable, compared to the configuration in your netplan YAML.

If the configuration does not match what you expect to see, this is most likely
a bug in netplan. File a bug in Launchpad
about your issue.

If the configuration matches, NetworkManager may not be able to apply
the configuration correctly. This may happen for a variety of reasons, and
further debugging of NetworkManager will be required. You may refer to
the Ubuntu DebuggingNetworkManager
page for more information on how to debug these issues.

Troubleshooting

Troubleshooting networking issues

Networking issues in netplan are commonly caused by incorrect configuration of the backend in use. Some features may not be supported by the chosen backend.

Always refer to the netplan reference documentation when unsure, features that are only supported on some backends should be clearly marked as such.

If you think something is a bug, it might well be one. Please don’t hesitate to report bugs on netplan.

Debugging netplan

Refer to your netplan YAML configuration to know what backend is in use. Netplan configuration will be in *.yaml files under /etc/netplan, /run/netplan, or /lib/netplan.

Check that the backend configuration was generated correctly for the configuration provided in the netplan YAML by comparing the files generated by netplan under /run for the backend in use (see below).

Further investigate backend behavior if the issue persists and the configuration is as expected. To do this, start the backend in debug mode, reproduce the issue, and revise the logs. Identify any missing configuration options that need to be added.

Debugging issues with the networkd backend

Verify that configuration in /run/systemd/network includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching 10-netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. Some of the options may be written in a different file: each interface may have any of the *.network, *.netdev or *.link files.

The settings contained in these files are generally pretty self-explanatory, and are documented in systemd manpages systemd.network(5), systemd.netdev(5) and systemd.link(5). If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, systemd-networkd may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of systemd-networkd will be required. You may refer to the Ubuntu DebuggingSystemd page for more information on how to debug these issues.

Debugging issues with the NetworkManager backend

Verify that configuration in /run/NetworkManager/system-configuration includes the settings in your netplan YAML.

For instance, if the you have the following addresses: field in YAML:

You should find a matching netplan- file for the name of the interface, which should contain the following lines:

Along with any other options you may have set. The name of options should be recognizable, compared to the configuration in your netplan YAML.

If the configuration does not match what you expect to see, this is most likely a bug in netplan. File a bug in Launchpad about your issue.

If the configuration matches, NetworkManager may not be able to apply the configuration correctly. This may happen for a variety of reasons, and further debugging of NetworkManager will be required. You may refer to the Ubuntu DebuggingNetworkManager page for more information on how to debug these issues.

Источник

Ошибка конфигурации Netplan: «Неверный YAML . не найден ожидаемый ключ».

Я пытаюсь подключиться к Интернету, используя статический IP, но когда я вхожу sudo netplan apply Команда консоль возвращает следующую ошибку:

Как это исправить? Содержание моего 01-netcfg.yaml похоже:

4 ответа

Итак, что касается конкретной ошибки, которую вы получаете, вы потерпели неудачу в базовом синтаксисе YAML и отступе, что является одной из причин netplan жалуется. YAML чрезвычайно ориентирован на отступы для того, как он интерпретирует команды, аргументы конфигурации и т. Д. Вы должны иметь правильные отступы для разбора конфигураций YAML. Сюрприз, вы вообще этого не делаете и нарушаете синтаксис YAML. Вот почему netplan жалуется, потому что вы не предоставляете надлежащую YAML.

Но даже более важно, чем синтаксис YAML, который заставит работать Netplan, у вас есть несколько критических сбоев в конфигурации вашей сети, и вам действительно нужно их исправить независимо от этого. Эти сбои, в частности:

  • 10.0.2.15/64 недопустимый диапазон CIDR IPv4. Приемлемые диапазоны CIDR находятся между /0 (для всех IPv4) и /32 (для одного адреса) для IPv4. Большинство сетей /24 для диапазона CIDR (с этим диапазоном IP, который будет охватывать 10.0.2.1 — 10.0.2.255 как полезное адресное пространство, хотя я бы предположил, .1 это ворота и .255 это широковещательная рассылка, но она может отличаться в вашей сети, поэтому дважды проверьте все значения!). Необходим правильный диапазон CIDR, чтобы система знала, какова ее маска сети и доступное IP-пространство.
  • 10.0.2.0 неправильный адрес шлюза. .0 адрес не является пригодным для использования адресом в IP-подсети, так как обычно он используется только префиксом сети. И так как ваш конфиг netowrk пытается сделать /24 но ужасно терпит неудачу, этот шлюз, вероятно, должен быть 10.0.2.1 — но, опять же, сначала проверьте эти значения у администратора сети.

Итак, исправление отступов и исправление сети, чтобы предположить, что это /24 в зависимости от указанного вами IP-адреса и шлюза ваш YAML должен выглядеть следующим образом с соответствующими отступами. И по сравнению с вашим существующим, вам действительно нужно узнать, как работает отступ.

Источник

Settings in netplan are not applied

Need some advice. I have two network interfaces, I configure separate IP and routes for each.

I press sudo netplan —debug apply and I see that the settings are not being applied to one of the interfaces, what am I doing wrong?

Why to network adapter enp4s0 settings are not applied? Why do the settings for this adapter end up in a different one (enp2s5)?

1 Answer 1

I have the error DEBUG: enp3s0 not found in <> , but i decided to go ahead and leave it as it is. The states structure of the interfaces should determine the presence of a working configuration. And your might want to consider making these changes after a reboot. Workaround: create a running config view for reload and access the views. From the beginning you need to execute the commands to confirm the config and reboot. But before that you need to make sure that the configuration is suitable for this. While searching for this issue, i came across several hints that a similar DEBUG: could be due to a lack of interaction between interfaces. This is the absence of a bridge or tunnel between them. When events are eventually processed, you get a crash because the sender has to reference the dangling pointer of the existence of the bridge or tunnel itself in the netplan config. The sender does not need to know about any of the recipients. The recipient, of course, knows about the sender; at least he knows the type of message that is being sent to him, just like in your previous config, before the reboot, the listener knows about the event to which he should subscribe.

In this case, it should be referred to the fact that using a generator for binary data is a kind of stretch without taking into account. The mechanism for moving from one type to another must be somehow clear (it cannot contain non-printable parts). If your want to have a configuration that can be used to handle binary data or anything else that isn’t pointer related, then sooner or later your will end up with a monster. The generator can do this and will do it readily if the developers did not use warning/error precautions.

sudo netplan —debug generate shows:

The above source code is a simplified partial implementation of my netplan, i am providing it to show more clearly which part is wrong and i want to simplify the answer to solving the problem. I think the main problem is Configuration is valid and it works the way i want. This means that your generator has enabled netdefs truncation without notice. Reading, writing in the yaml config does not cause any problems. This is why i didn’t find a mismatch issue for having no interfaces found in source -_-! The binding is part of a fixed pipeline, so if your want to use it, your need to inherit from another set created after the reload. I want to keep DEBUG: enp4s5 not found in <> as it is, i think it all depends on your definition of emptiness. Use these commands to declare that this code is stripped down but valid:

The conversion to integer is also «reasonably» in the sense that your get a truncated value. Then your look at the errors. If your are using systemd-networkd:

There are hints due to which the error may occur DEBUG: enp3s0 not found in <> , this is due to with the setting Kind = . This means that the wrong assignment resulted in a generator error. Check for this internal error:

A working theory based on the Kind = call stack of calling methods like gre, veth will invalidate the entire scope (including the interaction area) and thus prevent the traffic routing method from failing. At this point, the scene referenced by the element is not initialized (apparently), but mandatory based on:

My workaround is to make the Kind = callable between interfaces and make the source found with the added entry, so depending on your needs this might be an option. To validate the concept design, after reboot, route between interfaces, but at your discretion and ultimately DEBUG: enp3s0 not found in <> will be in the total.

Источник

Unable to apply netplan configuration in ephemeral environment

Affects Status Importance Assigned to Milestone
MAAS

Bug Description

During ephemeral deployments and network validation testing MAAS boots into an Ubuntu ephemeral environment and applies user provided network configuration. Because the system is booting from the standard Ubuntu cloud image[1]. The system boots, cloud-init creates a stock DHCP network config, and MAAS applies custom network configuration when user_data is proceed by cloud-init.

While basic network configuration such as DHCP and setting a static IP address works, bonds[2] and aliases[3] never come up. Additionally netplan apply returns 0 so this is not detected as a failure(LP:1701434).

netplan apply —debug gives no additional information

Related branches

summary: — Ephemeral deployment does not apply bonds
+ Unable to apply netplan configuration in ephemeral environment

A file exists in /run/netplan which marks the PXE boot interface as critical. Removing this file and running netplan apply does not allow a bond to be created.

I reran applying the network configuration with debug mode enabled as follows

systemctl stop systemd-networkd
SYSTEMD_ LOG_LEVEL= debug /lib/systemd/ systemd- networkd

While nothing in particular stood out from the debug output I did see this in journalctl -u systemd-networkd

ul 09 00:37:13 maas-test-2 systemd[1]: Started Network Service.
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: bond0: netdev could not be created: Operation not supported
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: lo: Link is not managed by us
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp1s0: Link is not managed by us
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp2s0: Link is not managed by us
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp3s0: IPv6 successfully enabled
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp2s0: Could not join netdev: No such device
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp2s0: Failed
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp1s0: Could not join netdev: No such device
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp1s0: Failed
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Could not emit changed OperationalState: Transport endpoint is not connected
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp3s0: Gained carrier
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Could not emit changed OperationalState: Transport endpoint is not connected
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: enp3s0: DHCPv4 address 192.168.122.241/24 via 192.168.122.1
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Not connected to system bus, not setting hostname.
Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Could not emit changed OperationalState: Transport endpoint is not connected
Jul 09 00:37:14 maas-test-2 systemd- networkd[ 1734]: enp3s0: Gained IPv6LL
Jul 09 00:37:14 maas-test-2 systemd- networkd[ 1734]: enp3s0: Configured

  • screenlog.0Edit (10.0 KiB, application/octet-stream)

If I remove all files in /run/netplan first I get similar output however enp1s0(boot interface) goes down and never comes back up.

Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Could not emit changed OperationalState: Transport endpoint is not connected

Along with the «could not find netdev» error, as worrying a bit. Could it be that the ephemeral environment doesn’t have everything mounted the way it should?

Is this reproducible in an installed system, ie. outside of the ephemeral environment?

Anyway, this doesn’t look at all like a netplan bug, more like an issue with systemd-networkd; reassigning to the right package.

affects: netplan → systemd
Changed in systemd:
status: New → Incomplete

The config works fine when I use MAAS to deploy the system, I only run into this bug when trying to apply the config in the ephemeral environment. Everything should be mounted properly. Below is what is mounted in the ephemeral environment. Is there a way to get systemd-networkd to tell me exactly what resource is missing?

sysfs on /sys type sysfs (rw,nosuid, nodev,noexec, relatime)
proc on /proc type proc (rw,nosuid, nodev,noexec, relatime)
udev on /dev type devtmpfs (rw,nosuid, relatime, size=988392k, nr_inodes= 247098, mode=755)
devpts on /dev/pts type devpts (rw,nosuid, noexec, relatime, gid=5,mode= 620,ptmxmode= 000)
tmpfs on /run type tmpfs (rw,nosuid, noexec, relatime, size=204104k, mode=755)
/root.tmp.img (deleted) on /media/root-ro type squashfs (ro,relatime)
tmpfs-root on /media/root-rw type tmpfs (rw,relatime)
overlayroot on / type overlay (rw,relatime, lowerdir= /media/ root-ro, upperdir= /media/ root-rw/ overlay, workdir= /media/ root-rw/ overlay- workdir/ _)
copymods on /lib/modules type tmpfs (rw,relatime)
securityfs on /sys/kernel/ security type securityfs (rw,nosuid, nodev,noexec, relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid, nodev,noexec, relatime, size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid, nodev,noexec, mode=755)
cgroup on /sys/fs/ cgroup/ unified type cgroup2 (rw,nosuid, nodev,noexec, relatime)
cgroup on /sys/fs/ cgroup/ systemd type cgroup (rw,nosuid, nodev,noexec, relatime, xattr,name= systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid, nodev,noexec, relatime)
cgroup on /sys/fs/ cgroup/ cpu,cpuacct type cgroup (rw,nosuid, nodev,noexec, relatime, cpu,cpuacct)
cgroup on /sys/fs/ cgroup/ net_cls, net_prio type cgroup (rw,nosuid, nodev,noexec, relatime, net_cls, net_prio)
cgroup on /sys/fs/ cgroup/ perf_event type cgroup (rw,nosuid, nodev,noexec, relatime, perf_event)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid, nodev,noexec, relatime, pids)
cgroup on /sys/fs/ cgroup/ freezer type cgroup (rw,nosuid, nodev,noexec, relatime, freezer)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid, nodev,noexec, relatime, rdma)
cgroup on /sys/fs/ cgroup/ hugetlb type cgroup (rw,nosuid, nodev,noexec, relatime, hugetlb)
cgroup on /sys/fs/ cgroup/ memory type cgroup (rw,nosuid, nodev,noexec, relatime, memory)
cgroup on /sys/fs/ cgroup/ cpuset type cgroup (rw,nosuid, nodev,noexec, relatime, cpuset)
cgroup on /sys/fs/ cgroup/ devices type cgroup (rw,nosuid, nodev,noexec, relatime, devices)
cgroup on /sys/fs/ cgroup/ blkio type cgroup (rw,nosuid, nodev,noexec, relatime, blkio)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime, pagesize= 2M)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/ fuse/connection s type fusectl (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid, nodev,relatime, user_id= 0,group_ id=0,allow_ other)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid, nodev,relatime, size=204100k, mode=700, uid=1000, gid=1000)

After looking some more into this, I noticed two more things that are off:

Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: bond0: netdev could not be created: Operation not supported

^ Operation not supported here is quite weird. I can’t think of a reason why it could happen. Are you using a special kernel there? Is it missing some module that needs to be modprobed (bonding)? What else might make creating a bond UNSUPP?

Also, the other errors:

Jul 09 00:37:13 maas-test-2 systemd- networkd[ 1734]: Could not emit changed OperationalState: Transport endpoint is not connected

Indicate there is no valid connection to the systemd bus. Why would DBUS not be running? This isn’t a question of mountpoints, but at the very least a question of the makeup of the ephemeral environment, for instance, if not all the services are started correctly there.

If you’re in the ephemeral environment, what happens if you run:

Источник

I am running Ubuntu server 20.04.3 LTS on a remote Raspberry Pi 4.
It is connected through WiFi to a remote router (IP 192.168.1.1), and I had configured networking with netplan.
However after some months I decided to change the DNS configuration, i.e. remove my router local DNS and replace it with Cloudflare’s DNS.
So knowing that the yaml file is very sensitive with spaces, the only change I made is to remove the «92» and «68», so the file now is as follows:

$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: true
    wifis:
        wlan0:
            dhcp4: no
            addresses: [192.168.1.12/24]
            gateway4: 192.168.1.1
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]
            access-points:
                "accesspointname":
                    password: "accesspointpassword"
    version: 2

However when I run netplan try, I get the following:

$ sudo netplan try
Job for netplan-wpa-wlan0.service canceled.

An error occurred: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

Reverting.
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

Also sometimes I get the following error instead:

$ sudo netplan try
Job for netplan-wpa-wlan0.service canceled.

An error occurred: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

Reverting.
Job for netplan-wpa-wlan0.service canceled.
Traceback (most recent call last):
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 84, in command_try
    NetplanApply().command_apply(run_generate=True, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 164, in command_apply
    utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services)
  File "/usr/share/netplan/netplan/cli/utils.py", line 131, in systemctl_networkd
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 66, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 95, in command_try
    self.revert()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 118, in revert
    NetplanApply().command_apply(run_generate=False, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 164, in command_apply
    utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services)
  File "/usr/share/netplan/netplan/cli/utils.py", line 131, in systemctl_networkd
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

I want to be very careful with this as I don’t want to be permanently locked out in the case of a network configuration error, as I don’t have local access to fix things if needed (that’s why I ran netplan try.. I’m not sure if I reboot the system if I will be locked out?)
Any suggestions?

Понравилась статья? Поделить с друзьями:
  • Error unable to delimit strings identifiers
  • Error unable to create gui exiting kodi что это
  • Error unable to create gui exiting kodi как исправить
  • Error unable to create appender of type rollingrandomaccessfile
  • Error unable to create a successful tls connection to the ldap masters