public function deploy() { \SSH::into('local')->run(array('cd /var/www/html', 'git pull origin master'), function ($line) { echo $line . PHP_EOL; // outputs server feedback }); }
public function getIndex() { SSH::into('production')->run(array('cd ~/public_html/yorubawebsite', 'git pull origin master'), function ($line) { echo $line . PHP_EOL; // outputs server feedback }); }
public function deploy() { SSH::into('production')->run(array('cd /var/www/html/papayaheaderlabs.WhortleberryMobileBE', 'git pull origin master-starting_jan13'), function ($line) { echo $line . PHP_EOL; // outputs server feedback }); }
public function getIndex() { \SSH::into('production')->run(array('cd ~/sample', 'git pull origin master'), function ($line) { echo $line . PHP_EOL; // outputs server feedback }); //return "Mail Sent !!"; }
/** * Execute the console command. * * @return mixed */ public function fire() { $me = $this; $remote = $this->argument('remote'); $config = app()->config['remote.connections.' . $remote]; $commands = array('cd ' . $config['root'], 'php artisan down', 'git fetch --all', 'git reset --hard origin/master', 'composer install --optimize-autoloader --no-dev', 'php artisan migrate --package=cartalyst/sentry --force', 'php artisan migrate --force', 'grunt build', 'php artisan cache:clear', 'php artisan up'); SSH::into($remote)->run($commands, function ($line) use($me) { $me->info($line); }); $this->info('All done!'); }
/** * This method copies the dhcpd.conf file from storage and then restarts dhcp */ public function deployDhcpConfig() { logThis('Deploying dhcpd.conf'); // The next three lines copies the local dhcpd.conf to the server $localFile = storage_path() . '/app/dhcp/dhcpd.conf'; $remotePath = '/etc/dhcp/dhcpd.conf'; \SSH::into('dhcp_server')->put($localFile, $remotePath); logThis('New dhcpd.conf copied to dhcp server at ' . env('DHCP_SERVER')); // Now let's restart dhcp \SSH::into('dhcp_server')->run(['service isc-dhcp-server restart']); logThis('isc-dhcp-server restarted on dhcp server at ' . env('DHCP_SERVER')); }
/** * Gets a Net_SFTP connection as Laravels SSH doesn't have all the functionality * * @return Net_SFTP connection */ protected function getConnection() { return \SSH::into($this->connectionName)->getGateway()->getConnection(); }
public function dailyBackup($job, $data) { if ($job->attempts() > 3) { $job->delete(); } //################################### select each backup $hosts = Host::where('id', '=', $data["id"])->where('state', '!=', 'disabled')->where('cron', '=', 'yes')->get(array('id', 'parent', 'name', 'host', 'type', 'ssh_login', 'ssh_pwd', 'storage', 'source', 'db_name', 'db_user', 'db_pwd')); foreach ($hosts as $host) { $backup = new Backup(); $backup->host_id = $host["id"]; $backup->hostname = $host["host"]; $backup->type = "cron"; //################################### folders check $dir = $host["storage"] . "/auto/"; if (!is_dir($dir)) { // creating if not exists and setting owner $cmd = "mkdir -p " . $dir . " && chown -R ftpuser:ftpgroup /backups/web " . $dir; exec($cmd); } //##################################### -- //##################################### generating ssh configuration Config::set('remote.connections.runtime.host', $host->host); Config::set('remote.connections.runtime.port', '22'); Config::set('remote.connections.runtime.username', $host->ssh_login); if (!$host->ssh_pwd) { Config::set('remote.connections.runtime.password', ''); Config::set('remote.connections.runtime.key', '/root/.ssh/id_rsa'); } else { Config::set('remote.connections.runtime.password', $host->ssh_pwd); Config::set('remote.connections.runtime.key', ''); } Config::set('remote.connections.runtime.keyphrase', ''); Config::set('remote.connections.runtime.root', '~/'); $dtime = date('d.m.y_H.i'); $FileName = $host->host . "_" . $dtime; $path = $dir . $host->host . "_" . $dtime . ".tar"; $dbpath = $dir . $host->host . "_" . $dtime . ".sql"; //##################################### -- //##################################### backup type: ssh-all if ($host->type == "ssh-all") { SSH::into('runtime')->run(array("tar -cf ~/" . $FileName . ".tar " . $host->source, "mysqldump -u" . $host->db_user . " -p" . $host->db_pwd . " --lock-tables --databases " . $host->db_name . "> ~/" . $FileName . ".sql")); // downloading files SSH::into('runtime')->get($FileName . ".tar", $path); SSH::into('runtime')->get($FileName . ".sql", $dbpath); // continue to local actions if success if (file_exists($dbpath) && file_exists($path)) { // adding sql file to archive exec("tar -rf " . $path . " " . $dbpath); // compressing exec("bzip2 -zfkv9 " . $path); $backup->file = $path . ".bz2"; $backup->total_size = filesize($path . ".bz2"); // cleanup local and remote files SSH::into('runtime')->run(array("rm ~/" . $FileName . ".tar", "rm ~/" . $FileName . ".sql")); $backup->status = "ok"; exec("rm " . $path); exec("rm " . $dbpath); } else { $backup->status = "broken"; } $backup->save(); //##################################### permissions $set_perm = "chown -R ftpuser:ftpgroup /backups/web " . $dir; exec($set_perm); } //##################################### -- //##################################### backup type: ssh-files if ($host->type == "ssh-files") { SSH::into('runtime')->run(array("tar -cf ~/" . $FileName . ".tar " . $host->source)); // downloading files SSH::into('runtime')->get($FileName . ".tar", $path); // continue to local actions if success if (file_exists($path)) { // compressing exec("bzip2 -zfkv9 " . $path); $backup->file = $path . ".bz2"; $backup->total_size = filesize($path . ".bz2"); // cleanup local and remote files SSH::into('runtime')->run(array("rm ~/" . $FileName . ".tar")); $backup->status = "ok"; exec("rm " . $path); } else { $backup->status = "broken"; } //##################################### permissions $set_perm = "chown -R ftpuser:ftpgroup /backups/web " . $dir; exec($set_perm); $backup->save(); } //##################################### -- //##################################### backup type: ssh-db if ($host->type == "ssh-db") { SSH::into('runtime')->run(array("mysqldump -u" . $host->db_user . " -p" . $host->db_pwd . " --lock-tables --databases " . $host->db_name . "> ~/" . $FileName . ".sql", "tar -cf ~/" . $FileName . ".tar " . "~/" . $FileName . ".sql")); // downloading files SSH::into('runtime')->get($FileName . ".tar", $path); // continue to local actions if success if (file_exists($path)) { // compressing exec("bzip2 -zfkv9 " . $path); $backup->file = $path . ".bz2"; $backup->total_size = filesize($path . ".bz2"); // cleanup local and remote files SSH::into('runtime')->run(array("rm ~/" . $FileName . ".tar", "rm ~/" . $FileName . ".sql")); $backup->status = "ok"; exec("rm " . $path); } else { $backup->status = "broken"; } //##################################### permissions $set_perm = "chown -R ftpuser:ftpgroup /backups/web " . $dir; exec($set_perm); $backup->save(); } //##################################### -- } $job->delete(); }