Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better bootstrap check-install #704

Merged
merged 16 commits into from
Jun 2, 2024
34 changes: 27 additions & 7 deletions scripts/bootstrap/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,37 @@ exists-non-empty() {
[[ -d $1 ]] && files="$(ls -A -- "$1")" && [[ -n $files ]]
}

already-installed-message() {
log "Toltec is already installed or partially installed"
log "Toltec is already installed or partially installed"
Eeems marked this conversation as resolved.
Show resolved Hide resolved
log "To re-enable Toltec after a system upgrade, run 'toltecctl reenable'"
log "To reinstall Toltec, run 'toltecctl uninstall' first"
}

# Check whether a Toltec install already exists or if conflicting files
# remain from previous installs
check-installed() {
if [[ ! -f $toltecctl_path ]]; then
return
local unit_path
unit_path="/lib/systemd/system/$(systemd-escape --path /opt).mount"
unit="$(basename "$unit_path")"
if [[ -f $unit_path ]] && systemctl --quiet is-active "$unit" 2> /dev/null; then
log ERROR "opt.mount is currently active"
already-installed-message
exit 1
fi

if exists-non-empty /opt || exists-non-empty /home/root/.entware; then
log "Toltec is already installed or partially installed"
log "To re-enable Toltec after a system upgrade, run 'toltecctl reenable'"
log "To reinstall Toltec, run 'toltecctl uninstall' first"
if [[ "$(grep ' /opt ' /proc/mounts)" != "" ]]; then
log ERROR "/opt is currently mounted"
already-installed-message
exit 1
fi
if exists-non-empty /opt; then
log ERROR "/opt exists and is not empty"
already-installed-message
exit 1
fi
if exists-non-empty /home/root/.entware; then
log ERROR "/home/root/.entware exists and is not empty"
already-installed-message
exit 1
fi
}
Expand Down