-
-if ($interactive)
-{
- # Clear the screen.
- system 'tput', 'clear';
-
- my $revision = get_revision();
- chomp(my $version = `sh src/version.sh`);
-
- # Display Introduction Message..
- print <<"STOP" ;
-Welcome to the \e[1mInspIRCd\e[0m Configuration program! (\e[1minteractive mode\e[0m)
-\e[1mPackage maintainers: Type ./configure --help for non-interactive help\e[0m
-
-*** If you are unsure of any of these values, leave it blank for ***
-*** standard settings that will work, and your server will run ***
-*** using them. Please consult your IRC network admin if in doubt. ***
-
-Press \e[1m<RETURN>\e[0m to accept the default for any option, or enter
-a new value. Please note: You will \e[1mHAVE\e[0m to read the docs
-dir, otherwise you won't have a config file!
-
-Your operating system is: \e[1;32m$^O\e[0m
-STOP
- print "Your InspIRCd version is: \e[1;32m";
- print $revision eq 'release' ? substr($version, 9) : substr($revision, 1);
- print "\e[0m\n\n";
- print "The following compiler has been detected: \e[1;32m$cxx{NAME} $cxx{VERSION}\e[0m ($config{CXX})\n\n";
-
- # Directory Settings..
- my $tmpbase = $config{BASE_DIR};
- $config{BASE_DIR} = prompt_dir(1, 'What directory do you wish to install the InspIRCd base?', $config{BASE_DIR});
- if ($tmpbase ne $config{BASE_DIR}) {
- $config{CONFIG_DIR} = rel2abs($config{BASE_DIR}."/conf");
- $config{MODULE_DIR} = rel2abs($config{BASE_DIR}."/modules");
- $config{DATA_DIR} = rel2abs($config{BASE_DIR}."/data");
- $config{LOG_DIR} = rel2abs($config{BASE_DIR}."/logs");
- $config{BINARY_DIR} = rel2abs($config{BASE_DIR}."/bin");
- }
-
- $config{BINARY_DIR} = prompt_dir(1, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR});
- $config{CONFIG_DIR} = prompt_dir(1, 'In what directory are the configuration files to be stored?', $config{CONFIG_DIR});
- $config{DATA_DIR} = prompt_dir(1, 'In what directory are variable data files to be stored?', $config{DATA_DIR});
- $config{LOG_DIR} = prompt_dir(1, 'In what directory are log files to be stored?', $config{LOG_DIR});
- $config{MODULE_DIR} = prompt_dir(1, 'In what directory are the modules to be placed?', $config{MODULE_DIR});
- $config{BUILD_DIR} = prompt_dir(1, 'In what directory do you want the build to take place?', $config{BUILD_DIR});
-
- my $chose_hiperf = 0;
- if ($config{HAS_KQUEUE}) {
- $config{USE_KQUEUE} = prompt_bool(1, 'Your operating system has support for the high performance kqueue socket engine. Would you like to enable it?', 1);
- if ($config{USE_KQUEUE}) {
- $config{SOCKETENGINE} = "kqueue";
- $chose_hiperf = 1;
- }
- }
- if ($config{HAS_EPOLL}) {
- $config{USE_EPOLL} = prompt_bool(1, 'Your operating system has support for the high performance epoll socket engine. Would you like to enable it?', 1);
- if ($config{USE_EPOLL}) {
- $config{SOCKETENGINE} = "epoll";
- $chose_hiperf = 1;
- }
- }
- if ($config{HAS_PORTS}) {
- $config{USE_PORTS} = prompt_bool(1, 'Your operating system has support for the high performance IOCP socket engine. Would you like to enable it?', 1);
- if ($config{USE_PORTS}) {
- $config{SOCKETENGINE} = "ports";
- $chose_hiperf = 1;
- }
- }
-
- if (!$chose_hiperf && $config{HAS_POLL}) {
- $config{USE_POLL} = prompt_bool(1, 'Your operating system has support for the mid performance poll socket engine. Would you like to enable it?', 1);
- if ($config{USE_POLL}) {
- $config{SOCKETENGINE} = "poll";
- }
- }
- unless ($chose_hiperf || $config{USE_POLL})
- {
- print "No high-performance socket engines are available, or you chose not to enable one. Defaulting to select() engine.\n\n";
- $config{SOCKETENGINE} = "select";
- }
-
- if ($config{HAS_GNUTLS} eq "y" || $config{HAS_OPENSSL} eq "y")
- {
- print "Detected GnuTLS version: \e[1;32m" . $gnutls_ver . "\e[0m\n";
- print "Detected OpenSSL version: \e[1;32m" . $openssl_ver . "\e[0m\n\n";
-
- $config{USE_SSL} = prompt_bool(1, 'One or more SSL libraries detected. Would you like to enable SSL support?', 1);
- if ($config{USE_SSL})
- {
- if ($config{HAS_GNUTLS} eq "y")
- {
- $config{USE_GNUTLS} = prompt_bool(1, 'Would you like to enable SSL with m_ssl_gnutls (recommended)?', 1);
- if ($config{USE_GNUTLS})
- {
- print "Using GnuTLS SSL module.\n\n";
- unlink 'src/modules/m_ssl_gnutls.cpp' if -f 'src/modules/m_ssl_gnutls.cpp';
- symlink "extra/m_ssl_gnutls.cpp", "src/modules/m_ssl_gnutls.cpp" or print STDERR "Symlink failed: $!\n";
- }
- }
-
- if ($config{HAS_OPENSSL} eq "y")
- {
- $config{USE_OPENSSL} = prompt_bool(1, 'Would you like to enable SSL with m_ssl_openssl (recommended)?', 1);
- if ($config{USE_OPENSSL})
- {
- print "Using OpenSSL SSL module.\n\n";
- unlink 'src/modules/m_ssl_openssl.cpp' if -f 'src/modules/m_ssl_openssl.cpp';
- symlink "extra/m_ssl_openssl.cpp", "src/modules/m_ssl_openssl.cpp" or print STDERR "Symlink failed: $!\n";
- }
- }
- }
- }
- else
- {
- print "\nCould not detect OpenSSL or GnuTLS. Make sure pkg-config is installed and\n";
- print "is in your path.\n\n";
+$config{GROUP} = $group[0];
+$config{GID} = $group[2];
+
+# Parse --uid=123 or --uid=foo and extract the user id.
+my @user;
+if (defined $opt_uid) {
+ @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid);
+ print_error "there is no '$opt_uid' user on this system!" unless @user;
+} else {
+ @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;
+}
+$config{USER} = $user[0];
+$config{UID} = $user[2];
+
+# Clear the screen.
+system 'tput', 'clear' if $interactive;
+
+# Check that the user actually wants this version.
+if ($version{LABEL} ne 'release') {
+ 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 http://www.inspircd.org/ or by
+running `git checkout insp20` 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;