Prechádzať zdrojové kódy

Add 全新的安装&更新程序

兔姬桑 2 rokov pred
rodič
commit
483708fda7

+ 0 - 1
.env.example

@@ -50,4 +50,3 @@ MAILGUN_SECRET=
 REDIRECT_HTTPS=true
 BAIDU_APP_AK =
 
-JWT_SECRET=

+ 147 - 0
app/Console/Commands/PanelInstallation.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\User;
+use Artisan;
+use Exception;
+use File;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+
+class PanelInstallation extends Command
+{
+    protected $signature = 'panel:install';
+    protected $description = 'ProxyPanel Installation (面板自主安装)';
+
+    public function handle()
+    {
+        try {
+            $bar = $this->output->createProgressBar(7);
+            $bar->minSecondsBetweenRedraws(0);
+
+            $this->info(PHP_EOL.'   ___                              ___                      _ '.PHP_EOL."  / _ \ _ __   ___  __  __ _   _   / _ \  __ _  _ __    ___ | |".PHP_EOL." / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \  / _ \| |".PHP_EOL.'/ ___/ | |   | (_) | >  < | |_| |/ ___/ | (_| || | | ||  __/| |'.PHP_EOL."\/     |_|    \___/ /_/\_\ \__, |\/      \__,_||_| |_| \___||_|".PHP_EOL.'                           |___/                               '.PHP_EOL);
+
+            $bar->start();
+            $this->line(' 创建.env');
+            if (File::exists(base_path().'/.env')) {
+                $this->error('.env existed | .env已存在');
+                if ($this->confirm('Do you wish to continue by deleting current exist .env file? | 是否删除已存.env文件, 并继续安装?', true)) {
+                    File::delete(base_path().'/.env');
+                } else {
+                    abort(500, 'Installation aborted by user decision. | 安装程序终止');
+                }
+            }
+            if (! copy(base_path().'/.env.example', base_path().'/.env')) {
+                abort(500, 'copy .env.example to .env failed, please check file permissions | 复制环境文件失败,请检查目录权限');
+            }
+            $bar->advance();
+
+            // 设置数据库信息
+            $this->line(' 设置数据库信息');
+            $this->saveToEnv([
+                'DB_HOST'     => $this->ask('请输入数据库地址(默认:localhost)', 'localhost'),
+                'DB_PORT'     => $this->ask('请输入数据库地址(默认:3306)', 3306),
+                'DB_DATABASE' => $this->ask('请输入数据库名'),
+                'DB_USERNAME' => $this->ask('请输入数据库用户名'),
+                'DB_PASSWORD' => $this->ask('请输入数据库密码'),
+            ]);
+            $bar->advance();
+
+            // 设置 app key
+            $this->line(' 设置 app key');
+            Artisan::call('key:generate');
+            $bar->advance();
+
+            // 测试数据库连通性
+            $this->line(' 测试数据库连通性');
+            try {
+                Artisan::call('config:cache');
+                DB::connection()->getPdo();
+            } catch (Exception $e) {
+                File::delete(base_path().'/.env');
+                abort(500, '数据库连接失败'.$e->getMessage());
+            }
+            $bar->advance();
+
+            // 初始化数据库
+            $this->line(' 导入数据库');
+            Artisan::call('migrate --seed');
+            $this->info('数据库导入完成');
+            $bar->advance();
+
+            // 文件夹软连接
+            $this->line(' 建立文件夹软连接');
+            Artisan::call('storage:link');
+            $bar->advance();
+
+            // 设置 管理员基础信息
+            $this->line(' 设置管理员基础信息');
+            $email = '';
+            while (! $email) {
+                $email = $this->ask('Please set your administrator account email address | 请输入[管理员]邮箱 默认: [email protected]', '[email protected]');
+                $this->info('[管理员] 账号:'.$email);
+            }
+            $password = '';
+            while (! $password) {
+                $password = $this->ask('Please set your administrator account password | 请输入[管理员]密码 默认: 123456', '123456');
+                $this->info('[管理员]密码:'.$password);
+            }
+            if (! $this->editAdmin($email, $password)) {
+                abort(500, '管理员账号注册失败,请重试');
+            }
+            $bar->finish();
+            $this->info(' Initial installation Completed! | 初步安装完毕');
+
+            $this->line(PHP_EOL.'View your http(s)://[website url]/admin to insert Administrator Dashboard | 访问 http(s)://[你的站点]/admin 进入管理面板');
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+
+        return 0;
+    }
+
+    private function saveToEnv($data = [])
+    {
+        function set_env_var($key, $value): bool
+        {
+            if (! is_bool(strpos($value, ' '))) {
+                $value = '"'.$value.'"';
+            }
+            $key = strtoupper($key);
+
+            $envPath = app()->environmentFilePath();
+            $contents = file_get_contents($envPath);
+
+            preg_match("/^{$key}=[^\r\n]*/m", $contents, $matches);
+
+            $oldValue = count($matches) ? $matches[0] : '';
+
+            if ($oldValue) {
+                $contents = str_replace((string) ($oldValue), "{$key}={$value}", $contents);
+            } else {
+                $contents .= "\n{$key}={$value}\n";
+            }
+
+            $file = fopen($envPath, 'wb');
+            fwrite($file, $contents);
+
+            return fclose($file);
+        }
+
+        foreach ($data as $key => $value) {
+            set_env_var($key, $value);
+        }
+
+        return true;
+    }
+
+    private function editAdmin($email, $password)
+    {
+        $user = User::find(1);
+        $user->username = $email;
+        $user->password = $password;
+
+        return $user->save();
+    }
+}

+ 60 - 0
app/Console/Commands/PanelUpdate.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Artisan;
+use Exception;
+use Illuminate\Console\Command;
+
+class PanelUpdate extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'panel:update';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'ProxyPanel Version Update (面板更新)';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        try {
+            $bar = $this->output->createProgressBar(2);
+            $bar->minSecondsBetweenRedraws(0);
+            $this->info('   ___                              ___                      _ '.PHP_EOL."  / _ \ _ __   ___  __  __ _   _   / _ \  __ _  _ __    ___ | |".PHP_EOL." / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \  / _ \| |".PHP_EOL.'/ ___/ | |   | (_) | >  < | |_| |/ ___/ | (_| || | | ||  __/| |'.PHP_EOL."\/     |_|    \___/ /_/\_\ \__, |\/      \__,_||_| |_| \___||_|".PHP_EOL.'                           |___/                               '.PHP_EOL);
+            $bar->start();
+            $this->line(' 更新数据库...');
+            Artisan::call('migrate --force');
+            $bar->advance();
+            $this->line(' 更新缓存...');
+            Artisan::call('optimize');
+            $bar->finish();
+            $this->info(' 更新完毕! ');
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+
+        return 0;
+    }
+}

