From: kink Date: Wed, 23 Jan 2002 17:08:18 +0000 (+0000) Subject: - Added options to add/remove plugins from the commandline (#467108): X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ebd13f5591c7d74d2d2b390407608b1faa8a5550;p=squirrelmail.git - Added options to add/remove plugins from the commandline (#467108): ./conf.pl --install-plugin ./conf.pl --remove-plugin - Now reports error when saving fails. (#503942) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2220 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/config/conf.pl b/config/conf.pl index 84c9d6e8..562605de 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -268,6 +268,27 @@ if(!$hide_sm_attributions) { $hide_sm_attributions = "false"; } +if ($ARGV[0] eq '--install-plugin') { + print "Activating plugin " . $ARGV[1] + . "\n"; + push @plugins, $ARGV[1]; + save_data(); + exit(0); +} +elsif ($ARGV[0] eq '--remove-plugin') { + print "Removing plugin " . $ARGV[1] + . "\n"; + foreach $plugin (@plugins) { + if ($plugin ne $ARGV[1]) { + push @newplugins, $plugin; + } + } + @plugins = @newplugins; + save_data(); + exit(0); +} + + ##################################################################################### if ($config_use_color == 1) { $WHT = "\x1B[37;1m"; @@ -449,7 +470,6 @@ while (($command ne "q") && ($command ne "Q")) { $menu = 0; } elsif ($command eq "s") { save_data (); - print "Data saved in config.php\n"; print "Press enter to continue..."; $tmp = ; $saved = 1; @@ -1776,154 +1796,159 @@ sub command62 { sub save_data { - $tab = " "; - open (CF, ">config.php"); - - print CF " '$ldap_host[$count]',\n"; - print CF " 'base' => '$ldap_base[$count]'"; - if ($ldap_name[$count]) { - print CF ",\n"; - print CF " 'name' => '$ldap_name[$count]'"; - } - if ($ldap_port[$count]) { - print CF ",\n"; - print CF " 'port' => '$ldap_port[$count]'"; - } - if ($ldap_charset[$count]) { - print CF ",\n"; - print CF " 'charset' => '$ldap_charset[$count]'"; - } - if ($ldap_maxrows[$count]) { - print CF ",\n"; - print CF " 'maxrows' => '$ldap_maxrows[$count]'"; - } - print CF "\n"; - print CF ");\n"; - print CF "\n"; - } - - print CF "/**\n"; - print CF " * Make sure there are no characters after the PHP closing\n"; - print CF " * tag below (including newline characters and whitespace).\n"; - print CF " * Otherwise, that character will cause the headers to be\n"; - print CF " * sent and regular output to begin, which will majorly screw\n"; - print CF " * things up when we try to send more headers later.\n"; - print CF " */\n"; - print CF "?>"; - - close CF; + $tab = " "; + if(open (CF, ">config.php")) + { + print CF " '$ldap_host[$count]',\n"; + print CF " 'base' => '$ldap_base[$count]'"; + if ($ldap_name[$count]) { + print CF ",\n"; + print CF " 'name' => '$ldap_name[$count]'"; + } + if ($ldap_port[$count]) { + print CF ",\n"; + print CF " 'port' => '$ldap_port[$count]'"; + } + if ($ldap_charset[$count]) { + print CF ",\n"; + print CF " 'charset' => '$ldap_charset[$count]'"; + } + if ($ldap_maxrows[$count]) { + print CF ",\n"; + print CF " 'maxrows' => '$ldap_maxrows[$count]'"; + } + print CF "\n"; + print CF ");\n"; + print CF "\n"; + } + + print CF "/**\n"; + print CF " * Make sure there are no characters after the PHP closing\n"; + print CF " * tag below (including newline characters and whitespace).\n"; + print CF " * Otherwise, that character will cause the headers to be\n"; + print CF " * sent and regular output to begin, which will majorly screw\n"; + print CF " * things up when we try to send more headers later.\n"; + print CF " */\n"; + print CF "?>"; + + close CF; + + print "Data saved in config.php\n"; + } else { + print "Error saving config.php: $!\n"; + } } sub set_defaults {