lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 8838b01 07/10: Make sure each 'lmi_setup*' sc


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 8838b01 07/10: Make sure each 'lmi_setup*' script is run in the right environment
Date: Thu, 26 Sep 2019 09:40:21 -0400 (EDT)

branch: master
commit 8838b01d92d4487d1eff9f78f20773f5ab05aa41
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Make sure each 'lmi_setup*' script is run in the right environment
    
    The "assertions" in other scripts may seem redundant when they're run
    only from the "00" script, but running them independently is a plausible
    use case.
---
 lmi_setup_00.sh  | 22 ++++++++++------------
 lmi_setup_10.sh  |  3 +++
 lmi_setup_11.sh  |  3 +++
 lmi_setup_20.sh  |  3 +++
 lmi_setup_21.sh  |  3 +++
 lmi_setup_30.sh  |  3 +++
 lmi_setup_40.sh  |  3 +++
 lmi_setup_41.sh  |  3 +++
 lmi_setup_42.sh  |  3 +++
 lmi_setup_43.sh  |  3 +++
 lmi_setup_inc.sh | 32 ++++++++++++++++++++++++++++++++
 11 files changed, 69 insertions(+), 12 deletions(-)

diff --git a/lmi_setup_00.sh b/lmi_setup_00.sh
index a232525..bd44a08 100755
--- a/lmi_setup_00.sh
+++ b/lmi_setup_00.sh
@@ -23,21 +23,19 @@
 
 set -vx
 
-if [ "$(id -u)" -ne 0 ]; then
-   echo "Must be run as root."
-   exit 1
-fi
-
 . ./lmi_setup_inc.sh
 
+assert_su
+assert_not_chrooted
+
 # Progressively uncomment these lines as they're tested.
 
 # ./lmi_setup_10.sh
 # ./lmi_setup_11.sh
-# ./lmi_setup_20.sh
-# ./lmi_setup_21.sh
-# ./lmi_setup_30.sh
-# ./lmi_setup_40.sh
-# ./lmi_setup_41.sh
-# ./lmi_setup_42.sh
-# ./lmi_setup_43.sh
+# schroot --chroot=${CHRTNAME} --user=root --directory=/tmp ./lmi_setup_20.sh
+# schroot --chroot=${CHRTNAME} --user=root --directory=/tmp ./lmi_setup_21.sh
+# sudo -u greg ./lmi_setup_30.sh
+# schroot --chroot=${CHRTNAME} --user=greg --directory=/tmp ./lmi_setup_40.sh
+# schroot --chroot=${CHRTNAME} --user=greg --directory=/tmp ./lmi_setup_41.sh
+# schroot --chroot=${CHRTNAME} --user=greg --directory=/tmp ./lmi_setup_42.sh
+# schroot --chroot=${CHRTNAME} --user=greg --directory=/tmp ./lmi_setup_43.sh
diff --git a/lmi_setup_10.sh b/lmi_setup_10.sh
index 925cd7a..9774375 100755
--- a/lmi_setup_10.sh
+++ b/lmi_setup_10.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_su
+assert_not_chrooted
+
 apt-get update
 apt-get install schroot debootstrap
 
diff --git a/lmi_setup_11.sh b/lmi_setup_11.sh
index 0964ce1..ebd1834 100755
--- a/lmi_setup_11.sh
+++ b/lmi_setup_11.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_su
+assert_not_chrooted
+
 # Unpack the OS tarball into the particular chroot being created.
 # (If the preceding apt-get and debootstrap steps have already been
 # completed once, then skip them and start here.)
diff --git a/lmi_setup_20.sh b/lmi_setup_20.sh
index 94bc341..cbd9df7 100755
--- a/lmi_setup_20.sh
+++ b/lmi_setup_20.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_su
+assert_chrooted
+
 # Add i386 before installing wine, so that wine can run 32-bit .exe's .
 
 dpkg --add-architecture i386
diff --git a/lmi_setup_21.sh b/lmi_setup_21.sh
index 64976a0..b312d36 100755
--- a/lmi_setup_21.sh
+++ b/lmi_setup_21.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_su
+assert_chrooted
+
 addgroup --gid=1000 greg
 adduser --gid=1000 --uid=1000 greg
 # enter user password, twice
diff --git a/lmi_setup_30.sh b/lmi_setup_30.sh
index f089a49..9a6643e 100755
--- a/lmi_setup_30.sh
+++ b/lmi_setup_30.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_not_su
+assert_not_chrooted
+
 # If cached lmi downloads are available elsewhere, copy them now.
 # Copying cache_for_lmi/downloads/ is an optional step that merely
 # conserves bandwidth. Directory cache_for_lmi/ in a native msw
diff --git a/lmi_setup_40.sh b/lmi_setup_40.sh
index 1ef49e2..7d531e1 100755
--- a/lmi_setup_40.sh
+++ b/lmi_setup_40.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_not_su
+assert_chrooted
+
 # Initialize wine. See:
 #   https://lists.nongnu.org/archive/html/lmi/2016-10/msg00002.html
 WINEDLLOVERRIDES=mscoree=d wine wineboot
diff --git a/lmi_setup_41.sh b/lmi_setup_41.sh
index c78f8ac..7933ee7 100755
--- a/lmi_setup_41.sh
+++ b/lmi_setup_41.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_not_su
+assert_chrooted
+
 # Symlink directories used by lmi, so that both native and wine
 # builds use the same directories and can share the same
 # architecture-independent 'configurable_settings.xml'--much like the
diff --git a/lmi_setup_42.sh b/lmi_setup_42.sh
index 24f17e3..68ccbe5 100755
--- a/lmi_setup_42.sh
+++ b/lmi_setup_42.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_not_su
+assert_chrooted
+
 # Install lmi for wine.
 
 cd ~ || { printf 'failed: cd\n'; exit 3; }
diff --git a/lmi_setup_43.sh b/lmi_setup_43.sh
index 035c1e4..314ce6f 100755
--- a/lmi_setup_43.sh
+++ b/lmi_setup_43.sh
@@ -25,6 +25,9 @@ set -vx
 
 . ./lmi_setup_inc.sh
 
+assert_not_su
+assert_chrooted
+
 # Symlink the repository's hooks/ directory:
 cd /opt/lmi/src/lmi || { printf 'failed: cd\n'; exit 3; }
 mv .git/hooks .git/hooks-orig
diff --git a/lmi_setup_inc.sh b/lmi_setup_inc.sh
index 14fbd3a..dc4276c 100755
--- a/lmi_setup_inc.sh
+++ b/lmi_setup_inc.sh
@@ -31,3 +31,35 @@ CHRTNAME=lmi_${CODENAME}${CHRTVER}
 # shellcheck disable=SC2034
 #   (this file should only be sourced)
 export CHRTNAME
+
+assert_su()
+{
+if [ "$(id -u)" -ne 0 ]; then
+   echo "Must be run as root."
+   exit 1
+fi
+}
+
+assert_not_su()
+{
+if [ "$(id -u)" -eq 0 ]; then
+   echo "Must not be run as root."
+   exit 1
+fi
+}
+
+assert_chrooted()
+{
+if [ "$(ls -di /)" = "2 /" ]; then
+   echo "Must be run in chroot."
+   exit 1
+fi
+}
+
+assert_not_chrooted()
+{
+if [ "$(ls -di /)" != "2 /" ]; then
+   echo "Must not be run in chroot."
+   exit 1
+fi
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]