From 844a918bfd385b4724c11836461df77edc1a84d6 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Thu, 29 Jun 2023 14:38:41 -0600 Subject: [PATCH 1/7] Update installed check messaging --- scripts/bootstrap/bootstrap | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index 6a278c10d..b834a06e0 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -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" + 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 } From 8a55344d43feb8de705bec4d4c3ad3894699fd0a Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Thu, 29 Jun 2023 17:10:08 -0600 Subject: [PATCH 2/7] Remove duplicate line --- scripts/bootstrap/bootstrap | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index b834a06e0..ad597ce3e 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -62,7 +62,6 @@ exists-non-empty() { } already-installed-message() { - log "Toltec is already installed or partially installed" 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" From dfdeb3cdd587c2249945f59c18f9bed8aa893a06 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Thu, 29 Jun 2023 17:43:57 -0600 Subject: [PATCH 3/7] Add missing local declaration --- scripts/bootstrap/bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index ad597ce3e..6a6f603bf 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -71,6 +71,7 @@ already-installed-message() { # remain from previous installs check-installed() { local unit_path + local unit 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 From fae7b1d696ed24a502bd21db5ee68aa8ce82db80 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Fri, 31 May 2024 13:13:41 -0600 Subject: [PATCH 4/7] Update package --- package/toltec-bootstrap/package | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/toltec-bootstrap/package b/package/toltec-bootstrap/package index 5edac385b..cc1d68274 100644 --- a/package/toltec-bootstrap/package +++ b/package/toltec-bootstrap/package @@ -5,8 +5,8 @@ pkgnames=(toltec-bootstrap) pkgdesc="Manage your Toltec install" url=https://toltec-dev.org/ -pkgver=0.4.3-2 -timestamp=2024-05-30T20:02Z +pkgver=0.4.4-1 +timestamp=2024-05-31T19:13Z section="utils" maintainer="Eeems " license=MIT From 83b9fcd68af9ed646016f68e5de04654b2bf999f Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Fri, 31 May 2024 13:31:38 -0600 Subject: [PATCH 5/7] Add note about unit_path --- scripts/bootstrap/bootstrap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index 5cde333a7..4261d0a70 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -72,6 +72,8 @@ already-installed-message() { check-installed() { local unit_path local unit + # This should mimic get-bind-mount-path as close as possible to ensure it's always + # the path that an install or reenable would generate. 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 From 57787107ce3e7bc4a1e3ad554eecd7fd33f16f56 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 2 Jun 2024 12:44:27 -0600 Subject: [PATCH 6/7] Error if trying to run with sh or other non-bash shell --- scripts/bootstrap/bootstrap | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index 4261d0a70..744f37656 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -15,6 +15,11 @@ # # +if [ -z "$BASH" ] || [[ "$(ps | grep $(echo $$) | awk '{print $5}' | grep -v grep)" != "bash" ]]; then + echo "bootstrap must be run with bash" + exit 1 +fi + set -eEuo pipefail # Path to the temporary local wget and Opkg binaries From 2b20767197ac6296e62711e8016ab0586f39d3a8 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 2 Jun 2024 12:47:16 -0600 Subject: [PATCH 7/7] Update bootstrap --- scripts/bootstrap/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bootstrap/bootstrap b/scripts/bootstrap/bootstrap index 744f37656..15da30019 100755 --- a/scripts/bootstrap/bootstrap +++ b/scripts/bootstrap/bootstrap @@ -15,7 +15,7 @@ # # -if [ -z "$BASH" ] || [[ "$(ps | grep $(echo $$) | awk '{print $5}' | grep -v grep)" != "bash" ]]; then +if [ -z "$BASH" ] || [[ "$(ps | awk '$1=='$$' { n=split($5,a,"/"); print a[n] }')" != "bash" ]]; then echo "bootstrap must be run with bash" exit 1 fi