inc.sh: use BASH_SOURCE for path resolution; add --missingconfok; fix install.sh sourcing and git pull logic
setup_system.inc.sh: replace $(dirname "$0") with $(dirname "${BASH_SOURCE[0]:-$0}") so
paths resolve correctly whether the file is sourced or executed directly. Add --missingconfok
flag to warn-and-continue instead of prompting+aborting when config is missing. Fix machine_uuid
path (missing ../). Move `source config` into the else branch so it is not reached when
missingconfok skips the exit.
install.sh: source inc.sh instead of executing it as a subprocess so exported variables
(REPO_URL etc.) propagate back to the caller. Fix git-origin conflict handling: when reusing
an existing OEMDRV partition the user has already confirmed they want to keep it, so remove
the "fresh clone / wipe" option entirely. Now always pulls (fetch+checkout) when a git repo
is present; clears and fresh-clones only when no git repo exists on the partition.
basic_pre_script.inc: dot-source inc.sh so INSTALLDOCS and other config vars are available.
config.dist, sync_client_software.sh: rename UPGRADEURL/UPGRADEBRANCH to REPO_URL/REPO_BRANCH
to match the variable names already used in install.sh.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+35
-35
@@ -69,7 +69,7 @@ do_clone_and_done() {
|
||||
info "Cloning $REPO_URL into $MOUNT_POINT..."
|
||||
cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT."
|
||||
git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed."
|
||||
${MOUNT_POINT}/system_setup/setup_system.inc.sh
|
||||
source "$MOUNT_POINT/system_setup/setup_system.inc.sh" --missingconfok
|
||||
finish_install "$dev"
|
||||
}
|
||||
|
||||
@@ -361,8 +361,8 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then
|
||||
fi
|
||||
|
||||
if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then
|
||||
info "Reading existing configuration..."
|
||||
$MOUNT_POINT/system_setup/setup_system.inc.sh
|
||||
info "Reading existing configuration from ${MOUNT_POINT} ..."
|
||||
source "$MOUNT_POINT/system_setup/setup_system.inc.sh"
|
||||
fi
|
||||
|
||||
# ── Check existing git repository origin ──────────────────────────────
|
||||
@@ -377,45 +377,45 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then
|
||||
printf " %-12s %-55s %s\n" "Existing:" "$EXIST_URL" "$EXIST_BRANCH"
|
||||
printf " %-12s %-55s %s\n" "Configured:" "$REPO_URL" "$REPO_BRANCH"
|
||||
echo
|
||||
echo " Hint: set REPO_URL / REPO_BRANCH env vars before running to override the configured values."
|
||||
echo
|
||||
echo " How should this be resolved?"
|
||||
echo " 1) Keep existing origin/branch — pull latest from $EXIST_URL / $EXIST_BRANCH"
|
||||
echo " 2) Switch to configured origin — migrate to $REPO_URL / $REPO_BRANCH (preserves local files)"
|
||||
echo " 3) Fresh clone from configured origin — clears all existing content"
|
||||
read -r -p " Choice [1/2/3]: " GIT_CHOICE
|
||||
case "${GIT_CHOICE}" in
|
||||
1)
|
||||
REPO_URL="$EXIST_URL"
|
||||
REPO_BRANCH="$EXIST_BRANCH"
|
||||
info "Fetching latest from $REPO_URL (branch: $REPO_BRANCH)..."
|
||||
git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \
|
||||
|| die "git fetch failed."
|
||||
git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \
|
||||
|| die "git checkout failed."
|
||||
$MOUNT_POINT/system_setup/setup_system.inc.sh
|
||||
finish_install "$EXISTING_OEMDRV_DEV"
|
||||
exit 0
|
||||
;;
|
||||
2)
|
||||
info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..."
|
||||
git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \
|
||||
|| die "git remote set-url failed."
|
||||
git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \
|
||||
|| die "git fetch failed."
|
||||
git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \
|
||||
|| die "git checkout failed."
|
||||
$MOUNT_POINT/system_setup/setup_system.inc.sh
|
||||
finish_install "$EXISTING_OEMDRV_DEV"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
# Option 3 or anything else: fall through to clear + fresh clone
|
||||
;;
|
||||
esac
|
||||
while true; do
|
||||
read -r -p " Choice [1/2]: " GIT_CHOICE
|
||||
case "${GIT_CHOICE}" in
|
||||
1)
|
||||
REPO_URL="$EXIST_URL"
|
||||
REPO_BRANCH="$EXIST_BRANCH"
|
||||
break
|
||||
;;
|
||||
2)
|
||||
info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..."
|
||||
git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \
|
||||
|| die "git remote set-url failed."
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo " Please enter 1 or 2."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
info "Pulling latest from $REPO_URL (branch: $REPO_BRANCH)..."
|
||||
git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \
|
||||
|| die "git fetch failed."
|
||||
git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \
|
||||
|| die "git checkout failed."
|
||||
source "$MOUNT_POINT/system_setup/setup_system.inc.sh"
|
||||
finish_install "$EXISTING_OEMDRV_DEV"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# No git repo on the partition — clear and do a fresh clone
|
||||
if [[ -n "$(ls -A "$MOUNT_POINT" 2>/dev/null)" ]]; then
|
||||
info "Clearing existing content in $MOUNT_POINT before fresh clone..."
|
||||
info "No git repository found on $MOUNT_POINT — clearing before fresh clone..."
|
||||
find "$MOUNT_POINT" -mindepth 1 -delete
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user