4 # InspIRCd -- Internet Relay Chat Daemon
6 # Copyright (C) 2012-2017 Peter Powell <petpow@saberuk.com>
7 # Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 # Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
9 # Copyright (C) 2003, 2006-2008 Craig Edwards <craigedwards@brainbox.cc>
10 # Copyright (C) 2006-2008 Robin Burchell <robin+git@viroteck.net>
11 # Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
12 # Copyright (C) 2007 John Brooks <john.brooks@dereferenced.net>
13 # Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
14 # Copyright (C) 2003-2006 Craig McLure <craig@chatspike.net>
16 # This file is part of InspIRCd. InspIRCd is free software: you can
17 # redistribute it and/or modify it under the terms of the GNU General Public
18 # License as published by the Free Software Foundation, version 2.
20 # This program is distributed in the hope that it will be useful, but WITHOUT
21 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
36 use warnings FATAL => qw(all);
38 use File::Basename qw(basename);
40 use File::Spec::Functions qw(rel2abs);
41 use FindBin qw($RealDir);
42 use Getopt::Long qw(GetOptions);
43 use POSIX qw(getgid getuid);
55 $opt_disable_auto_extras,
56 $opt_disable_interactive,
57 $opt_distribution_label,
71 sub enable_extras (@);
73 sub disable_extras (@);
76 my @opt_disableextras;
78 exit 1 unless GetOptions(
79 'clean' => \&cmd_clean,
81 'update' => \&cmd_update,
83 'binary-dir=s' => \$opt_binary_dir,
84 'config-dir=s' => \$opt_config_dir,
85 'data-dir=s' => \$opt_data_dir,
86 'development' => \$opt_development,
87 'disable-auto-extras' => \$opt_disable_auto_extras,
88 'disable-interactive' => \$opt_disable_interactive,
89 'distribution-label=s' => \$opt_distribution_label,
90 'example-dir=s' => \$opt_example_dir,
92 'log-dir=s' => \$opt_log_dir,
93 'manual-dir=s' => \$opt_manual_dir,
94 'module-dir=s' => \$opt_module_dir,
95 'prefix=s' => \$opt_prefix,
96 'script-dir=s' => \$opt_script_dir,
97 'socketengine=s' => \$opt_socketengine,
98 'system' => \$opt_system,
101 # TODO: when the modulemanager rewrite is done these should be removed.
102 'disable-extras=s@' => \@opt_disableextras,
103 'enable-extras=s@' => \@opt_enableextras,
104 'list-extras' => sub { list_extras; exit 0; },
107 if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) {
108 @opt_enableextras = split /,/, join(',', @opt_enableextras);
109 @opt_disableextras = split /,/, join(',', @opt_disableextras);
110 enable_extras(@opt_enableextras);
111 disable_extras(@opt_disableextras);
113 print "Remember: YOU are responsible for making sure any libraries needed have been installed!\n";
117 our $interactive = !(
120 defined $opt_binary_dir ||
121 defined $opt_config_dir ||
122 defined $opt_data_dir ||
123 defined $opt_development ||
124 defined $opt_disable_auto_extras ||
125 defined $opt_disable_interactive ||
126 defined $opt_distribution_label ||
127 defined $opt_example_dir ||
129 defined $opt_log_dir ||
130 defined $opt_manual_dir ||
131 defined $opt_module_dir ||
132 defined $opt_prefix ||
133 defined $opt_script_dir ||
134 defined $opt_socketengine ||
135 defined $opt_system ||
139 my %version = get_version $opt_distribution_label;
140 print_format "<|BOLD Configuring InspIRCd $version{FULL} on $^O.|>\n";
144 %config = read_config_file(CONFIGURE_CACHE_FILE);
145 run_test CONFIGURE_CACHE_FILE, %config;
146 if (!defined $config{VERSION}) {
147 $config{VERSION} = CONFIGURE_CACHE_VERSION;
148 } elsif ($config{VERSION} != CONFIGURE_CACHE_VERSION) {
149 print_warning "ignoring contents of ${\CONFIGURE_CACHE_FILE} as it was generated by an incompatible version of $0!";
150 %config = ('VERSION', CONFIGURE_CACHE_VERSION);
154 $config{CXX} = find_compiler($config{CXX} // $ENV{CXX});
155 unless ($config{CXX}) {
156 say 'A suitable C++ compiler could not be detected on your system!';
157 unless ($interactive) {
158 say 'Set the CXX environment variable to the path to a C++ compiler binary if this is incorrect.';
161 until ($config{CXX}) {
162 my $compiler_path = prompt_string 1, 'Please enter the path to a C++ compiler binary:', 'c++';
163 $config{CXX} = find_compiler $compiler_path;
166 my %compiler = get_compiler_info($config{CXX});
168 $config{HAS_ARC4RANDOM_BUF} = run_test 'arc4random_buf()', test_file($config{CXX}, 'arc4random_buf.cpp');
169 $config{HAS_CLOCK_GETTIME} = run_test 'clock_gettime()', test_file($config{CXX}, 'clock_gettime.cpp', $^O eq 'darwin' ? undef : '-lrt');
170 $config{HAS_EVENTFD} = run_test 'eventfd()', test_file($config{CXX}, 'eventfd.cpp');
173 push @socketengines, 'epoll' if run_test 'epoll', test_header $config{CXX}, 'sys/epoll.h';
174 push @socketengines, 'kqueue' if run_test 'kqueue', test_file $config{CXX}, 'kqueue.cpp';
175 push @socketengines, 'poll' if run_test 'poll', test_header $config{CXX}, 'poll.h';
176 push @socketengines, 'select';
178 if (defined $opt_socketengine) {
179 unless (grep { $_ eq $opt_socketengine } @socketengines) {
180 my $reason = -f "src/socketengines/socketengine_$opt_socketengine.cpp" ? 'is not available on this platform' : 'does not exist';
181 print_error "The socket engine you requested ($opt_socketengine) $reason!",
182 'Available socket engines are:',
183 map { " * $_" } @socketengines;
186 $config{SOCKETENGINE} = $opt_socketengine // $socketengines[0];
188 if (defined $opt_system) {
189 $config{BASE_DIR} = $opt_prefix // '/var/lib/inspircd';
190 $config{BINARY_DIR} = $opt_binary_dir // '/usr/sbin';
191 $config{CONFIG_DIR} = $opt_config_dir // '/etc/inspircd';
192 $config{DATA_DIR} = $opt_data_dir // '/var/inspircd';
193 $config{EXAMPLE_DIR} = $opt_example_dir // '/usr/share/doc/inspircd';
194 $config{LOG_DIR} = $opt_log_dir // '/var/log/inspircd';
195 $config{MANUAL_DIR} = $opt_manual_dir // '/usr/share/man/man1';
196 $config{MODULE_DIR} = $opt_module_dir // '/usr/lib/inspircd';
197 $config{SCRIPT_DIR} = $opt_script_dir // '/usr/share/inspircd'
199 $config{BASE_DIR} = $opt_prefix // $config{BASE_DIR} // rel2abs 'run';
200 $config{BINARY_DIR} = $opt_binary_dir // $config{BINARY_DIR} // rel2abs $config{BASE_DIR} . '/bin';
201 $config{CONFIG_DIR} = $opt_config_dir // $config{CONFIG_DIR} // rel2abs $config{BASE_DIR} . '/conf';
202 $config{DATA_DIR} = $opt_data_dir // $config{DATA_DIR} // rel2abs $config{BASE_DIR} . '/data';
203 $config{EXAMPLE_DIR} = $opt_example_dir // $config{EXAMPLE_DIR} // $config{CONFIG_DIR} . '/examples';
204 $config{LOG_DIR} = $opt_log_dir // $config{LOG_DIR} // rel2abs $config{BASE_DIR} . '/logs';
205 $config{MANUAL_DIR} = $opt_manual_dir // $config{MANUAL_DIR} // rel2abs $config{BASE_DIR} . '/manuals';
206 $config{MODULE_DIR} = $opt_module_dir // $config{MODULE_DIR} // rel2abs $config{BASE_DIR} . '/modules';
207 $config{SCRIPT_DIR} = $opt_script_dir // $config{SCRIPT_DIR} // $config{BASE_DIR};
210 # Parse --gid=123 or --gid=foo and extract the group id.
212 if (defined $opt_gid) {
213 @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid);
214 print_error "there is no '$opt_gid' group on this system!" unless @group;
216 @group = $opt_system ? getgrnam('irc') : getgrgid($config{GID} // getgid());
217 print_error "you need to specify a group to run as using '--gid [id|name]'!" unless @group;
219 print_warning <<"EOW";
220 You are building as the privileged $group[0] group and have not specified
221 an unprivileged group to run InspIRCd as.
223 This is almost never what you should do. You should probably either create a new
224 unprivileged user/group to build and run as or pass the '--gid [id|name]' flag
225 to specify an unprivileged group to run as.
227 if (!prompt_bool $interactive, "Are you sure you want to build as the $group[0] group?", 0) {
228 say STDERR "If you are sure you want to build as the $group[0] group pass the --gid $group[2] flag." unless $interactive;
233 $config{GROUP} = $group[0];
234 $config{GID} = $group[2];
236 # Parse --uid=123 or --uid=foo and extract the user id.
238 if (defined $opt_uid) {
239 @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid);
240 print_error "there is no '$opt_uid' user on this system!" unless @user;
242 @user = $opt_system ? getpwnam('irc') : getpwuid($config{UID} // getuid());
243 print_error "you need to specify a user to run as using '--uid [id|name]'!" unless @user;
245 print_warning <<"EOW";
246 You are building as the privileged $user[0] user and have not specified
247 an unprivileged user to run InspIRCd as.
249 This is almost never what you should do. You should probably either create a new
250 unprivileged user/group to build and run as or pass the '--uid [id|name]' flag
251 to specify an unprivileged user to run as.
253 if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) {
254 say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive;
259 $config{USER} = $user[0];
260 $config{UID} = $user[2];
262 # Warn the user about clock drifting when running on OpenVZ.
263 if (-e '/proc/user_beancounters' || -e '/proc/vz/vzaquota') {
264 print_warning <<'EOW';
265 You are building InspIRCd inside of an OpenVZ container. If you
266 plan to use InspIRCd in this container then you should make sure that NTP is
267 configured on the Hardware Node. Failure to do so may result in clock drifting!
271 # Warn the user about OpenBSD shipping incredibly broken compilers/linkers.
272 if ($^O eq 'openbsd') {
273 print_warning <<'EOW';
274 You are building InspIRCd on OpenBSD. The C++ compilers and linkers
275 that OpenBSD ship are incredibly broken. You may have strange linker errors
276 and crashes. Please consider using a different OS like FreeBSD/NetBSD instead.
280 # Check that the user actually wants this version.
281 if (defined $version{REAL_LABEL}) {
282 print_warning <<'EOW';
283 You are building a development version. This contains code which has
284 not been tested as heavily and may contain various faults which could seriously
285 affect the running of your server. It is recommended that you use a stable
288 You can obtain the latest stable version from https://www.inspircd.org or by
289 running `<|GREEN git checkout $(git describe --abbrev=0 --tags insp3)|>` if you are
292 if (!prompt_bool $interactive, 'I understand this warning and want to continue anyway.', $opt_development // 0) {
293 say STDERR 'If you understand this warning and still want to continue pass the --development flag.' unless $interactive;
298 # Configure directory settings.
299 my $question = <<"EOQ";
300 Currently, InspIRCd is configured with the following paths:
302 <|BOLD Base:|> $config{BASE_DIR}
303 <|BOLD Binary:|> $config{BINARY_DIR}
304 <|BOLD Config:|> $config{CONFIG_DIR}
305 <|BOLD Data:|> $config{DATA_DIR}
306 <|BOLD Log:|> $config{LOG_DIR}
307 <|BOLD Manual:|> $config{MANUAL_DIR}
308 <|BOLD Module:|> $config{MODULE_DIR}
309 <|BOLD Script:|> $config{SCRIPT_DIR}
311 Do you want to change these settings?
313 if (prompt_bool $interactive, $question, 0) {
314 my $original_base_dir = $config{BASE_DIR};
315 $config{BASE_DIR} = prompt_dir $interactive, 'In what directory do you wish to install the InspIRCd base?', $config{BASE_DIR};
316 foreach my $key (qw(BINARY_DIR CONFIG_DIR DATA_DIR LOG_DIR MANUAL_DIR MODULE_DIR SCRIPT_DIR)) {
317 $config{$key} =~ s/^\Q$original_base_dir\E/$config{BASE_DIR}/;
319 $config{BINARY_DIR} = prompt_dir $interactive, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR};
320 $config{CONFIG_DIR} = prompt_dir $interactive, 'In what directory are configuration files to be stored?', $config{CONFIG_DIR};
321 $config{DATA_DIR} = prompt_dir $interactive, 'In what directory are variable data files to be stored?', $config{DATA_DIR};
322 $config{LOG_DIR} = prompt_dir $interactive, 'In what directory are log files to be stored?', $config{LOG_DIR};
323 $config{MANUAL_DIR} = prompt_dir $interactive, 'In what directory are manual pages to be placed?', $config{MANUAL_DIR};
324 $config{MODULE_DIR} = prompt_dir $interactive, 'In what directory are modules to be placed?', $config{MODULE_DIR};
325 $config{SCRIPT_DIR} = prompt_dir $interactive, 'In what directory are scripts to be placed?', $config{SCRIPT_DIR};
328 # Configure module settings.
330 Currently, InspIRCd is configured to automatically enable all available extra modules.
332 Would you like to enable extra modules manually?
334 if (prompt_bool $interactive, $question, 0) {
335 foreach my $extra (<src/modules/extra/m_*.cpp>) {
336 my $module_name = basename $extra, '.cpp';
337 if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
338 enable_extras "$module_name.cpp";
341 } elsif (!defined $opt_disable_auto_extras) {
342 # TODO: finish modulemanager rewrite and replace this code with:
343 # system './modulemanager', 'enable', '--auto';
345 # Missing: m_ldap, m_regex_stdlib, m_ssl_mbedtls
346 'm_geo_maxmind.cpp' => 'pkg-config --exists libmaxminddb',
347 'm_mysql.cpp' => 'mysql_config --version',
348 'm_pgsql.cpp' => 'pg_config --version',
349 'm_regex_pcre.cpp' => 'pcre-config --version',
350 'm_regex_posix.cpp' => undef,
351 'm_regex_re2.cpp' => 'pkg-config --exists re2',
352 'm_regex_tre.cpp' => 'pkg-config --exists tre',
353 'm_sqlite3.cpp' => 'pkg-config --exists sqlite3',
354 'm_ssl_gnutls.cpp' => 'pkg-config --exists gnutls',
355 'm_ssl_openssl.cpp' => 'pkg-config --exists openssl',
356 'm_sslrehashsignal.cpp' => undef,
358 while (my ($module, $command) = each %modules) {
359 unless (defined $command && system "$command 1>/dev/null 2>/dev/null") {
360 enable_extras $module;
365 # Generate SSL certificates.
367 Would you like to generate a self-signed SSL certificate now? This certificate
368 can be used for testing but <|BOLD should not|> be used on a production network.
370 Note: you can get a <|BOLD free|> CA-signed certificate from Let's Encrypt. See
371 https://letsencrypt.org/getting-started/ for more details.
374 if (<src/modules/m_ssl_*.cpp>) {
375 if (prompt_bool $interactive, $question, $interactive) {
376 system './tools/genssl', 'auto';
379 print_warning <<"EOM";
380 You are building without enabling any SSL modules. This is not
381 recommended as SSL greatly enhances the security and privacy of your IRC server
382 and in a future version will be <|BOLD required|> for linking servers.
384 Please read the following documentation pages on how to enable SSL support:
386 GnuTLS (recommended): https://docs.inspircd.org/3/modules/ssl_gnutls
387 mbedTLS: https://docs.inspircd.org/3/modules/ssl_mbedtls
388 OpenSSL: https://docs.inspircd.org/3/modules/ssl_openssl
392 # Cache the distribution label so that its not lost when --update is run.
393 $config{DISTRIBUTION} = $opt_distribution_label if $opt_distribution_label;
395 write_configure_cache %config;
396 parse_templates \%config, \%compiler, \%version;
398 print_format <<"EOM";
400 Configuration is complete! You have chosen to build with the following settings:
403 <|GREEN Binary:|> $config{CXX}
404 <|GREEN Name:|> $compiler{NAME}
405 <|GREEN Version:|> $compiler{VERSION}
407 <|GREEN Extra Modules:|>
410 for my $file (<src/modules/m_*>) {
411 my $module = basename $file, '.cpp';
412 say " * $module" if -l $file;
415 print_format <<"EOM";
418 <|GREEN Base:|> $config{BASE_DIR}
419 <|GREEN Binary:|> $config{BINARY_DIR}
420 <|GREEN Config:|> $config{CONFIG_DIR}
421 <|GREEN Data:|> $config{DATA_DIR}
422 <|GREEN Example:|> $config{EXAMPLE_DIR}
423 <|GREEN Log:|> $config{LOG_DIR}
424 <|GREEN Manual:|> $config{MANUAL_DIR}
425 <|GREEN Module:|> $config{MODULE_DIR}
426 <|GREEN Script:|> $config{SCRIPT_DIR}
428 <|GREEN Execution Group:|> $config{GROUP} ($config{GID})
429 <|GREEN Execution User:|> $config{USER} ($config{UID})
430 <|GREEN Socket Engine:|> $config{SOCKETENGINE}
432 To build with these settings run '<|GREEN make -j${\get_cpu_count} install|>' now.
436 # Routine to list out the extra/ modules that have been enabled.
437 # Note: when getting any filenames out and comparing, it's important to lc it if the
438 # file system is not case-sensitive (== Epoc, MacOS, OS/2 (incl DOS/DJGPP), VMS, Win32
439 # (incl NetWare, Symbian)). Cygwin may or may not be case-sensitive, depending on
440 # configuration, however, File::Spec does not currently tell us (it assumes Unix behavior).
444 my $srcdir = File::Spec->catdir("src", "modules");
445 my $abs_srcdir = File::Spec->rel2abs($srcdir);
448 opendir $dd, File::Spec->catdir($abs_srcdir, "extra") or die (File::Spec->catdir($abs_srcdir, "extra") . ": $!\n");
449 my @extras = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
452 opendir $dd, $abs_srcdir or die "$abs_srcdir: $!\n";
453 my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
456 my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
458 EXTRA: for my $extra (@extras) {
459 next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
460 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
461 my $abs_source = File::Spec->catfile($abs_srcdir, $extra);
462 next unless ($extra =~ m/\.(cpp|h)$/ || (-d $abs_extra)); # C++ Source/Header, or directory
463 if (-l $abs_source) {
464 # Symlink, is it in the right place?
465 my $targ = readlink($abs_source);
466 my $abs_targ = File::Spec->rel2abs($targ, $abs_srcdir);
467 if ($abs_targ eq $abs_extra) {
468 $extras{$extra} = "\e[32;1menabled\e[0m";
470 $extras{$extra} = sprintf("\e[31;1mwrong symlink target (%s)\e[0m", $abs_targ);
472 } elsif (-e $abs_source) {
473 my ($devext, $inoext) = stat($abs_extra);
474 my ($devsrc, $inosrc, undef, $lnksrc) = stat($abs_source);
476 if ($devsrc == $devext && $inosrc == $inoext) {
477 $extras{$extra} = "\e[32;1menabled\e[0m";
479 $extras{$extra} = sprintf("\e[31;1mwrong hardlink target (%d:%d)\e[0m", $devsrc, $inosrc);
482 open my $extfd, "<", $abs_extra;
483 open my $srcfd, "<", $abs_source;
485 if (scalar(<$extfd>) eq scalar(<$srcfd>)) {
486 $extras{$extra} = "\e[32;1menabled\e[0m";
488 $extras{$extra} = sprintf("\e[31;1mout of synch (re-copy)\e[0m");
492 $extras{$extra} = "\e[33;1mdisabled\e[0m";
495 # Now let's add dependency info
496 for my $extra (keys(%extras)) {
497 next unless $extras{$extra} =~ m/enabled/; # only process enabled extras.
498 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
499 my @deps = split /\s+/, get_directive($abs_extra, 'ModDep', '');
500 for my $dep (@deps) {
501 if (exists($extras{$dep})) {
502 my $ref = \$extras{$dep}; # Take reference.
503 if ($$ref !~ m/needed by/) {
504 # First dependency found.
505 if ($$ref =~ m/enabled/) {
506 $$ref .= " (needed by \e[32;1m$extra\e[0m";
508 $$ref =~ s/\e\[.*?m//g; # Strip out previous coloring. Will be set in bold+red+blink later.
509 $$ref .= " (needed by \e[0;32;1;5m$extra\e[0;31;1;5m";
512 if ($$ref =~ m/enabled/) {
513 $$ref .= ", \e[32;1m$extra\e[0m";
515 $$ref .= ", \e[0;32;1;5m$extra\e[0;31;1;5m";
521 for my $extra (sort {$a cmp $b} keys(%extras)) {
522 my $text = $extras{$extra};
523 if ($text =~ m/needed by/ && $text !~ m/enabled/) {
524 printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? ")" : "");
526 printf "%-*s = %s%s\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
529 return keys(%extras) if wantarray; # Can be used by manage_extras.
532 sub enable_extras (@) {
534 for my $extra (@extras) {
535 my $extrapath = "src/modules/extra/$extra";
536 if (!-e $extrapath) {
537 print STDERR "Cannot enable \e[32;1m$extra\e[0m : No such file or directory in src/modules/extra\n";
540 my $source = "src/modules/$extra";
542 print STDERR "Cannot enable \e[32;1m$extra\e[0m : destination in src/modules exists (might already be enabled?)\n";
545 # Get dependencies, and add them to be processed.
546 my @deps = split /\s+/, get_directive($extrapath, 'ModDep', '');
547 for my $dep (@deps) {
548 next if scalar(grep { $_ eq $dep } (@extras)) > 0; # Skip if we're going to be enabling it anyway.
549 if (!-e "src/modules/$dep" && !-e "include/$dep") {
550 if (-e "src/modules/extra/$dep") {
551 print STDERR "Will also enable extra \e[32;1m$dep\e[0m (needed by \e[32;1m$extra\e[0m)\n";
554 print STDERR "\e[33;1mWARNING:\e[0m module \e[32;1m$extra\e[0m might be missing dependency \e[32;1m$dep\e[0m - YOU are responsible for satisfying it!\n";
558 print "Enabling $extra ... \n";
559 symlink "extra/$extra", $source or print STDERR "$source: Cannot link to 'extra/$extra': $!\n";
563 sub disable_extras (@)
565 opendir my $dd, "src/modules/extra/";
566 my @files = readdir($dd);
569 EXTRA: for my $extra (@extras) {
570 my $extrapath = "src/modules/extra/$extra";
571 my $source = "src/modules/$extra";
572 if (!-e $extrapath) {
573 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Is not an extra\n";
576 if ((! -l $source) || readlink($source) ne "extra/$extra") {
577 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Source is not a link or doesn't refer to the right file. Remove manually if this is in error.\n";
580 # Check if anything needs this.
581 for my $file (@files) {
582 my @deps = split /\s+/, get_directive("src/modules/extra/$file", 'ModDep', '');
583 # File depends on this extra...
584 if (scalar(grep { $_ eq $extra } @deps) > 0) {
585 # And is both enabled and not about to be disabled.
586 if (-e "src/modules/$file" && scalar(grep { $_ eq $file } @extras) < 1) {
587 print STDERR "Cannot disable \e[32;1m$extra\e[0m : is needed by \e[32;1m$file\e[0m\n";
593 print "Disabling $extra ... \n";
594 unlink "src/modules/$extra" or print STDERR "Cannot disable \e[32;1m$extra\e[0m : $!\n";