Просмотр исходного кода

Merge branch 'main' into feature/user-roles

Kristan Kenney 5 лет назад
Родитель
Сommit
dbe1c39966

+ 1 - 1
bin/v-restore-user

@@ -277,7 +277,7 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
 
             # Checking backend template
             check_backend_tpl=$(is_backend_template_valid $BACKEND)
-            if [ ! -z "$check_proxy_tpl" ]; then
+            if [ ! -z "$check_backend_tpl" ]; then
                 BACKEND='default'
             fi
 

+ 48 - 0
install/deb/filemanager/filegator/backend/Services/Archiver/Adapters/HestiaZipArchiver.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace Filegator\Services\Archiver\Adapters;
+
+use Filegator\Container\Container;
+use Filegator\Services\Archiver\ArchiverInterface;
+use Filegator\Services\Service;
+use Filegator\Services\Storage\Filesystem as Storage;
+use Filegator\Services\Tmpfs\TmpfsInterface;
+
+
+class HestiaZipArchiver extends ZipArchiver implements Service, ArchiverInterface
+{
+    protected $container;
+
+    public function __construct(TmpfsInterface $tmpfs, Container $container)
+    {
+        $this->tmpfs = $tmpfs;
+        $this->container = $container;
+    }
+
+    public function uncompress(string $source, string $destination, Storage $storage)
+    {
+
+        $auth = $this->container->get('Filegator\Services\Auth\AuthInterface');
+
+        $v_user = basename($auth->user()->getUsername());
+        
+        if(!strlen($v_user)) {
+            return;
+        }
+
+        if(strpos($source, '/home') === false) {
+            $source = "/home/$v_user/" . $source;
+        }
+
+        if(strpos($destination, '/home') === false) {
+            $destination = "/home/$v_user/" . $destination;
+        }
+
+        exec ("sudo /usr/local/hestia/bin/v-extract-fs-archive " .
+            escapeshellarg($v_user)  . " " .
+            escapeshellarg($source) . " " .
+            escapeshellarg($destination)
+        ,$output, $return_var);
+
+    }
+}

+ 5 - 0
install/deb/filemanager/filegator/configuration.php

@@ -42,6 +42,11 @@ $dist_config['services']['Filegator\Services\Storage\Filesystem']['config']['ada
         ]);
     };
 
+$dist_config['services']['Filegator\Services\Archiver\ArchiverInterface'] = [
+    'handler' => '\Filegator\Services\Archiver\Adapters\HestiaZipArchiver',
+    'config' => [],
+];
+
 $dist_config['services']['Filegator\Services\Auth\AuthInterface'] = [
         'handler' => '\Filegator\Services\Auth\Adapters\HestiaAuth',
         'config' => [

+ 56 - 0
web/src/app/WebApp/Installers/Nextcloud/NextcloudSetup.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Nextcloud;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class NextcloudSetup extends BaseSetup {
+
+    protected $appInfo = [ 
+        'name' => 'Nextcloud',
+        'group' => 'cloud',
+        'enabled' => true,
+        'version' => '21.0.0',
+        'thumbnail' => 'nextcloud-thumb.png'
+    ];
+    
+    protected $appname = 'nextcloud';
+    
+    protected $config = [
+        'form' => [
+            'username' => ['value'=>'admin'],
+            'password' => 'password'
+            ],
+        'database' => true,
+        'resources' => [
+            'archive'  => [ 'src' => 'https://download.nextcloud.com/server/releases/nextcloud-21.0.0.tar.bz2' ]
+        ],
+    ];
+    
+    public function install(array $options = null) : bool
+    {
+        parent::install($options);
+        
+        $this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot(".htaccess.txt"), $this->getDocRoot(".htaccess")]);
+        
+        // install nextcloud 
+        $this->appcontext->runUser('v-run-cli-cmd', ['/usr/bin/php',
+            $this->getDocRoot('occ'), 
+            'maintenance:install',
+            '--database mysql',
+            '--database-name '.$this->appcontext->user() . '_' .$options['database_name'],
+            '--database-user '.$this->appcontext->user() . '_' .$options['database_user'],
+            '--database-pass '.$options['database_password'],
+            '--admin-user '.$options['username'],
+            '--admin-pass '.$options['password']
+            ], $status);
+            
+        $this->appcontext->runUser('v-run-cli-cmd',  
+            ['/usr/bin/php',
+                $this->getDocRoot('occ'), 
+                'config:system:set',
+                'trusted_domains 2 --value='.$this->domain
+            ], $status2);
+        return ($status->code === 0 && $status2->code === 0);
+    }
+}

BIN
web/src/app/WebApp/Installers/Nextcloud/nextcloud-thumb.png