Compare commits
11 Commits
80a8b86a08
...
stable
| Author | SHA1 | Date | |
|---|---|---|---|
| d178b8da91 | |||
| 7ecb6378fe | |||
| 9496078644 | |||
| 3aab864c34 | |||
| 5eb5404061 | |||
| d9040f1e6c | |||
| 8270e635d6 | |||
| d724f80cad | |||
| 1f5f340ce4 | |||
| 40e111b3a6 | |||
| 506011f933 |
0
bootstrap/cache/.gitkeep
vendored
Normal file
0
bootstrap/cache/.gitkeep
vendored
Normal file
@@ -98,5 +98,5 @@
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"version": "26.0.2",
|
||||
"build": "66"
|
||||
"build": "72"
|
||||
}
|
||||
|
||||
134
git_update.sh
134
git_update.sh
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2016
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -41,6 +42,66 @@ resolve_php_bin() {
|
||||
echo "php"
|
||||
}
|
||||
|
||||
resolve_configured_php_bin() {
|
||||
local configured="${1:-}"
|
||||
local current="${2:-php}"
|
||||
local trimmed="$configured"
|
||||
trimmed="${trimmed#"${trimmed%%[![:space:]]*}"}"
|
||||
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
|
||||
|
||||
if [[ -z "$trimmed" ]]; then
|
||||
echo "$current"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$trimmed" == "keyhelp-php-domain" ]]; then
|
||||
if command -v keyhelp-php-domain >/dev/null 2>&1; then
|
||||
echo "keyhelp-php-domain"
|
||||
return
|
||||
fi
|
||||
if [[ -x "/usr/bin/keyhelp-php-domain" ]]; then
|
||||
echo "/usr/bin/keyhelp-php-domain"
|
||||
return
|
||||
fi
|
||||
if [[ -x "/usr/local/bin/keyhelp-php-domain" ]]; then
|
||||
echo "/usr/local/bin/keyhelp-php-domain"
|
||||
return
|
||||
fi
|
||||
echo "Configured PHP binary 'keyhelp-php-domain' was not found." >&2
|
||||
echo "Set ACP -> System -> CLI to a working custom binary (e.g. keyhelp-php84)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v "$trimmed" >/dev/null 2>&1; then
|
||||
echo "$trimmed"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$trimmed" == */* && -x "$trimmed" ]]; then
|
||||
echo "$trimmed"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Configured PHP binary '$trimmed' is not executable/resolvable." >&2
|
||||
echo "Set ACP -> System -> CLI to a valid command or absolute executable path." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
read_setting_php_bin() {
|
||||
if [[ ! -f artisan ]]; then
|
||||
echo ""
|
||||
return 0
|
||||
fi
|
||||
echo "Running with PHP binary: $PHP_BIN -r <read system.php_binary>" >&2
|
||||
"$PHP_BIN" -r '
|
||||
require "vendor/autoload.php";
|
||||
$app = require "bootstrap/app.php";
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$value = (string) \App\Models\Setting::where("key", "system.php_binary")->value("value");
|
||||
echo trim($value);
|
||||
'
|
||||
}
|
||||
|
||||
PHP_BIN="$(resolve_php_bin)"
|
||||
echo "Resolved PHP binary: $PHP_BIN"
|
||||
if command -v "$PHP_BIN" >/dev/null 2>&1; then
|
||||
@@ -55,18 +116,16 @@ if [[ -z "$COMPOSER_BIN" ]]; then
|
||||
echo "Composer not found in PATH."
|
||||
exit 1
|
||||
fi
|
||||
$PHP_BIN "$COMPOSER_BIN" install --no-dev --optimize-autoloader
|
||||
echo "Running with PHP binary: $PHP_BIN $COMPOSER_BIN install --no-dev --optimize-autoloader"
|
||||
"$PHP_BIN" "$COMPOSER_BIN" install --no-dev --optimize-autoloader
|
||||
|
||||
if [[ -x "artisan" ]]; then
|
||||
CONFIGURED_PHP="$($PHP_BIN artisan tinker --execute="echo \\App\\Models\\Setting::where('key','system.php_binary')->value('value') ?? '';" 2>/dev/null || true)"
|
||||
if [[ -n "$CONFIGURED_PHP" ]]; then
|
||||
if command -v "$CONFIGURED_PHP" >/dev/null 2>&1; then
|
||||
PHP_BIN="$CONFIGURED_PHP"
|
||||
elif [[ -x "$CONFIGURED_PHP" ]]; then
|
||||
PHP_BIN="$CONFIGURED_PHP"
|
||||
fi
|
||||
fi
|
||||
if ! CONFIGURED_PHP="$(read_setting_php_bin)"; then
|
||||
echo "Failed to read configured PHP binary from settings." >&2
|
||||
echo "Aborting to avoid running update with the wrong PHP binary." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Configured PHP binary from settings: ${CONFIGURED_PHP:-<empty>}"
|
||||
PHP_BIN="$(resolve_configured_php_bin "$CONFIGURED_PHP" "$PHP_BIN")"
|
||||
|
||||
echo "Final PHP binary: $PHP_BIN"
|
||||
if command -v "$PHP_BIN" >/dev/null 2>&1; then
|
||||
@@ -80,26 +139,61 @@ echo "Building assets..."
|
||||
npm run build
|
||||
|
||||
echo "Running migrations..."
|
||||
$PHP_BIN artisan migrate --force
|
||||
echo "Running with PHP binary: $PHP_BIN artisan migrate --force"
|
||||
"$PHP_BIN" artisan migrate --force
|
||||
|
||||
echo "Syncing version/build to settings..."
|
||||
VERSION="$($PHP_BIN -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["version"] ?? "";')"
|
||||
BUILD="$($PHP_BIN -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["build"] ?? "";')"
|
||||
echo "Running with PHP binary: $PHP_BIN -r <read composer.json version>"
|
||||
VERSION="$("$PHP_BIN" -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["version"] ?? "";')"
|
||||
echo "Running with PHP binary: $PHP_BIN -r <read composer.json build>"
|
||||
BUILD="$("$PHP_BIN" -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["build"] ?? "";')"
|
||||
echo "Computed from composer.json: VERSION=$VERSION, BUILD=$BUILD"
|
||||
|
||||
if [[ -n "$VERSION" || -n "$BUILD" ]]; then
|
||||
$PHP_BIN -r '
|
||||
echo "Updating settings version/build (VERSION=$VERSION, BUILD=$BUILD)..."
|
||||
echo "Running with PHP binary: $PHP_BIN -r <write settings version/build>"
|
||||
SPEEDBB_VERSION="$VERSION" SPEEDBB_BUILD="$BUILD" "$PHP_BIN" -r '
|
||||
require "vendor/autoload.php";
|
||||
$app = require "bootstrap/app.php";
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
if (getenv("SPEEDBB_VERSION")) {
|
||||
\App\Models\Setting::updateOrCreate(["key" => "version"], ["value" => getenv("SPEEDBB_VERSION")]);
|
||||
$version = getenv("SPEEDBB_VERSION");
|
||||
$build = getenv("SPEEDBB_BUILD");
|
||||
if ($version !== false && $version !== "") {
|
||||
\Illuminate\Support\Facades\DB::table("settings")->upsert(
|
||||
[[
|
||||
"key" => "version",
|
||||
"value" => $version,
|
||||
"created_at" => now(),
|
||||
"updated_at" => now(),
|
||||
]],
|
||||
["key"],
|
||||
["value", "updated_at"]
|
||||
);
|
||||
echo "Upserted version setting.\n";
|
||||
}
|
||||
if (getenv("SPEEDBB_BUILD")) {
|
||||
\App\Models\Setting::updateOrCreate(["key" => "build"], ["value" => getenv("SPEEDBB_BUILD")]);
|
||||
if ($build !== false && $build !== "") {
|
||||
\Illuminate\Support\Facades\DB::table("settings")->upsert(
|
||||
[[
|
||||
"key" => "build",
|
||||
"value" => $build,
|
||||
"created_at" => now(),
|
||||
"updated_at" => now(),
|
||||
]],
|
||||
["key"],
|
||||
["value", "updated_at"]
|
||||
);
|
||||
echo "Upserted build setting.\n";
|
||||
}
|
||||
' \
|
||||
SPEEDBB_VERSION="$VERSION" \
|
||||
SPEEDBB_BUILD="$BUILD"
|
||||
&& echo "Running with PHP binary: $PHP_BIN -r <verify settings version/build>" \
|
||||
&& "$PHP_BIN" -r '
|
||||
require "vendor/autoload.php";
|
||||
$app = require "bootstrap/app.php";
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$version = \App\Models\Setting::where("key", "version")->value("value");
|
||||
$build = \App\Models\Setting::where("key", "build")->value("value");
|
||||
echo "Settings now: version={$version}, build={$build}\n";
|
||||
'
|
||||
fi
|
||||
|
||||
echo "Update complete."
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Fail fast if the database is unreachable.
|
||||
php artisan version:fetch >/dev/null
|
||||
# Keep commits possible when local DB is offline.
|
||||
if ! php artisan version:fetch >/dev/null 2>&1; then
|
||||
echo "pre-commit: skipped 'php artisan version:fetch' (database unreachable)." >&2
|
||||
echo "pre-commit: start MySQL and run it manually when needed." >&2
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user