option('force'); if(!file_exists('/var/lib/asterisk/sounds/ar')){ mkdir('/var/lib/asterisk/sounds/ar'); } if(!file_exists('/var/lib/asterisk/sounds/ar/custom')){ mkdir('/var/lib/asterisk/sounds/ar/custom'); } $sounds_folder = base_path('sounds'); $files_array = [ [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-enter-order-id.wav', 'location' => $sounds_folder.'/ar/custom/ar-enter-order-id.wav', 'db' => [ 'displayname' => 'ar-enter-order-id', 'filename' => 'custom/ar-enter-order-id', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-thank-you.wav', 'location' => $sounds_folder.'/ar/custom/ar-thank-you.wav', 'db' => [ 'displayname' => 'ar-thank-you', 'filename' => 'custom/ar-thank-you', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-thanks-hangup-now.wav', 'location' => $sounds_folder.'/ar/custom/ar-thanks-hangup-now.wav', 'db' => [ 'displayname' => 'ar-thanks-hangup-now', 'filename' => 'custom/ar-thanks-hangup-now', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-followed-by-star.wav', 'location' => $sounds_folder.'/ar/custom/ar-followed-by-star.wav', 'db' => [ 'displayname' => 'ar-followed-by-star', 'filename' => 'custom/ar-followed-by-star', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-enter-id-followed-star.wav', 'location' => $sounds_folder.'/ar/custom/ar-enter-id-followed-star.wav', 'db' => [ 'displayname' => 'ar-enter-id-followed-star', 'filename' => 'custom/ar-enter-id-followed-star', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-enter-id-followed-shebak.wav', 'location' => $sounds_folder.'/ar/custom/ar-enter-id-followed-shebak.wav', 'db' => [ 'displayname' => 'ar-enter-id-followed-shebak', 'filename' => 'custom/ar-enter-id-followed-shebak', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-no-answer.wav', 'location' => $sounds_folder.'/ar/custom/ar-no-answer.wav', 'db' => [ 'displayname' => 'ar-no-answer', 'filename' => 'custom/ar-no-answer', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], [ 'prospect_location' => '/var/lib/asterisk/sounds/ar/custom/ar-number-busy.wav', 'location' => $sounds_folder.'/ar/custom/ar-number-busy.wav', 'db' => [ 'displayname' => 'ar-number-busy', 'filename' => 'custom/ar-number-busy', 'description' => 'Please enter order ID', 'fcode' => '0', 'fcode_pass' => '', 'fcode_lang' => 'ar' ], ], ]; $need_reload = 0; foreach($files_array as $one){ if(file_exists($one['prospect_location']) && !$force){ $this->warn('Skipped -> '.$one['db']['displayname']); continue; } $need_reload = 1; $process = new Process(['cp',$one['location'],$one['prospect_location']]); $process->run(); DB::table('asterisk.recordings')->insert([$one['db']]); $this->warn('Done -> '.$one['db']['displayname']); } if($need_reload || $force){ $this->warn('Reloading dialplan to apply new sounds'); $process = new Process(['fwconsole','reload']); $process->run(); } return 0; } }