--- /dev/null
+<?php
+
+
+$build_path = $argv[1];
+
+$settings = json_decode(file_get_contents(__DIR__."/../default_settings.json"),true);
+$local_settings_path = __DIR__."/../local_settings.json";
+if (file_exists($local_settings_path)) {
+ $local_settings = json_decode(file_get_contents($local_settings_path),true);
+ $settings = array_merge($settings,$local_settings);
+}
+
+foreach(glob(__DIR__."/source/*.php") as $file){
+ if (basename($file) == 'LocalSettings.php'){
+ continue;
+ }
+ copy($file,$build_path."/".basename($file));
+}
+
+
+
+$localSettingsContent = "<?php\ndefine('ALLO_SERVEUR_URL','{$settings['allo_server_url']}');\n";
+
+file_put_contents($build_path."/LocalSettings.php",$localSettingsContent);
+
+
+$zip = new ZipArchive();
+if($zip->open($build_path."/".$settings['agent_zip_name'], ZipArchive::CREATE) !== true) {
+ echo "Impossible de créer le fichier zip {$settings['agent_zip_name']}\n";
+ exit(-1);
+}
+
+foreach(glob($build_path."/*.php") as $file) {
+ $zip->addFile($file,basename($file));
+}
+$zip->close();
+
+foreach(glob($build_path."/*.php") as $file) {
+ unlink($file);
+}
+
+$install_script_content = file_get_contents(__DIR__."/install.php.txt");
+
+$install_content=<<<"INSTALL"
+<?php
+
+define("ALLO_AGENT_URL","{$settings['agent_base_url']}");
+define("ALLO_AGENT_FILENAME","{$settings['agent_zip_name']}");
+define("INSTALLATION_PATH","{$settings['agent_installation_path']}");
+define("PHP_MIN_VERSION","{$settings['agent_min_php_version']}");
+
+$install_script_content
+
+INSTALL;
+
+file_put_contents($build_path."/".$settings['agent_install_script'],$install_content);
+
+
+
+echo "Allo agent succesfully build\n";
+
+exit(0);
\ No newline at end of file