浏览代码

Fixed case may stop update

BrettonYe 4 月之前
父节点
当前提交
2deced20fa

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

@@ -1,59 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Artisan;
-use Illuminate\Console\Command;
-
-class PanelUpdate extends Command
-{
-    protected $signature = 'panel:update';
-
-    protected $description = 'ProxyPanel Version Update (面板更新)';
-
-    public function handle(): void
-    {
-        $bar = $this->output->createProgressBar(2);
-        $bar->minSecondsBetweenRedraws(0);
-        $this->displayBanner();
-        $bar->start();
-        $this->updateDatabase();
-
-        $bar->advance();
-        $this->updateCache();
-
-        $bar->finish();
-        $this->info(trans('setup.update_complete'));
-    }
-
-    private function displayBanner(): void
-    {
-        $banner = <<<BANNER
-   ___                              ___                      _ 
-  / _ \ _ __   ___  __  __ _   _   / _ \  __ _  _ __    ___ | |
- / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \  / _ \| |
-/ ___/ | |   | (_) | >  < | |_| |/ ___/ | (_| || | | ||  __/| |
-\/     |_|    \___/ /_/\_\ \__, |\/      \__,_||_| |_| \___||_|
-                           |___/                               
-
-BANNER;
-
-        $this->info($banner);
-    }
-
-    private function updateDatabase(): void
-    {
-        $this->line(trans('setup.update_db'));
-        Artisan::call('migrate --force');
-
-        if (config('app.env') === 'demo' && $this->confirm(trans('setup.demo_reset'))) {
-            Artisan::call('migrate:fresh --seed --force');
-        }
-    }
-
-    private function updateCache(): void
-    {
-        $this->line(trans('setup.update_cache'));
-        Artisan::call('optimize');
-    }
-}

+ 2 - 2
app/Providers/SettingServiceProvider.php

@@ -55,8 +55,8 @@ class SettingServiceProvider extends ServiceProvider
             ->merge(collect(['is_onlinePay' => $settings->whereIn('name', $payments)->pluck('value')->filter()->isNotEmpty()])) // 设置在线支付开关
             ->merge(collect(['is_onlinePay' => $settings->whereIn('name', $payments)->pluck('value')->filter()->isNotEmpty()])) // 设置在线支付开关
             ->sortKeys()
             ->sortKeys()
             ->toArray();
             ->toArray();
-        $modified['tasks_clean'] = json_decode($modified['tasks_clean'], true);
-        $modified['tasks_close'] = json_decode($modified['tasks_close'], true);
+        $modified['tasks_clean'] = json_decode($modified['tasks_clean'] ?? '', true);
+        $modified['tasks_close'] = json_decode($modified['tasks_close'] ?? '', true);
 
 
         config(['settings' => $modified]); // 设置系统参数
         config(['settings' => $modified]); // 设置系统参数
 
 

+ 0 - 10
resources/lang/de/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => 'Sie sind im Demo-Modus. Möchten Sie die Datenbank zurücksetzen?',
-    'update_cache' => 'Cache aktualisieren...',
-    'update_complete' => 'Aktualisierung abgeschlossen!',
-    'update_db' => 'Datenbank aktualisieren...',
-];

+ 0 - 10
resources/lang/en/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => 'You have been detected in Demo mode, do you reset the database?',
-    'update_cache' => 'Update cache...',
-    'update_complete' => 'Update Completed! ',
-    'update_db' => 'Update Database...',
-];

+ 0 - 10
resources/lang/fa/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => 'شناسایی شد که شما در حالت دمو هستید. آیا می‌خواهید پایگاه داده را بازنشانی کنید؟',
-    'update_cache' => 'به‌روزرسانی کش...',
-    'update_complete' => 'به‌روزرسانی کامل شد!',
-    'update_db' => 'به‌روزرسانی پایگاه داده...',
-];

+ 0 - 10
resources/lang/ja/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => 'DEMOモードであることが検出されました。データベースをリセットしますか?',
-    'update_cache' => 'キャッシュを更新しています...',
-    'update_complete' => '업데이트 완료!',
-    'update_db' => 'データベースを更新しています...',
-];

+ 0 - 10
resources/lang/ko/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => '데모 모드가 감지되었습니다. 데이터베이스를 재설정하시겠습니까?',
-    'update_cache' => '캐시 업데이트 중...',
-    'update_complete' => '업데이트 완료!',
-    'update_db' => '데이터베이스 업데이트 중...',
-];

+ 0 - 10
resources/lang/vi/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => 'Phát hiện bạn đang ở chế độ Demo, bạn có muốn đặt lại cơ sở dữ liệu không?',
-    'update_cache' => 'Cập nhật bộ nhớ đệm...',
-    'update_complete' => 'Cập nhật hoàn tất!',
-    'update_db' => 'Cập nhật cơ sở dữ liệu...',
-];

+ 0 - 10
resources/lang/zh_CN/setup.php

@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-return [
-    'demo_reset' => '检测到您在DEMO模式, 是否重置数据库?',
-    'update_cache' => '更新缓存...',
-    'update_complete' => '更新完毕!',
-    'update_db' => '更新数据库...',
-];

+ 12 - 0
scripts/lib.sh

@@ -5,6 +5,18 @@ function print_message() {
     echo -e "\e[34m========= $1 | $2 =========\e[0m"
     echo -e "\e[34m========= $1 | $2 =========\e[0m"
 }
 }
 
 
+function print_logo() {
+cat << "EOF"
+   ___                              ___                      _
+  / _ \ _ __   ___  __  __ _   _   / _ \  __ _  _ __    ___ | |
+ / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \  / _ \| |
+/ ___/ | |   | (_) | >  < | |_| |/ ___/ | (_| || | | ||  __/| |
+\/     |_|    \___/ /_/\_\ \__, |\/      \__,_||_| |_| \___||_|
+                           |___/
+
+EOF
+}
+
 # 安装依赖
 # 安装依赖
 install_dependencies() {
 install_dependencies() {
   # 判断系统
   # 判断系统

+ 26 - 9
update.sh

@@ -5,25 +5,40 @@ cd "$(dirname "$0")" || exit 1
 # 引入依赖脚本
 # 引入依赖脚本
 source scripts/lib.sh
 source scripts/lib.sh
 
 
+print_message "Starting panel update..." "开始面板更新..."
+
+print_logo
+
 # 更新代码
 # 更新代码
-print_message "Checking server environment..." "检查服务器环境..."
+print_message "updating Code..." "更新代码..."
 git fetch -f && git reset -q --hard origin/master && git pull
 git fetch -f && git reset -q --hard origin/master && git pull
 
 
+# 更新数据库
+print_message "Updating database..." "更新数据库..."
+php artisan migrate --force
+
+# 如果是演示环境,询问是否重置数据库
+if [[ $(grep -E '^APP_ENV=demo' .env) ]]; then
+    read -p "Reset demo database? [y/N] " -n 1 -r
+    echo
+    if [[ $REPLY =~ ^[Yy]$ ]]; then
+        print_message "Resetting demo database..." "重置演示数据库..."
+        php artisan migrate:fresh --seed --force
+    fi
+fi
+
+# 优化缓存
+print_message "Optimizing application cache..." "优化应用缓存..."
+php artisan optimize
+
 # 检查Composer
 # 检查Composer
 print_message "Checking Composer..." "检查Composer..."
 print_message "Checking Composer..." "检查Composer..."
 check_composer
 check_composer
 
 
-# 清理优化缓存
-print_message "Cleaning panel cache..." "清理面板缓存..."
-php artisan optimize:clear
-
 # 执行Composer更新
 # 执行Composer更新
 print_message "Updating packages via Composer..." "通过Composer更新程序包..."
 print_message "Updating packages via Composer..." "通过Composer更新程序包..."
 composer update --no-interaction --no-dev --optimize-autoloader
 composer update --no-interaction --no-dev --optimize-autoloader
 
 
-# 执行Panel更新
-php artisan panel:update
-
 # 设置权限
 # 设置权限
 set_permissions
 set_permissions
 
 
@@ -32,4 +47,6 @@ update_old_queue
 
 
 # 检查最新的IP数据库文件
 # 检查最新的IP数据库文件
 print_message "Updating IP database files..." "更新本地IP数据库文件..."
 print_message "Updating IP database files..." "更新本地IP数据库文件..."
-cd scripts/ && bash download_dbs.sh
+(cd scripts/ && bash download_dbs.sh)
+
+print_message "Panel update completed successfully!" "面板更新完成!"