forked from obel1x/fedora-OEMDRV
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:
@@ -17,7 +17,7 @@ cp /opt/sys_config/system_setup/config.dist/setup_system.conf.dist /opt/sys_conf
|
|||||||
# Edit setup_system.conf with your domain, server FQDNs, paths, etc.
|
# Edit setup_system.conf with your domain, server FQDNs, paths, etc.
|
||||||
```
|
```
|
||||||
|
|
||||||
Local per-machine overrides go in `config.d/*.conf` (gitignored). These are sourced after `setup_system.conf` and can override any exported variable (e.g. `config.d/system_defines.conf` overrides `UPGRADEBRANCH`).
|
Local per-machine overrides go in `config.d/*.conf` (gitignored). These are sourced after `setup_system.conf` and can override any exported variable (e.g. `config.d/system_defines.conf` overrides `REPO_BRANCH`).
|
||||||
|
|
||||||
`config/skel.tar.zst` (gitignored) holds the `/etc/skel` archive deployed to new installs. The `.dist` version is at `system_setup/skel/skel.tar.zst.dist`. To modify skel: extract, edit, then repack:
|
`config/skel.tar.zst` (gitignored) holds the `/etc/skel` archive deployed to new installs. The `.dist` version is at `system_setup/skel/skel.tar.zst.dist`. To modify skel: extract, edit, then repack:
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ Optionally add local per-machine overrides in `config.d/`:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Example: use the devel branch on this machine
|
# Example: use the devel branch on this machine
|
||||||
echo 'export UPGRADEBRANCH="devel"' > /opt/sys_config/config.d/system_defines.conf
|
echo 'export REPO_BRANCH="devel"' > /opt/sys_config/config.d/system_defines.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
Once configured, boot the Fedora installer from USB — Anaconda will detect the `OEMDRV` partition and run the Kickstart automatically.
|
Once configured, boot the Fedora installer from USB — Anaconda will detect the `OEMDRV` partition and run the Kickstart automatically.
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if [ ! -f ${FQFILENAME} ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if there is a Partition OEMDRV and on which Drive
|
# Check if there is a Partition OEMDRV and on which Drive
|
||||||
/mnt/anaconda_pre/system_setup/setup_system.inc.sh
|
. /mnt/anaconda_pre/system_setup/setup_system.inc.sh
|
||||||
OEMDRVINFO=$(blkid | grep 'LABEL="OEMDRV"')
|
OEMDRVINFO=$(blkid | grep 'LABEL="OEMDRV"')
|
||||||
if [ "${OEMDRVINFO}." == "." ] ; then
|
if [ "${OEMDRVINFO}." == "." ] ; then
|
||||||
echo "* Error: Required partition with label 'OEMDRV' is not found."
|
echo "* Error: Required partition with label 'OEMDRV' is not found."
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ export SERVERFQDN_IPA=ipa.${TLDOMAIN} # Needs to be the IPA- Server
|
|||||||
export SERVERFQDN_NC=nextcloud.${TLDOMAIN}
|
export SERVERFQDN_NC=nextcloud.${TLDOMAIN}
|
||||||
export INSTALLDOCS="https://gitea.dtext.online/obel1x/fedora-OEMDRV/src/branch/main/README.md"
|
export INSTALLDOCS="https://gitea.dtext.online/obel1x/fedora-OEMDRV/src/branch/main/README.md"
|
||||||
|
|
||||||
#If the UPGRADEURL and branch is set, this script collection will do automatic upgrades
|
#If the REPO_URL and REPO_BRANCH is set, this script collection will do automatic upgrades
|
||||||
export UPGRADEURL="https://gitea.dtext.online/obel1x/fedora-OEMDRV.git"
|
export REPO_URL="https://gitea.dtext.online/obel1x/fedora-OEMDRV.git"
|
||||||
export UPGRADEBRANCH="main"
|
export REPO_BRANCH="main"
|
||||||
|
|
||||||
#Configuration Files - maybe syned with your companies settings
|
#Configuration Files - maybe syned with your companies settings
|
||||||
export SYSCONFIGPATH="/opt/sys_config"
|
export SYSCONFIGPATH="/opt/sys_config"
|
||||||
|
|||||||
+35
-35
@@ -69,7 +69,7 @@ do_clone_and_done() {
|
|||||||
info "Cloning $REPO_URL into $MOUNT_POINT..."
|
info "Cloning $REPO_URL into $MOUNT_POINT..."
|
||||||
cd "$MOUNT_POINT" || die "Cannot cd to $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."
|
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"
|
finish_install "$dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,8 +361,8 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then
|
if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then
|
||||||
info "Reading existing configuration..."
|
info "Reading existing configuration from ${MOUNT_POINT} ..."
|
||||||
$MOUNT_POINT/system_setup/setup_system.inc.sh
|
source "$MOUNT_POINT/system_setup/setup_system.inc.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Check existing git repository origin ──────────────────────────────
|
# ── 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" "Existing:" "$EXIST_URL" "$EXIST_BRANCH"
|
||||||
printf " %-12s %-55s %s\n" "Configured:" "$REPO_URL" "$REPO_BRANCH"
|
printf " %-12s %-55s %s\n" "Configured:" "$REPO_URL" "$REPO_BRANCH"
|
||||||
echo
|
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 " How should this be resolved?"
|
||||||
echo " 1) Keep existing origin/branch — pull latest from $EXIST_URL / $EXIST_BRANCH"
|
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 " 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"
|
while true; do
|
||||||
read -r -p " Choice [1/2/3]: " GIT_CHOICE
|
read -r -p " Choice [1/2]: " GIT_CHOICE
|
||||||
case "${GIT_CHOICE}" in
|
case "${GIT_CHOICE}" in
|
||||||
1)
|
1)
|
||||||
REPO_URL="$EXIST_URL"
|
REPO_URL="$EXIST_URL"
|
||||||
REPO_BRANCH="$EXIST_BRANCH"
|
REPO_BRANCH="$EXIST_BRANCH"
|
||||||
info "Fetching latest from $REPO_URL (branch: $REPO_BRANCH)..."
|
break
|
||||||
git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \
|
;;
|
||||||
|| die "git fetch failed."
|
2)
|
||||||
git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \
|
info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..."
|
||||||
|| die "git checkout failed."
|
git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \
|
||||||
$MOUNT_POINT/system_setup/setup_system.inc.sh
|
|| die "git remote set-url failed."
|
||||||
finish_install "$EXISTING_OEMDRV_DEV"
|
break
|
||||||
exit 0
|
;;
|
||||||
;;
|
*)
|
||||||
2)
|
echo " Please enter 1 or 2."
|
||||||
info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..."
|
;;
|
||||||
git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \
|
esac
|
||||||
|| die "git remote set-url failed."
|
done
|
||||||
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
|
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
|
# No git repo on the partition — clear and do a fresh clone
|
||||||
if [[ -n "$(ls -A "$MOUNT_POINT" 2>/dev/null)" ]]; then
|
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
|
find "$MOUNT_POINT" -mindepth 1 -delete
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -5,45 +5,54 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
#
|
#
|
||||||
# This is not a runnig script-file. No real logic to execute. Its used for includes in other scripts.
|
# This is not a runnig script-file. No real logic to execute. Its used for includes in other scripts.
|
||||||
|
#
|
||||||
|
# Parameters (pass as arguments to the `source` call, e.g. source setup_system.inc.sh --missingconfok):
|
||||||
|
# --missingconfok Print a warning instead of prompting and aborting when config/setup_system.conf is missing.
|
||||||
|
|
||||||
#Check if we are root
|
# Parse flags passed to this inc (e.g. source setup_system.inc.sh --missingconfok).
|
||||||
# Deprectaed - use if Statement itself
|
# In bash, arguments to `source` temporarily replace $@ for the duration of the sourced file.
|
||||||
#check_root()
|
_INC_MISSINGCONFOK=0
|
||||||
#{
|
for _inc_arg in "$@"; do
|
||||||
# if [ "$EUID" -ne 0 ]; then
|
[[ "$_inc_arg" == "--missingconfok" ]] && _INC_MISSINGCONFOK=1
|
||||||
# return 1
|
done
|
||||||
# fi
|
unset _inc_arg
|
||||||
# return 0
|
|
||||||
#}
|
|
||||||
|
|
||||||
#First, get the machine_uuid wich is needed by some userspace programs.
|
#Get the machine_uuid wich is needed by some userspace programs.
|
||||||
#As all Parameters that are bound to CPU or Mainboard, are only readable by root, we need to get the values at installtime.
|
#As all Parameters that are bound to CPU or Mainboard, are only readable by root, we need to get the values at installtime.
|
||||||
#On old installations without the file, we will write it whenever possible
|
#On old installations without the file, we will write it whenever possible
|
||||||
if [ -f $( dirname "$0" )/config.d/machine_uuid.sys ]; then
|
if [ -f $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys ]; then
|
||||||
export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )"
|
export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )"
|
||||||
elif [ "$EUID" -eq 0 ]; then
|
elif [ "$EUID" -eq 0 ]; then
|
||||||
dmidecode -t system | grep -i 'UUID' \
|
dmidecode -t system | grep -i 'UUID' \
|
||||||
| sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \
|
| sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \
|
||||||
| sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \
|
| sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \
|
||||||
> "$( dirname "$0" )/config.d/machine_uuid.sys"
|
> "$( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys"
|
||||||
export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )"
|
export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Check for configure.conf - used for frist setup of system
|
#Check for configure.conf - used for first setup of system
|
||||||
if [[ -f $(dirname "$0")/../config.d/configure.conf ]]; then
|
if [[ -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf ]]; then
|
||||||
echo "System in configure-mode. Will use $(dirname "$0")/../config.d/configure.conf for setup."
|
echo "System in configure-mode. Will use $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf for setup."
|
||||||
source $(dirname "$0")/../config.d/configure.conf
|
source $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf
|
||||||
else
|
else
|
||||||
#Load default system setup file
|
#Load default system setup file
|
||||||
if [[ ! -f $(dirname "$0")/../config/setup_system.conf ]]; then
|
if [[ ! -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf ]]; then
|
||||||
echo "System configuration not found. Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running."
|
echo "System configuration not found."
|
||||||
echo "Press any key to continue" && read -n 1 -s -r && exit 1
|
echo "Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running."
|
||||||
|
if [[ $_INC_MISSINGCONFOK -eq 1 ]]; then
|
||||||
|
echo "WARNING: Continuing without system configuration (--missingconfok)."
|
||||||
|
else
|
||||||
|
echo "Press any key to continue" && read -n 1 -s -r && exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Found and use configfile $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf"
|
||||||
|
source $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf
|
||||||
fi
|
fi
|
||||||
source $(dirname "$0")/../config/setup_system.conf
|
|
||||||
|
|
||||||
#Parse additional client-configs
|
#Parse additional client-configs
|
||||||
if [[ `ls -1 $(dirname "$0")/../config.d/*.conf 2>/dev/null | wc -l ` -gt 0 ]]; then
|
if [[ `ls -1 $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf 2>/dev/null | wc -l ` -gt 0 ]]; then
|
||||||
source $(dirname "$0")/../config.d/*.conf
|
echo "Additional config file found $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf - using it"
|
||||||
|
source $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -34,29 +34,29 @@ echo ""
|
|||||||
#Do an upgrade of the Base package if its configured and if there are changes
|
#Do an upgrade of the Base package if its configured and if there are changes
|
||||||
chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH}
|
chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH}
|
||||||
chmod ug+rwX,o=rX -R ${SYSCONFIGPATH}
|
chmod ug+rwX,o=rX -R ${SYSCONFIGPATH}
|
||||||
if [[ ! -z "${UPGRADEURL}" ]]; then
|
if [[ ! -z "${REPO_URL}" ]]; then
|
||||||
echo "Checking for Upgrades on ${UPGRADEURL} and Branch ${UPGRADEBRANCH}"
|
echo "Checking for Upgrades on ${REPO_URL} and Branch ${REPO_BRANCH}"
|
||||||
REMOTEURL=$( git config --get remote.origin.url )
|
REMOTEURL=$( git config --get remote.origin.url )
|
||||||
echo "Remote git URL is ${REMOTEURL}"
|
echo "Remote git URL is ${REMOTEURL}"
|
||||||
if [[ "${REMOTEURL}" != "${UPGRADEURL}" ]]; then
|
if [[ "${REMOTEURL}" != "${REPO_URL}" ]]; then
|
||||||
echo "This Repo is not on the matching URL, so no update is possible. If you want to change this, check out the docs on how to setup from scratch."
|
echo "This Repo is not on the matching URL, so no update is possible. If you want to change this, check out the docs on how to setup from scratch."
|
||||||
else
|
else
|
||||||
GITBRANCH=$( git rev-parse --abbrev-ref HEAD )
|
GITBRANCH=$( git rev-parse --abbrev-ref HEAD )
|
||||||
echo "Current branch is ${GITBRANCH}"
|
echo "Current branch is ${GITBRANCH}"
|
||||||
if [[ "${GITBRANCH}" != "${UPGRADEBRANCH}" ]]; then
|
if [[ "${GITBRANCH}" != "${REPO_BRANCH}" ]]; then
|
||||||
echo "This Repo is not on the right branch, so no update is possible."
|
echo "This Repo is not on the right branch, so no update is possible."
|
||||||
else
|
else
|
||||||
# Doing upgrade, discarding all local changes frist (is more save than forced pull)
|
# Doing upgrade, discarding all local changes frist (is more save than forced pull)
|
||||||
echo "Checks have passed, we are now upgrading via git."
|
echo "Checks have passed, we are now upgrading via git."
|
||||||
#Fetch latest Updates and remove all history
|
#Fetch latest Updates and remove all history
|
||||||
git fetch origin && git reset --hard origin/${UPGRADEBRANCH} && git rebase HEAD^
|
git fetch origin && git reset --hard origin/${REPO_BRANCH} && git rebase HEAD^
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Error: Failure while updating, will continue as is."
|
echo "Error: Failure while updating, will continue as is."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "UPGRADEURL is not specified in conf - No Upgrade option available."
|
echo "REPO_URL is not specified in conf - No Upgrade option available."
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user