mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 15:10:54 +00:00
Fixed case may stop update
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -55,8 +55,8 @@ class SettingServiceProvider extends ServiceProvider
|
||||
->merge(collect(['is_onlinePay' => $settings->whereIn('name', $payments)->pluck('value')->filter()->isNotEmpty()])) // 设置在线支付开关
|
||||
->sortKeys()
|
||||
->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]); // 设置系统参数
|
||||
|
||||
|
||||
@@ -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...',
|
||||
];
|
||||
@@ -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...',
|
||||
];
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'demo_reset' => 'شناسایی شد که شما در حالت دمو هستید. آیا میخواهید پایگاه داده را بازنشانی کنید؟',
|
||||
'update_cache' => 'بهروزرسانی کش...',
|
||||
'update_complete' => 'بهروزرسانی کامل شد!',
|
||||
'update_db' => 'بهروزرسانی پایگاه داده...',
|
||||
];
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'demo_reset' => 'DEMOモードであることが検出されました。データベースをリセットしますか?',
|
||||
'update_cache' => 'キャッシュを更新しています...',
|
||||
'update_complete' => '업데이트 완료!',
|
||||
'update_db' => 'データベースを更新しています...',
|
||||
];
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'demo_reset' => '데모 모드가 감지되었습니다. 데이터베이스를 재설정하시겠습니까?',
|
||||
'update_cache' => '캐시 업데이트 중...',
|
||||
'update_complete' => '업데이트 완료!',
|
||||
'update_db' => '데이터베이스 업데이트 중...',
|
||||
];
|
||||
@@ -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...',
|
||||
];
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'demo_reset' => '检测到您在DEMO模式, 是否重置数据库?',
|
||||
'update_cache' => '更新缓存...',
|
||||
'update_complete' => '更新完毕!',
|
||||
'update_db' => '更新数据库...',
|
||||
];
|
||||
@@ -5,6 +5,18 @@ function print_message() {
|
||||
echo -e "\e[34m========= $1 | $2 =========\e[0m"
|
||||
}
|
||||
|
||||
function print_logo() {
|
||||
cat << "EOF"
|
||||
___ ___ _
|
||||
/ _ \ _ __ ___ __ __ _ _ / _ \ __ _ _ __ ___ | |
|
||||
/ /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \ / _ \| |
|
||||
/ ___/ | | | (_) | > < | |_| |/ ___/ | (_| || | | || __/| |
|
||||
\/ |_| \___/ /_/\_\ \__, |\/ \__,_||_| |_| \___||_|
|
||||
|___/
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# 安装依赖
|
||||
install_dependencies() {
|
||||
# 判断系统
|
||||
|
||||
35
update.sh
35
update.sh
@@ -5,25 +5,40 @@ cd "$(dirname "$0")" || exit 1
|
||||
# 引入依赖脚本
|
||||
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
|
||||
|
||||
# 更新数据库
|
||||
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
|
||||
print_message "Checking Composer..." "检查Composer..."
|
||||
check_composer
|
||||
|
||||
# 清理优化缓存
|
||||
print_message "Cleaning panel cache..." "清理面板缓存..."
|
||||
php artisan optimize:clear
|
||||
|
||||
# 执行Composer更新
|
||||
print_message "Updating packages via Composer..." "通过Composer更新程序包..."
|
||||
composer update --no-interaction --no-dev --optimize-autoloader
|
||||
|
||||
# 执行Panel更新
|
||||
php artisan panel:update
|
||||
|
||||
# 设置权限
|
||||
set_permissions
|
||||
|
||||
@@ -32,4 +47,6 @@ update_old_queue
|
||||
|
||||
# 检查最新的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!" "面板更新完成!"
|
||||
Reference in New Issue
Block a user