--- /dev/null
+<?php
+
+namespace App\Jobs;
+
+use App\Models\FluidbookExternalInstallServer;
+use Cubist\Util\CommandLine\Rsync;
+use Cubist\Util\Files\Files;
+use Cubist\Util\Text;
+
+class HostingUpdate extends Base
+{
+
+ protected static $_data = [
+ //'hosting' => ['host' => 'clockwork.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting', 'ip' => '178.33.250.33'],
+ 'hosting2' => ['host' => 'clockwork.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting2', 'ip' => '213.186.47.100'],
+ //'ushosting' => ['host' => 'kingkong.cubedesigners.com', 'basepath' => '/home/fluidbook/data/hosting', 'ip' => '134.148.91.250'],
+ ];
+
+ public function handle()
+ {
+ foreach (static::$_data as $name => $s) {
+ $this->updateHosting($name, $s);
+ }
+ }
+
+ protected function updateHosting($name, $data)
+ {
+ $d = Files::mkdir(protected_path('hosting/' . $name));
+ $r = Files::mkdir(resource_path('hosting'));
+ $servers = FluidbookExternalInstallServer::withoutGlobalScopes()->where('protocol', $name)->get();
+
+ $updateAll = [];
+
+ copy($r . 'updateall', $d . 'update');
+
+ foreach ($servers as $server) {
+ $s = $d . 'server-' . $server->id;
+ Files::copy($r . 'server', $s);
+ Files::recursiveReplaceStringInDir($s, [
+ '$sid' => $server->id,
+ '$image' => $server->php ? 'php:apache' : 'httpd',
+ '$dockerpath' => $server->php ? '/var/www/html' : '/usr/local/apache2/htdocs',
+ '$domains' => implode(',', Text::explodeNewLines($server->subdomains)),
+ '$hosting' => $name,
+ '$path' => $data['basepath'],
+ ]);
+ $updateAll[] = '/docker/fluidbook-' . $name . '/server-' . $server->id . '/update';
+ }
+
+ Files::recursiveReplaceStringInDir($d, [
+ '$hosting' => $name,
+ '$updateall' => implode("\n", $updateAll),
+ '$ip' => $data['ip']
+ ]);
+
+ chmod($d . 'update', 0755);
+ $rsync = new Rsync($d, 'root@' . $data['host'] . ':/docker/fluidbook-' . $name);
+ $rsync->setMirror(true);
+ $rsync->execute();
+
+
+ }
+}
version: '2'
services:
- nginx-proxy:
+ fluidbook-$hosting-nginx-proxy:
image: nginxproxy/nginx-proxy
container_name: fluidbook-$hosting-proxy
networks:
- fluidbook-$hosting
+ ports:
- "$ip:80:80"
- "$ip:443:443"
volumes:
- ./config/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf:ro
- ./vhosts:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- - ./certs:/etc/nginx/certs
+ - /docker/nginxproxy/certs:/etc/nginx/certs
restart: unless-stopped
- acme-companion:
- image: nginxproxy/acme-companion
- container_name: nginx-proxy-acme
- networks:
- - fluidbook-$hosting
- environment:
- - DEFAULT_EMAIL=vincent@cubedesigners.com
- volumes_from:
- - nginx-proxy
- volumes:
- - ./certs:/etc/nginx/certs:rw
- - ./acme:/etc/acme.sh
- - /var/run/docker.sock:/var/run/docker.sock:ro
-
networks:
fluidbook-$hosting:
external: