+ @user = $opt_system ? getpwnam('irc') : getpwuid($config{UID} // getuid());
+ print_error "you need to specify a user to run as using '--uid [id|name]'!" unless @user;
+ unless ($user[2]) {
+ print_warning <<"EOW";
+You are building as the privileged $user[0] user and have not specified
+an unprivileged user to run InspIRCd as.
+
+This is almost never what you should do. You should probably either create a new
+unprivileged user/group to build and run as or pass the '--uid [id|name]' flag
+to specify an unprivileged user to run as.
+EOW
+ if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) {
+ # PACKAGERS: You do not need to delete this check. Use `--uid $(id -u)` or `--uid 0` instead.
+ say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive;
+ exit 1;
+ }
+ }
+}
+$config{USER} = $user[0];
+$config{UID} = $user[2];
+
+# Warn the user about clock drifting when running on OpenVZ.
+if (-e '/proc/user_beancounters' || -e '/proc/vz/vzaquota') {
+ print_warning <<'EOW';
+You are building InspIRCd inside of an OpenVZ container. If you
+plan to use InspIRCd in this container then you should make sure that NTP is
+configured on the Hardware Node. Failure to do so may result in clock drifting!
+EOW
+}
+
+# Warn the user about OpenBSD shipping incredibly broken compilers/linkers.
+if ($^O eq 'openbsd') {
+ print_warning <<'EOW';
+You are building InspIRCd on OpenBSD. The C++ compilers and linkers
+that OpenBSD ship are incredibly broken. You may have strange linker errors
+and crashes. Please consider using a different OS like FreeBSD/NetBSD instead.
+EOW
+}
+
+# Warn about Perl versions that will not be supported in the future.
+if ($^V lt 'v5.26.0') {
+ print_warning <<"EOW";
+You are building InspIRCd with Perl $^V. This is very old and will
+not be supported by the next major version of InspIRCd. Please consider updating
+to Perl v5.26 or newer.
+EOW
+}
+
+# Warn about compiler versions that will not be supported in the future.
+my %future_compilers = (
+ AppleClang => version->parse('10.0'),
+ Clang => version->parse('5.0'),
+ GCC => version->parse('7.0'),
+);
+if (exists $future_compilers{$compiler{NAME}} && $compiler{VERSION} lt $future_compilers{$compiler{NAME}}) {
+ print_warning <<"EOW";
+You are building InspIRCd with $compiler{NAME} v$compiler{VERSION}. This is very old and
+will not be supported by the next major version of InspIRCd. Please consider
+updating to $compiler{NAME} v$future_compilers{$compiler{NAME}} or newer.
+EOW
+}
+
+# Check that the user actually wants this version.
+if (defined $version{REAL_LABEL}) {
+ print_warning <<'EOW';
+You are building a development version. This contains code which has
+not been tested as heavily and may contain various faults which could seriously
+affect the running of your server. It is recommended that you use a stable
+version instead.
+
+You can obtain the latest stable version from https://www.inspircd.org or by
+running `<|GREEN git checkout $(git describe --abbrev=0 --tags insp3)|>` if you are
+installing from Git.
+EOW
+ if (!prompt_bool $interactive, 'I understand this warning and want to continue anyway.', $opt_development // 0) {
+ say STDERR 'If you understand this warning and still want to continue pass the --development flag.' unless $interactive;
+ exit 1;
+ }
+}
+
+# Configure directory settings.
+my $question = <<"EOQ";
+Currently, InspIRCd is configured with the following paths:
+
+<|BOLD Binary:|> $config{BINARY_DIR}
+<|BOLD Config:|> $config{CONFIG_DIR}
+<|BOLD Data:|> $config{DATA_DIR}
+<|BOLD Log:|> $config{LOG_DIR}
+<|BOLD Manual:|> $config{MANUAL_DIR}
+<|BOLD Module:|> $config{MODULE_DIR}
+<|BOLD Script:|> $config{SCRIPT_DIR}
+
+Do you want to change these settings?
+EOQ
+if (prompt_bool $interactive, $question, 0) {
+ my $original_base_dir = $config{BASE_DIR};
+ $config{BASE_DIR} = prompt_dir $interactive, 'In what directory do you wish to install the InspIRCd base?', $config{BASE_DIR};
+ for my $key (qw(BINARY_DIR CONFIG_DIR DATA_DIR LOG_DIR MANUAL_DIR MODULE_DIR SCRIPT_DIR)) {
+ $config{$key} =~ s/^\Q$original_base_dir\E/$config{BASE_DIR}/;
+ }
+ $config{BINARY_DIR} = prompt_dir $interactive, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR};
+ $config{CONFIG_DIR} = prompt_dir $interactive, 'In what directory are configuration files to be stored?', $config{CONFIG_DIR};
+ $config{DATA_DIR} = prompt_dir $interactive, 'In what directory are variable data files to be stored?', $config{DATA_DIR};
+ $config{LOG_DIR} = prompt_dir $interactive, 'In what directory are log files to be stored?', $config{LOG_DIR};
+ $config{MANUAL_DIR} = prompt_dir $interactive, 'In what directory are manual pages to be placed?', $config{MANUAL_DIR};
+ $config{MODULE_DIR} = prompt_dir $interactive, 'In what directory are modules to be placed?', $config{MODULE_DIR};
+ $config{SCRIPT_DIR} = prompt_dir $interactive, 'In what directory are scripts to be placed?', $config{SCRIPT_DIR};
+ $config{EXAMPLE_DIR} = $config{CONFIG_DIR} . '/examples';
+ $config{RUNTIME_DIR} = $config{DATA_DIR};
+}
+
+# Configure module settings.
+$question = <<'EOQ';
+Currently, InspIRCd is configured to automatically enable all available extra modules.
+
+Would you like to enable extra modules manually?
+EOQ
+if (prompt_bool $interactive, $question, 0) {
+ for my $extra (<$RealDir/src/modules/extra/m_*.cpp>) {
+ my $module_name = module_shrink $extra;
+ if (prompt_bool $interactive, "Would you like to enable the <|BOLD $module_name|> module?", 0) {
+ enable_extras $module_name;
+ }
+ }
+} elsif (!defined $opt_disable_auto_extras) {
+ my %modules = (
+ 'm_argon2.cpp' => 'pkg-config --exists libargon2',
+ 'm_geo_maxmind.cpp' => 'pkg-config --exists libmaxminddb',
+ 'm_mysql.cpp' => 'mysql_config --version',
+ 'm_pgsql.cpp' => 'pg_config --version',
+ 'm_ldap.cpp' => "echo '#include <ldap.h>' | $config{CXX} -E -",
+ 'm_regex_pcre.cpp' => 'pcre-config --version',
+ 'm_regex_posix.cpp' => undef,
+ 'm_regex_re2.cpp' => 'pkg-config --exists re2',
+ 'm_regex_stdlib.cpp' => "$config{CXX} -o /dev/null -std=c++11 $RealDir/make/test/compiler.cpp",
+ 'm_regex_tre.cpp' => 'pkg-config --exists tre',
+ 'm_sqlite3.cpp' => 'pkg-config --exists sqlite3',
+ 'm_ssl_gnutls.cpp' => 'pkg-config --exists gnutls',
+ 'm_ssl_mbedtls.cpp' => "echo '#include <mbedtls/version.h>' | $config{CXX} -E -",
+ 'm_ssl_openssl.cpp' => 'pkg-config --exists openssl',
+ 'm_sslrehashsignal.cpp' => undef,
+ );
+ while (my ($module, $command) = each %modules) {
+ unless (defined $command && system "$command 1>/dev/null 2>/dev/null") {
+ enable_extras $module;
+ }
+ }
+}
+
+# Generate SSL certificates.
+$question = <<EOQ;
+Would you like to generate a self-signed SSL certificate now? This certificate
+can be used for testing but <|BOLD should not|> be used on a production network.
+
+Note: you can get a <|BOLD free|> CA-signed certificate from Let's Encrypt. See
+https://letsencrypt.org/getting-started/ for more details.
+EOQ
+
+if (<$RealDir/src/modules/m_ssl_*.cpp>) {
+ if (prompt_bool $interactive, $question, $interactive) {
+ create_directory CONFIGURE_DIRECTORY, 0750 or print_error "unable to create ${\CONFIGURE_DIRECTORY}: $!";
+ system './tools/genssl', 'auto', CONFIGURE_DIRECTORY;