+ 1 - 1
app/Http/Middleware/isForbidden.php

@@ -22,7 +22,7 @@ class isForbidden
     {
         // 拒绝机器人访问
         if (sysConfig('is_forbid_robot') && Agent::isRobot()) {
-            Log::warning('识别到机器人访问('.IP::getClientIp().')');
+            Log::warning('识别到机器人('.IP::getClientIp().')访问');
 
             return Response::view('auth.error', ['message' => trans('errors.forbidden.bots')], 403);
         }

+ 1 - 12
app/Models/User.php

@@ -11,12 +11,11 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
 use Illuminate\Notifications\Notifiable;
 use Kyslik\ColumnSortable\Sortable;
 use Spatie\Permission\Traits\HasRoles;
-use Tymon\JWTAuth\Contracts\JWTSubject;
 
 /**
  * 用户信息.
  */
-class User extends Authenticatable implements JWTSubject
+class User extends Authenticatable
 {
     use Notifiable, HasRoles, Sortable;
 
@@ -324,16 +323,6 @@ class User extends Authenticatable implements JWTSubject
         return $this->hasMany(Order::class);
     }
 
-    public function getJWTIdentifier()
-    {
-        return $this->getKey();
-    }
-
-    public function getJWTCustomClaims()
-    {
-        return [];
-    }
-
     public function routeNotificationForTelegram()
     {
         return $this->telegram_user_id;

+ 2 - 1
app/Providers/AppServiceProvider.php

@@ -13,6 +13,7 @@ use App\Observers\OrderObserver;
 use App\Observers\UserGroupObserver;
 use App\Observers\UserObserver;
 use DB;
+use File;
 use Illuminate\Support\ServiceProvider;
 use Schema;
 use URL;
@@ -31,7 +32,7 @@ class AppServiceProvider extends ServiceProvider
             $this->app->register(TelescopeServiceProvider::class);
             $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
         }
-        if (Schema::hasTable('config') && DB::table('config')->exists()) {
+        if (File::exists(base_path().'/.env') && Schema::hasTable('config') && DB::table('config')->exists()) {
             $this->app->register(SettingServiceProvider::class);
         }
     }

+ 1 - 2
composer.json

@@ -28,6 +28,7 @@
     "laravel-notification-channels/bearychat": "^1.4",
     "laravel-notification-channels/telegram": "^0.5",
     "laravel/framework": "^7.30",
+    "laravel/sanctum": "^2.15",
     "laravel/socialite": "^5.2",
     "laravel/tinker": "^2.6",
     "mews/captcha": "^3.2",
@@ -40,7 +41,6 @@
     "srmklive/paypal": "^1.8",
     "stripe/stripe-php": "^7.69",
     "symfony/yaml": "^5.2",
-    "tymon/jwt-auth": "^1.0",
     "xhat/payjs": "^1.5",
     "zbrettonye/geetest": "^1.2",
     "zbrettonye/hcaptcha": "^1.1",
@@ -48,7 +48,6 @@
     "zoujingli/ip2region": "^1.0"
   },
   "require-dev": {
-    "arcanedev/laravel-lang": "^8.0",
     "barryvdh/laravel-debugbar": "^3.4",
     "barryvdh/laravel-ide-helper": "^2.8",
     "facade/ignition": "^2.0",

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 143 - 511
composer.lock


+ 1 - 1
config/auth.php

@@ -42,7 +42,7 @@ return [
         ],
 
         'api' => [
-            'driver' => 'jwt',
+            'driver' => 'token',
             'provider' => 'users',
             'hash' => false,
         ],

+ 0 - 304
config/jwt.php

@@ -1,304 +0,0 @@
-<?php
-
-/*
- * This file is part of jwt-auth.
- *
- * (c) Sean Tymon <[email protected]>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-return [
-
-    /*
-    |--------------------------------------------------------------------------
-    | JWT Authentication Secret
-    |--------------------------------------------------------------------------
-    |
-    | Don't forget to set this in your .env file, as it will be used to sign
-    | your tokens. A helper command is provided for this:
-    | `php artisan jwt:secret`
-    |
-    | Note: This will be used for Symmetric algorithms only (HMAC),
-    | since RSA and ECDSA use a private/public key combo (See below).
-    |
-    */
-
-    'secret' => env('JWT_SECRET'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | JWT Authentication Keys
-    |--------------------------------------------------------------------------
-    |
-    | The algorithm you are using, will determine whether your tokens are
-    | signed with a random string (defined in `JWT_SECRET`) or using the
-    | following public & private keys.
-    |
-    | Symmetric Algorithms:
-    | HS256, HS384 & HS512 will use `JWT_SECRET`.
-    |
-    | Asymmetric Algorithms:
-    | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
-    |
-    */
-
-    'keys' => [
-
-        /*
-        |--------------------------------------------------------------------------
-        | Public Key
-        |--------------------------------------------------------------------------
-        |
-        | A path or resource to your public key.
-        |
-        | E.g. 'file://path/to/public/key'
-        |
-        */
-
-        'public' => env('JWT_PUBLIC_KEY'),
-
-        /*
-        |--------------------------------------------------------------------------
-        | Private Key
-        |--------------------------------------------------------------------------
-        |
-        | A path or resource to your private key.
-        |
-        | E.g. 'file://path/to/private/key'
-        |
-        */
-
-        'private' => env('JWT_PRIVATE_KEY'),
-
-        /*
-        |--------------------------------------------------------------------------
-        | Passphrase
-        |--------------------------------------------------------------------------
-        |
-        | The passphrase for your private key. Can be null if none set.
-        |
-        */
-
-        'passphrase' => env('JWT_PASSPHRASE'),
-
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | JWT time to live
-    |--------------------------------------------------------------------------
-    |
-    | Specify the length of time (in minutes) that the token will be valid for.
-    | Defaults to 1 hour.
-    |
-    | You can also set this to null, to yield a never expiring token.
-    | Some people may want this behaviour for e.g. a mobile app.
-    | This is not particularly recommended, so make sure you have appropriate
-    | systems in place to revoke the token if necessary.
-    | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
-    |
-    */
-
-    'ttl' => env('JWT_TTL', 60),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Refresh time to live
-    |--------------------------------------------------------------------------
-    |
-    | Specify the length of time (in minutes) that the token can be refreshed
-    | within. I.E. The user can refresh their token within a 2 week window of
-    | the original token being created until they must re-authenticate.
-    | Defaults to 2 weeks.
-    |
-    | You can also set this to null, to yield an infinite refresh time.
-    | Some may want this instead of never expiring tokens for e.g. a mobile app.
-    | This is not particularly recommended, so make sure you have appropriate
-    | systems in place to revoke the token if necessary.
-    |
-    */
-
-    'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
-
-    /*
-    |--------------------------------------------------------------------------
-    | JWT hashing algorithm
-    |--------------------------------------------------------------------------
-    |
-    | Specify the hashing algorithm that will be used to sign the token.
-    |
-    | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
-    | for possible values.
-    |
-    */
-
-    'algo' => env('JWT_ALGO', 'HS256'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Required Claims
-    |--------------------------------------------------------------------------
-    |
-    | Specify the required claims that must exist in any token.
-    | A TokenInvalidException will be thrown if any of these claims are not
-    | present in the payload.
-    |
-    */
-
-    'required_claims' => [
-        'iss',
-        'iat',
-        'exp',
-        'nbf',
-        'sub',
-        'jti',
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Persistent Claims
-    |--------------------------------------------------------------------------
-    |
-    | Specify the claim keys to be persisted when refreshing a token.
-    | `sub` and `iat` will automatically be persisted, in
-    | addition to the these claims.
-    |
-    | Note: If a claim does not exist then it will be ignored.
-    |
-    */
-
-    'persistent_claims' => [
-        // 'foo',
-        // 'bar',
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Lock Subject
-    |--------------------------------------------------------------------------
-    |
-    | This will determine whether a `prv` claim is automatically added to
-    | the token. The purpose of this is to ensure that if you have multiple
-    | authentication models e.g. `App\User` & `App\OtherPerson`, then we
-    | should prevent one authentication request from impersonating another,
-    | if 2 tokens happen to have the same id across the 2 different models.
-    |
-    | Under specific circumstances, you may want to disable this behaviour
-    | e.g. if you only have one authentication model, then you would save
-    | a little on token size.
-    |
-    */
-
-    'lock_subject' => true,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Leeway
-    |--------------------------------------------------------------------------
-    |
-    | This property gives the jwt timestamp claims some "leeway".
-    | Meaning that if you have any unavoidable slight clock skew on
-    | any of your servers then this will afford you some level of cushioning.
-    |
-    | This applies to the claims `iat`, `nbf` and `exp`.
-    |
-    | Specify in seconds - only if you know you need it.
-    |
-    */
-
-    'leeway' => env('JWT_LEEWAY', 0),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Blacklist Enabled
-    |--------------------------------------------------------------------------
-    |
-    | In order to invalidate tokens, you must have the blacklist enabled.
-    | If you do not want or need this functionality, then set this to false.
-    |
-    */
-
-    'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
-
-    /*
-    | -------------------------------------------------------------------------
-    | Blacklist Grace Period
-    | -------------------------------------------------------------------------
-    |
-    | When multiple concurrent requests are made with the same JWT,
-    | it is possible that some of them fail, due to token regeneration
-    | on every request.
-    |
-    | Set grace period in seconds to prevent parallel request failure.
-    |
-    */
-
-    'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Cookies encryption
-    |--------------------------------------------------------------------------
-    |
-    | By default Laravel encrypt cookies for security reason.
-    | If you decide to not decrypt cookies, you will have to configure Laravel
-    | to not encrypt your cookie token by adding its name into the $except
-    | array available in the middleware "EncryptCookies" provided by Laravel.
-    | see https://laravel.com/docs/master/responses#cookies-and-encryption
-    | for details.
-    |
-    | Set it to true if you want to decrypt cookies.
-    |
-    */
-
-    'decrypt_cookies' => false,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Providers
-    |--------------------------------------------------------------------------
-    |
-    | Specify the various providers used throughout the package.
-    |
-    */
-
-    'providers' => [
-
-        /*
-        |--------------------------------------------------------------------------
-        | JWT Provider
-        |--------------------------------------------------------------------------
-        |
-        | Specify the provider that is used to create and decode the tokens.
-        |
-        */
-
-        'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
-
-        /*
-        |--------------------------------------------------------------------------
-        | Authentication Provider
-        |--------------------------------------------------------------------------
-        |
-        | Specify the provider that is used to authenticate users.
-        |
-        */
-
-        'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
-
-        /*
-        |--------------------------------------------------------------------------
-        | Storage Provider
-        |--------------------------------------------------------------------------
-        |
-        | Specify the provider that is used to store tokens in the blacklist.
-        |
-        */
-
-        'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
-
-    ],
-
-];

+ 0 - 63
config/lang-publisher.php

@@ -1,63 +0,0 @@
-<?php
-
-use Helldar\PrettyArray\Contracts\Caseable;
-
-return [
-    /*
-     * Determines what type of files to use when updating language files.
-     *
-     * `true` means inline files will be used.
-     * `false` means that default files will be used.
-     *
-     * The difference between them can be seen here:
-     * @see https://github.com/Laravel-Lang/lang/blob/master/script/en/validation.php
-     * @see https://github.com/Laravel-Lang/lang/blob/master/script/en/validation-inline.php
-     *
-     * By default, `false`.
-     */
-
-    'inline' => false,
-
-    /*
-     * Do arrays need to be aligned by keys before processing arrays?
-     *
-     * By default, true
-     */
-
-    'alignment' => true,
-
-    /*
-     * Key exclusion when combining.
-     */
-
-    'exclude' => [
-        // 'auth' => ['throttle'],
-        // 'pagination' => ['previous'],
-        // 'passwords' => ['reset', 'throttled', 'user'],
-        // 'Confirm Password',
-    ],
-
-    /*
-     * List of ignored localizations.
-     */
-
-    'ignore' => [
-        // 'en',
-        // Helldar\LaravelLangPublisher\Constants\Locales::ALBANIAN,
-    ],
-
-    /*
-     * Change key case.
-     *
-     * Available values:
-     *
-     *   Helldar\PrettyArray\Contracts\Caseable::NO_CASE      - Case does not change
-     *   Helldar\PrettyArray\Contracts\Caseable::CAMEL_CASE   - camelCase
-     *   Helldar\PrettyArray\Contracts\Caseable::KEBAB_CASE   - kebab-case
-     *   Helldar\PrettyArray\Contracts\Caseable::PASCAL_CASE  - PascalCase
-     *   Helldar\PrettyArray\Contracts\Caseable::SNAKE_CASE   - snake_case
-     *
-     * By default, Caseable::NO_CASE
-     */
-    'case' => interface_exists(Caseable::class) ? Caseable::NO_CASE : 0,
-];

+ 0 - 36
config/laravel-lang.php

@@ -1,36 +0,0 @@
-<?php
-
-return [
-
-    /* -----------------------------------------------------------------
-     |  The vendor path
-     | -----------------------------------------------------------------
-     */
-
-    /** @link      https://github.com/caouecs/Laravel-lang */
-    'vendor' => base_path('vendor/caouecs/laravel-lang/src'),
-
-    /* -----------------------------------------------------------------
-     |  Supported locales
-     | -----------------------------------------------------------------
-     | If you want to limit your translations, set your supported locales list.
-     */
-
-    'locales' => [
-        'ko',
-        'zh-CN',
-    ],
-
-    /* -----------------------------------------------------------------
-     |  Check Settings
-     | -----------------------------------------------------------------
-     */
-
-    'check' => [
-        'ignore' => [
-            'validation.custom',
-            'validation.attributes',
-        ],
-    ],
-
-];

+ 0 - 163
config/telescope.php

@@ -1,163 +0,0 @@
-<?php
-
-use Laravel\Telescope\Http\Middleware\Authorize;
-use Laravel\Telescope\Watchers;
-
-return [
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Domain
-    |--------------------------------------------------------------------------
-    |
-    | This is the subdomain where Telescope will be accessible from. If the
-    | setting is null, Telescope will reside under the same domain as the
-    | application. Otherwise, this value will be used as the subdomain.
-    |
-    */
-
-    'domain' => env('TELESCOPE_DOMAIN', null),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Path
-    |--------------------------------------------------------------------------
-    |
-    | This is the URI path where Telescope will be accessible from. Feel free
-    | to change this path to anything you like. Note that the URI will not
-    | affect the paths of its internal API that aren't exposed to users.
-    |
-    */
-
-    'path' => env('TELESCOPE_PATH', 'telescope'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Storage Driver
-    |--------------------------------------------------------------------------
-    |
-    | This configuration options determines the storage driver that will
-    | be used to store Telescope's data. In addition, you may set any
-    | custom options as needed by the particular driver you choose.
-    |
-    */
-
-    'driver' => env('TELESCOPE_DRIVER', 'database'),
-
-    'storage' => [
-        'database' => [
-            'connection' => env('DB_CONNECTION', 'mysql'),
-            'chunk' => 1000,
-        ],
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Master Switch
-    |--------------------------------------------------------------------------
-    |
-    | This option may be used to disable all Telescope watchers regardless
-    | of their individual configuration, which simply provides a single
-    | and convenient way to enable or disable Telescope data storage.
-    |
-    */
-
-    'enabled' => env('TELESCOPE_ENABLED', true),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Route Middleware
-    |--------------------------------------------------------------------------
-    |
-    | These middleware will be assigned to every Telescope route, giving you
-    | the chance to add your own middleware to this list or change any of
-    | the existing middleware. Or, you can simply stick with this list.
-    |
-    */
-
-    'middleware' => [
-        'web',
-        Authorize::class,
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Ignored Paths & Commands
-    |--------------------------------------------------------------------------
-    |
-    | The following array lists the URI paths and Artisan commands that will
-    | not be watched by Telescope. In addition to this list, some Laravel
-    | commands, like migrations and queue commands, are always ignored.
-    |
-    */
-
-    'ignore_paths' => [
-        'nova-api*',
-    ],
-
-    'ignore_commands' => [
-        //
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Telescope Watchers
-    |--------------------------------------------------------------------------
-    |
-    | The following array lists the "watchers" that will be registered with
-    | Telescope. The watchers gather the application's profile data when
-    | a request or task is executed. Feel free to customize this list.
-    |
-    */
-
-    'watchers' => [
-        Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true),
-
-        Watchers\CommandWatcher::class => [
-            'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
-            'ignore' => [],
-        ],
-
-        Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true),
-
-        Watchers\EventWatcher::class => [
-            'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
-            'ignore' => [],
-        ],
-
-        Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
-        Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
-        Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true),
-        Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
-
-        Watchers\ModelWatcher::class => [
-            'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
-            'events' => ['eloquent.*'],
-        ],
-
-        Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
-
-        Watchers\QueryWatcher::class => [
-            'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
-            'ignore_packages' => true,
-            'slow' => 100,
-        ],
-
-        Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
-
-        Watchers\RequestWatcher::class => [
-            'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
-            'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
-        ],
-
-        Watchers\GateWatcher::class => [
-            'enabled' => env('TELESCOPE_GATE_WATCHER', true),
-            'ignore_abilities' => [],
-            'ignore_packages' => true,
-        ],
-
-        Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
-
-        Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
-    ],
-];

+ 58 - 0
install.sh

@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+#检查系统
+check_sys(){
+	if [[ -f /etc/redhat-release ]]; then
+		release="centos"
+	elif cat /etc/issue | grep -q -E -i "debian"; then
+		release="debian"
+	elif cat /etc/issue | grep -q -E -i "ubuntu"; then
+		release="ubuntu"
+	elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
+		release="centos"
+	elif cat /proc/version | grep -q -E -i "debian"; then
+		release="debian"
+	elif cat /proc/version | grep -q -E -i "ubuntu"; then
+		release="ubuntu"
+	elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
+		release="centos"
+    fi
+}
+#检查composer是否安装
+check_composer(){
+  if [ ! -f "/usr/bin/composer" ]; then
+      if [[ "${release}" == "centos" ]]; then
+      		yum install -y composer
+      	else
+      		apt-get install -y composer
+      fi
+  fi
+}
+
+# 设置权限
+set_permissions(){
+  if [ ! -d "/home/www" ]; then
+    mkdir -p /home/www
+    chown www:www /home/www
+  fi
+    chown -R www:www ./
+    chmod -R 755 ./
+    chmod -R 777 storage/
+}
+
+set_crontab(){
+  cmd="php $(dirname "$path")/artisan schedule:run >> /dev/null 2>&1"
+  cronjob="* * * * * $cmd"
+  ( crontab -u www -l | grep -v -F "$cmd" ; echo "$cronjob" ) | crontab -u www -
+
+
+  cmd="bash $(dirname "$path")/queue.sh"
+  cronjob="*/10 * * * * $cmd"
+  ( crontab -l | grep -v -F "$cmd" ; echo "$cronjob" ) | crontab -
+}
+
+check_sys
+check_composer
+composer install
+php artisan panel:install
+set_permissions
+set_crontab

+ 42 - 6
update.sh

@@ -1,8 +1,44 @@
 #!/usr/bin/env bash
-git fetch --all
-git reset --hard origin/master
-git pull
+#检查系统
+check_sys(){
+	if [[ -f /etc/redhat-release ]]; then
+		release="centos"
+	elif cat /etc/issue | grep -q -E -i "debian"; then
+		release="debian"
+	elif cat /etc/issue | grep -q -E -i "ubuntu"; then
+		release="ubuntu"
+	elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
+		release="centos"
+	elif cat /proc/version | grep -q -E -i "debian"; then
+		release="debian"
+	elif cat /proc/version | grep -q -E -i "ubuntu"; then
+		release="ubuntu"
+	elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
+		release="centos"
+    fi
+}
+#检查composer是否安装
+check_composer(){
+  if [ ! -f "/usr/bin/composer" ]; then
+      if [[ "${release}" == "centos" ]]; then
+      		yum install -y composer
+      	else
+      		apt-get install -y composer
+      fi
+  fi
+}
+
+# 设置权限
+set_permissions(){
+    chown -R www:www ./
+    chmod -R 755 ./
+    chmod -R 777 storage/
+}
+
+git fetch --all && git reset --hard origin/master && git pull
+check_sys
+check_composer
 php artisan optimize:clear
-composer install --prefer-dist --optimize-autoloader --no-dev
-php artisan optimize
-chown -R www:www ./
+composer install
+php artisan panel:update
+set_permissions

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov