feat: make install_db.sh's PORT argument optional, defaulting to 3306
This commit is contained in:
+10
-8
@@ -69,14 +69,20 @@ trap cleanup EXIT
|
|||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Użycie:
|
Użycie:
|
||||||
$0 <MARIADB_VERSION> <PORT>
|
$0 <MARIADB_VERSION> [PORT]
|
||||||
|
|
||||||
Przykłady:
|
Przykłady:
|
||||||
|
$0 10.11
|
||||||
$0 10.11 33033
|
$0 10.11 33033
|
||||||
$0 11.4 3020
|
$0 11.4 3020
|
||||||
$0 11.8 3021
|
$0 11.8 3021
|
||||||
|
|
||||||
Dozwolone gałęzie MariaDB: 10.11, 11.4, 11.8.
|
Dozwolone gałęzie MariaDB: 10.11, 11.4, 11.8.
|
||||||
|
|
||||||
|
Jeżeli PORT zostanie pominięty, przyjmowana jest wartość domyślna 3306. W takim
|
||||||
|
przypadku skrypt najpierw przenosi natywną instancję MariaDB zarządzaną przez
|
||||||
|
CustomBuild na inny port (patrz scripts/setup/native_mariadb_port_takeover.sh),
|
||||||
|
aby zwolnić port 3306 dla alt-mariadb.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,19 +104,15 @@ apply_cli_args() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $# -gt 2 ]]; then
|
if [[ $# -gt 2 ]]; then
|
||||||
usage_error "Podano zbyt wiele argumentów. Oczekiwano: MARIADB_VERSION PORT."
|
usage_error "Podano zbyt wiele argumentów. Oczekiwano: MARIADB_VERSION [PORT]."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $# -lt 2 ]]; then
|
|
||||||
usage_error "Podaj wersję MariaDB i port TCP, np. 11.4 3020."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# -ge 1 && -n "${1:-}" ]]; then
|
|
||||||
MARIADB_VERSION="$1"
|
MARIADB_VERSION="$1"
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# -ge 2 && -n "${2:-}" ]]; then
|
if [[ $# -ge 2 && -n "${2:-}" ]]; then
|
||||||
PORT="$2"
|
PORT="$2"
|
||||||
|
else
|
||||||
|
PORT="3306"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MARIADB_DIR="/usr/local/mariadb-$MARIADB_VERSION"
|
MARIADB_DIR="/usr/local/mariadb-$MARIADB_VERSION"
|
||||||
|
|||||||
@@ -41,10 +41,20 @@ set -e
|
|||||||
[ "$NO_ARGS_STATUS" -eq 2 ] || fail "install_db.sh without arguments should exit with status 2, got $NO_ARGS_STATUS"
|
[ "$NO_ARGS_STATUS" -eq 2 ] || fail "install_db.sh without arguments should exit with status 2, got $NO_ARGS_STATUS"
|
||||||
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Użycie:' \
|
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Użycie:' \
|
||||||
|| fail "install_db.sh without arguments does not print usage"
|
|| fail "install_db.sh without arguments does not print usage"
|
||||||
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq '<MARIADB_VERSION> <PORT>' \
|
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq '<MARIADB_VERSION> [PORT]' \
|
||||||
|| fail "install_db.sh usage does not show required version and port"
|
|| fail "install_db.sh usage does not show optional port"
|
||||||
if printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Ten skrypt musi zostać uruchomiony jako root'; then
|
if printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Ten skrypt musi zostać uruchomiony jako root'; then
|
||||||
fail "install_db.sh without arguments reaches root check instead of usage"
|
fail "install_db.sh without arguments reaches root check instead of usage"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
ONE_ARG_OUTPUT="$("$SCRIPT" 10.11 2>&1)"
|
||||||
|
ONE_ARG_STATUS=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
[ "$ONE_ARG_STATUS" -eq 1 ] \
|
||||||
|
|| fail "install_db.sh with only a version argument should reach the root check (status 1), got $ONE_ARG_STATUS: $ONE_ARG_OUTPUT"
|
||||||
|
printf '%s\n' "$ONE_ARG_OUTPUT" | grep -Fq 'Ten skrypt musi zostać uruchomiony jako root' \
|
||||||
|
|| fail "install_db.sh with only a version argument should default PORT to 3306 and reach the root check, got: $ONE_ARG_OUTPUT"
|
||||||
|
|
||||||
echo "install_db_cli_test: OK"
|
echo "install_db_cli_test: OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user