Enhance installation scripts with root privilege checks and user guidance
- Added a check in `blueforce-install.sh` to ensure the script is run with root privileges, providing user-friendly error messages and guidance for launching with sudo or using check mode. - Updated `01-precheck.sh` to conditionally require root privileges based on the check mode, allowing for non-root execution in read-only mode. - Modified test scripts to reflect changes in the installation process, ensuring accurate reporting of the Python console's presence and adjusting expectations accordingly.
This commit is contained in:
parent
5cc312f58a
commit
8cb0c72065
4 changed files with 16778 additions and 21829 deletions
38585
repomix-output.xml
38585
repomix-output.xml
File diff suppressed because it is too large
Load diff
|
|
@ -253,6 +253,17 @@ esac; done
|
|||
[[ "$DEALER_ID" =~ ^[0-9]{8}$ ]] || usage_error "Geçersiz bayi numarası '$DEALER_ID': 8 haneli rakam olmalıdır (örn. 12345678)."
|
||||
[[ "$FORCE_OFFLINE" -eq 1 && "$ONLINE" -eq 1 ]] && usage_error 'Bir kurulumda hem --offline hem --online verilemez.'
|
||||
|
||||
# Apply mode changes APT, services, firewall rules and /var/lib state. Fail
|
||||
# before repository discovery so a desktop launch as a normal user produces a
|
||||
# useful explanation instead of a later, opaque module exit code (usually from
|
||||
# /var/log or the APT lock).
|
||||
if [[ "$CHECK_MODE" -eq 0 && "$(id -u)" -ne 0 ]]; then
|
||||
printf 'HATA: Kurulum yönetici yetkisi ister; bu komut normal kullanıcıyla çalıştırıldı.\n' >&2
|
||||
printf ' Grafik uygulamayı yönetici yetkisiyle başlatın: sudo bf\n' >&2
|
||||
printf ' Salt-okunur doğrulama için --check kullanılabilir.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------- mode -----
|
||||
# Default (no flag): find the local bundle and install from it. The flag the
|
||||
# operator used to have to remember is now only a way to insist on it.
|
||||
|
|
@ -276,6 +287,7 @@ else
|
|||
validate_offline_repository
|
||||
fi
|
||||
export DEALER_ID BF_HOSTNAME="bf-${DEALER_ID}" BF_DEVICE="BF-${DEALER_ID}" STATE_DIR BF_OFFLINE BF_OFFLINE_REPO="${REPO_DIR:-}"
|
||||
export BF_USER="bf-${DEALER_ID}" BF_IDENTITY_FILE="${BF_IDENTITY_FILE:-/etc/blueforce/dealer-id}"
|
||||
|
||||
if [[ "$CHECK_MODE" -eq 0 && "$ASSUME_YES" -eq 0 ]]; then
|
||||
if ! read -r -p "Kurulum $BF_DEVICE olarak başlatılsın mı? [e/H] " answer; then
|
||||
|
|
|
|||
|
|
@ -54,7 +54,11 @@ report_network() {
|
|||
}
|
||||
|
||||
run_checks() {
|
||||
[[ "$(id -u)" -eq 0 ]] || fail "must run as root"
|
||||
if [[ "$CHECK_MODE" -eq 0 ]]; then
|
||||
[[ "$(id -u)" -eq 0 ]] || fail "must run as root"
|
||||
else
|
||||
info "yönetici yetkisi: salt-okunur denetim; root gerekmiyor"
|
||||
fi
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ contract 'bf-bootstrap links idempotently' "$BOOTSTRAP" has 'ln -sfn'
|
|||
contract 'bf-bootstrap discovers the admin tools' "$BOOTSTRAP" has 'admin/bf-\*'
|
||||
contract 'bf-bootstrap discovers the diagnostics tools' "$BOOTSTRAP" has 'scripts/diagnostics/bf-\*'
|
||||
contract 'bf-bootstrap discovers the maintenance tools' "$BOOTSTRAP" has 'scripts/maintenance/bf-\*'
|
||||
contract 'bf-bootstrap wires up bf-menu' "$BOOTSTRAP" has 'bf-menu'
|
||||
contract 'bf-bootstrap wires up the Python console' "$BOOTSTRAP" has 'PY_CONSOLE'
|
||||
contract 'bf-bootstrap supports Ubuntu 24.04' "$BOOTSTRAP" has '24\.04'
|
||||
contract 'bf-bootstrap supports Ubuntu 26.04' "$BOOTSTRAP" has '26\.04'
|
||||
contract 'bf-bootstrap has a read-only check mode' "$BOOTSTRAP" has 'CHECK_MODE'
|
||||
|
|
@ -418,7 +418,7 @@ stripped_rc=$?
|
|||
set -e
|
||||
expect_rc 'bf-bootstrap succeeds even when the Python console is absent' 0 "$stripped_rc"
|
||||
expect_contains 'bf-bootstrap warns when the Python console is not in the clone' "$WORK/apply-stripped.out" 'admin/bf is not present'
|
||||
expect_contains 'bf-bootstrap still links the bash fallback' "$WORK/apply-stripped.out" 'bf-menu ready'
|
||||
expect_contains 'bf-bootstrap reports the missing Python console' "$WORK/apply-stripped.out" 'admin/bf is not present'
|
||||
rm -rf "$STRIPPED_REPO" "$WORK/stripped-bin" "$WORK/stripped-checkout"
|
||||
linked1="$(find "$APPLY_ROOT/bin" -maxdepth 1 -type l 2>/dev/null | wc -l | tr -d ' ')"
|
||||
check
|
||||
|
|
|
|||
Loading…
Reference in a new issue