Skip to content
Snippets Groups Projects
Commit 75eae394 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix confirmation of scripts make scripts not working with cron

parent 0bfccc72
No related branches found
No related tags found
No related merge requests found
......@@ -34,12 +34,6 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
exit(-1);
}
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";
exit(-1);
}
$now=$argv[1];
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
......@@ -49,6 +43,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
// Global variables
$version=DOL_VERSION;
$error=0;
$confirmed=0;
/*
......@@ -59,6 +54,18 @@ $error=0;
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now [-y]\n";
exit(-1);
}
foreach($argv as $key => $val)
{
if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
}
$now=$argv[1];
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
print "\n";
......@@ -77,12 +84,16 @@ print "login=".$conf->global->LDAP_ADMIN_DN."\n";
print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
print "DN target=".$conf->global->LDAP_CONTACT_DN."\n";
print "\n";
print "Press a key to confirm...\n";
$input = trim(fgets(STDIN));
print "Warning, this operation may result in data loss if it failed.\n";
print "Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (! $confirmed)
{
print "Press a key to confirm...\n";
$input = trim(fgets(STDIN));
print "Warning, this operation may result in data loss if it failed.\n";
print "Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
/*
if (! $conf->global->LDAP_CONTACT_ACTIVE)
......
......@@ -43,7 +43,7 @@ $langs->load("main");
// Global variables
$version=DOL_VERSION;
$error=0;
$confirmed=0;
/*
......@@ -55,9 +55,15 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";
print "Usage: $script_file now [-y]\n";
exit(-1);
}
foreach($argv as $key => $val)
{
if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
}
$now=$argv[1];
print "Mails sending disabled (useless in batch mode)\n";
......@@ -78,13 +84,16 @@ print "login=".$conf->global->LDAP_ADMIN_DN."\n";
print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
print "DN target=".$conf->global->LDAP_MEMBER_DN."\n";
print "\n";
print "Press a key to confirm...\n";
$input = trim(fgets(STDIN));
print "Warning, this operation may result in data loss if it failed.\n";
print "Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (! $confirmed)
{
print "Press a key to confirm...\n";
$input = trim(fgets(STDIN));
print "Warning, this operation may result in data loss if it failed.\n";
print "Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
/*
if (! $conf->global->LDAP_MEMBER_ACTIVE)
......
......@@ -48,7 +48,7 @@ $langs->load("errors");
$version=DOL_VERSION;
$error=0;
$forcecommit=0;
$confirmed=0;
/*
......@@ -94,7 +94,7 @@ $required_fields=array_unique(array_values(array_filter($required_fields, "dolVa
if (! isset($argv[2]) || ! is_numeric($argv[2])) {
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost] [-y]\n";
exit(-1);
}
......@@ -103,6 +103,7 @@ foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
}
print "Mails sending disabled (useless in batch mode)\n";
......@@ -139,9 +140,11 @@ if ($typeid <= 0)
}
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (! $confirmed)
{
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
// Load table of correspondence of countries
$hashlib2rowid=array();
......
......@@ -49,6 +49,7 @@ $langs->load("errors");
$version=DOL_VERSION;
$error=0;
$forcecommit=0;
$confirmed=0;
/*
......@@ -73,7 +74,7 @@ $required_fields=array_unique(array_values(array_filter($required_fields, "dolVa
if (! isset($argv[1])) {
//print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
exit(-1);
}
......@@ -82,6 +83,7 @@ foreach($argv as $key => $val)
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
}
print "Mails sending disabled (useless in batch mode)\n";
......@@ -105,9 +107,11 @@ print "commitiferror=".$forcecommit."\n";
print "Mapped LDAP fields=".join(',',$required_fields)."\n";
print "\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (! $confirmed)
{
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
if (empty($conf->global->LDAP_GROUP_DN))
{
......
......@@ -48,7 +48,7 @@ $version=DOL_VERSION;
$error=0;
$forcecommit=0;
$excludeuser=array();
$confirmed=0;
/*
* Main
......@@ -85,7 +85,7 @@ $required_fields = array(
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
if (! isset($argv[1])) {
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
exit(-1);
}
......@@ -94,6 +94,7 @@ foreach($argv as $key => $val)
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
}
print "Mails sending disabled (useless in batch mode)\n";
......@@ -118,9 +119,11 @@ print "excludeuser=".join(',',$excludeuser)."\n";
print "Mapped LDAP fields=".join(',',$required_fields)."\n";
print "\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (! $confirmed)
{
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
}
if (empty($conf->global->LDAP_USER_DN))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment