lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 6cf9a9a 1/2: Abstract the normal user name fo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 6cf9a9a 1/2: Abstract the normal user name for chroot setup
Date: Tue, 8 Oct 2019 19:43:29 -0400 (EDT)

branch: master
commit 6cf9a9a5041b926fb8d48bca9f585f6a02e3c60d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Abstract the normal user name for chroot setup
---
 install_centos.sh | 28 ++++++++++++++--------------
 install_redhat.sh | 14 +++++++-------
 lmi_setup_00.sh   | 10 +++++-----
 lmi_setup_11.sh   |  4 ++--
 lmi_setup_21.sh   | 44 ++++++++++++++++++++++----------------------
 lmi_setup_30.sh   |  2 +-
 lmi_setup_41.sh   | 12 ++++++------
 lmi_setup_inc.sh  |  1 +
 8 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/install_centos.sh b/install_centos.sh
index 04ad6e5..4414216 100755
--- a/install_centos.sh
+++ b/install_centos.sh
@@ -37,8 +37,8 @@ cat >/etc/schroot/chroot.d/centos7lmi.conf <<EOF
 [centos7lmi]
 description=centos-7.7
 directory=/srv/chroot/centos7lmi
-users=greg
-groups=greg
+users="${NORMAL_USER}"
+groups="${NORMAL_USER}"
 root-groups=root
 type=plain
 EOF
@@ -67,17 +67,17 @@ chmod 666 /dev/null
 chmod 666 /dev/ptmx
 [ -d /dev/pts  ] || mkdir /dev/pts
 
-getent group greg || groupadd --gid=1000 greg
-getent passwd greg || useradd --gid=1000 --groups=greg --uid=1000 \
+getent group "${NORMAL_USER}" || groupadd --gid=1000 "${NORMAL_USER}"
+getent passwd "${NORMAL_USER}" || useradd --gid=1000 --groups="${NORMAL_USER}" 
--uid=1000 \
   --create-home --shell=/bin/zsh \
-  --password="$(openssl passwd -1 expired)" greg
+  --password="$(openssl passwd -1 expired)" "${NORMAL_USER}"
 
 mountpoint /dev/pts || mount -t devpts -o rw,nosuid,noexec,relatime,mode=600 
devpts /dev/pts
 mountpoint /proc    || mount -t proc -o rw,nosuid,nodev,noexec,relatime proc 
/proc
 
 yum --assumeyes install ncurses-term zsh
 chsh -s /bin/zsh root
-chsh -s /bin/zsh greg
+chsh -s /bin/zsh "${NORMAL_USER}"
 
 # Make a more modern 'git' available via 'scl'. This is not needed
 # if all real work is done in a debian chroot.
@@ -114,15 +114,15 @@ chmod +x /srv/chroot/centos7lmi/tmp/setup0.sh
 schroot --chroot=centos7lmi --user=root --directory=/tmp ./setup0.sh
 
 cp -a ~/.zshrc /srv/chroot/centos7lmi/root/.zshrc
-cp -a ~/.zshrc /srv/chroot/centos7lmi/home/greg/.zshrc
+cp -a ~/.zshrc /srv/chroot/centos7lmi/home/"${NORMAL_USER}"/.zshrc
 
 cat >/srv/chroot/centos7lmi/etc/schroot/chroot.d/"${CHRTNAME}".conf <<EOF
 [${CHRTNAME}]
 aliases=lmi
 description=debian ${CODENAME} cross build ${CHRTVER}
 directory=/srv/chroot/${CHRTNAME}
-users=greg
-groups=greg
+users="${NORMAL_USER}"
+groups="${NORMAL_USER}"
 root-groups=root
 type=plain
 EOF
@@ -159,11 +159,11 @@ set -vx
 cp -a lmi_setup_*.sh /srv/chroot/${CHRTNAME}/tmp
 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
+# sudo -u "${NORMAL_USER}" ./lmi_setup_30.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_40.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_41.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_42.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_43.sh
 EOF
 
 chmod +x /srv/chroot/centos7lmi/tmp/setup1.sh
diff --git a/install_redhat.sh b/install_redhat.sh
index 5421ed1..efc8a99 100755
--- a/install_redhat.sh
+++ b/install_redhat.sh
@@ -72,8 +72,8 @@ cat >/etc/schroot/chroot.d/"${CHRTNAME}".conf <<EOF
 aliases=lmi
 description=debian ${CODENAME} cross build ${CHRTVER}
 directory=/srv/chroot/${CHRTNAME}
-users=greg
-groups=greg
+users="${NORMAL_USER}"
+groups="${NORMAL_USER}"
 root-groups=root
 type=plain
 EOF
@@ -111,11 +111,11 @@ set -evx
 cp -a lmi_setup_*.sh /srv/chroot/${CHRTNAME}/tmp
 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
+# sudo -u "${NORMAL_USER}" ./lmi_setup_30.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_40.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_41.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_42.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_43.sh
 
 stamp1=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
 echo "Finished: $stamp1"
diff --git a/lmi_setup_00.sh b/lmi_setup_00.sh
index 3f264ab..1db6708 100755
--- a/lmi_setup_00.sh
+++ b/lmi_setup_00.sh
@@ -48,11 +48,11 @@ chmod +x lmi_setup_*.sh
 cp -a lmi_setup_*.sh /srv/chroot/${CHRTNAME}/tmp
 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
+sudo -u "${NORMAL_USER}" ./lmi_setup_30.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_40.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_41.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_42.sh
+schroot --chroot=${CHRTNAME} --user="${NORMAL_USER}" --directory=/tmp 
./lmi_setup_43.sh
 
 stamp1=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
 echo "Finished: $stamp1"
diff --git a/lmi_setup_11.sh b/lmi_setup_11.sh
index 32238c2..61b1ef4 100755
--- a/lmi_setup_11.sh
+++ b/lmi_setup_11.sh
@@ -41,8 +41,8 @@ cat >/etc/schroot/chroot.d/"${CHRTNAME}".conf <<EOF
 aliases=lmi
 description=debian ${CODENAME} cross build ${CHRTVER}
 directory=/srv/chroot/${CHRTNAME}
-users=greg
-groups=greg
+users="${NORMAL_USER}"
+groups="${NORMAL_USER}"
 root-groups=root
 type=plain
 EOF
diff --git a/lmi_setup_21.sh b/lmi_setup_21.sh
index 8d1ffec..7f7aebd 100755
--- a/lmi_setup_21.sh
+++ b/lmi_setup_21.sh
@@ -34,33 +34,33 @@ assert_chrooted
 # done securely in a script. A better password can be set later,
 # interactively, if desired. Forcing the dummy password to expire
 # immediately, thus (e.g.):
-#   chage -d 0 greg
+#   chage -d 0 "${NORMAL_USER}"
 # may seem like a good idea, but invoking schroot with that userid
 # doesn't prompt for a password change.
-groupadd --gid=1000 greg
+groupadd --gid=1000 "${NORMAL_USER}"
 useradd --gid=1000 --groups=sudo --uid=1000 --create-home --shell=/bin/zsh \
-  --password="$(openssl passwd -1 expired)" greg
+  --password="$(openssl passwd -1 expired)" "${NORMAL_USER}"
 
 # Add an 'lmi' group, which may be useful in a multi-user chroot.
 groupadd --gid=1001 lmi
-usermod -aG lmi greg
+usermod -aG lmi "${NORMAL_USER}"
 
 mkdir -p /opt/lmi
-chown greg:lmi /opt/lmi
+chown "${NORMAL_USER}":lmi /opt/lmi
 mkdir -p /etc/opt/lmi
-chown greg:lmi /etc/opt/lmi
+chown "${NORMAL_USER}":lmi /etc/opt/lmi
 mkdir -p /var/opt/lmi
-chown greg:lmi /var/opt/lmi
+chown "${NORMAL_USER}":lmi /var/opt/lmi
 mkdir -p /cache_for_lmi
-chown greg:lmi /cache_for_lmi
+chown "${NORMAL_USER}":lmi /cache_for_lmi
 
-chsh -s /bin/zsh greg
+chsh -s /bin/zsh "${NORMAL_USER}"
 
 # Repair /usr/share/libtool/.../ltmain.sh as indicated here:
 #   https://lists.gnu.org/archive/html/libtool-patches/2011-06/msg00001.html
 # Do this as root because root owns the file.
 
-cat >/home/greg/ltmain.sh.patch <<EOF
+cat >/home/"${NORMAL_USER}"/ltmain.sh.patch <<EOF
 --- /usr/share/libtool/build-aux/ltmain.sh.orig 2016-08-20 12:34:31.000000000 
+0000
 +++ /usr/share/libtool/build-aux/ltmain.sh 2017-08-10 13:10:28.466155965 +0000
 @@ -5555,7 +5555,7 @@
@@ -74,15 +74,15 @@ cat >/home/greg/ltmain.sh.patch <<EOF
  # ifdef __STRICT_ANSI__
 EOF
 
-patch --dry-run --strip=0 --directory=/ </home/greg/ltmain.sh.patch \
- && patch --strip=0 --directory=/ </home/greg/ltmain.sh.patch
+patch --dry-run --strip=0 --directory=/ 
</home/"${NORMAL_USER}"/ltmain.sh.patch \
+ && patch --strip=0 --directory=/ </home/"${NORMAL_USER}"/ltmain.sh.patch
 
 # Configure zsh, for root as well as the user configured above.
 
 wget -N 'https://git.savannah.nongnu.org/cgit/lmi.git/plain/gwc/.zshrc'
 mv .zshrc ~
-cp -a ~/.zshrc /home/greg/.zshrc
-chown greg:greg /home/greg/.zshrc
+cp -a ~/.zshrc /home/"${NORMAL_USER}"/.zshrc
+chown "${NORMAL_USER}":"${NORMAL_USER}" /home/"${NORMAL_USER}"/.zshrc
 
 # Configure vim. Rather than trying to split its contents between
 # '~/.vimrc' and '/etc/vim/vimrc.local', just copy it everywhither.
@@ -90,22 +90,22 @@ chown greg:greg /home/greg/.zshrc
 wget -N 'https://git.savannah.nongnu.org/cgit/lmi.git/plain/gwc/.vimrc'
 mv .vimrc ~
 cp -a ~/.vimrc /etc/vim/vimrc.local
-cp -a ~/.vimrc /home/greg/.vimrc
-chown greg:greg /home/greg/.vimrc
+cp -a ~/.vimrc /home/"${NORMAL_USER}"/.vimrc
+chown "${NORMAL_USER}":"${NORMAL_USER}" /home/"${NORMAL_USER}"/.vimrc
 
 # Without this, 'zg' gives an error message; with it, vim creates a
 # spellfile the first time 'zg' is used, if none already exists.
 mkdir ~/.vim
-mkdir /home/greg/.vim
-chown greg:greg /home/greg/.vim
+mkdir /home/"${NORMAL_USER}"/.vim
+chown "${NORMAL_USER}":"${NORMAL_USER}" /home/"${NORMAL_USER}"/.vim
 # It's a much better idea to copy a mature spellfile hither:
 wget -N 
'https://git.savannah.nongnu.org/cgit/lmi.git/plain/gwc/.vim/spell/en.utf-8.add'
 mkdir ~/.vim/spell
 mv en.utf-8.add ~/.vim/spell/en.utf-8.add
-mkdir /home/greg/.vim/spell
-chown greg:greg /home/greg/.vim/spell
-cp -a ~/.vim/spell/en.utf-8.add /home/greg/.vim/spell/en.utf-8.add
-chown greg:greg /home/greg/.vim/spell/en.utf-8.add
+mkdir /home/"${NORMAL_USER}"/.vim/spell
+chown "${NORMAL_USER}":"${NORMAL_USER}" /home/"${NORMAL_USER}"/.vim/spell
+cp -a ~/.vim/spell/en.utf-8.add /home/"${NORMAL_USER}"/.vim/spell/en.utf-8.add
+chown "${NORMAL_USER}":"${NORMAL_USER}" 
/home/"${NORMAL_USER}"/.vim/spell/en.utf-8.add
 # and then (imperatively) run this command:
 vim -es -c ':mkspell! ~/.vim/spell/en.utf-8.add' -c ':q'
 # which will be repeated below in the user chroot.
diff --git a/lmi_setup_30.sh b/lmi_setup_30.sh
index 09d2284..b664f5d 100755
--- a/lmi_setup_30.sh
+++ b/lmi_setup_30.sh
@@ -48,7 +48,7 @@ cp --dereference --preserve --recursive \
 
 # Configure ssh, iff this chroot needs write access to savannah.
 # The easiest way is to copy existing credentials, e.g.:
-cp -a ~/.ssh/ /srv/chroot/${CHRTNAME}/home/greg
+cp -a ~/.ssh/ /srv/chroot/${CHRTNAME}/home/"${NORMAL_USER}"
 # Make sure the .ssh/config file contains:
 #   Protocol 2
 #   HashKnownHosts no
diff --git a/lmi_setup_41.sh b/lmi_setup_41.sh
index 7e54096..18de3b0 100755
--- a/lmi_setup_41.sh
+++ b/lmi_setup_41.sh
@@ -34,16 +34,16 @@ assert_chrooted
 # "identity mount" technique used with cygwin. See:
 #   https://lists.nongnu.org/archive/html/lmi/2017-05/msg00018.html
 
-mkdir -p ~/.wine/drive_c/users/greg/opt/
-cd ~/.wine/drive_c/users/greg/opt/ || { printf 'failed: cd\n'; exit 3; }
+mkdir -p ~/.wine/drive_c/users/"${NORMAL_USER}"/opt/
+cd ~/.wine/drive_c/users/"${NORMAL_USER}"/opt/ || { printf 'failed: cd\n'; 
exit 3; }
 ln --symbolic --relative --force --no-dereference /opt/lmi/ ./lmi
 
-mkdir -p ~/.wine/drive_c/users/greg/etc/opt/
-cd ~/.wine/drive_c/users/greg/etc/opt/ || { printf 'failed: cd\n'; exit 3; }
+mkdir -p ~/.wine/drive_c/users/"${NORMAL_USER}"/etc/opt/
+cd ~/.wine/drive_c/users/"${NORMAL_USER}"/etc/opt/ || { printf 'failed: cd\n'; 
exit 3; }
 ln --symbolic --relative --force --no-dereference /etc/opt/lmi/ ./lmi
 
-mkdir -p ~/.wine/drive_c/users/greg/var/opt/
-cd ~/.wine/drive_c/users/greg/var/opt/ || { printf 'failed: cd\n'; exit 3; }
+mkdir -p ~/.wine/drive_c/users/"${NORMAL_USER}"/var/opt/
+cd ~/.wine/drive_c/users/"${NORMAL_USER}"/var/opt/ || { printf 'failed: cd\n'; 
exit 3; }
 ln --symbolic --relative --force --no-dereference /var/opt/lmi/ ./lmi
 
 cd ~ || { printf 'failed: cd\n'; exit 3; }
diff --git a/lmi_setup_inc.sh b/lmi_setup_inc.sh
index 6ab16b5..6769529 100755
--- a/lmi_setup_inc.sh
+++ b/lmi_setup_inc.sh
@@ -33,6 +33,7 @@ set -vx
 CODENAME=bullseye
 CHRTVER=1
 CHRTNAME=lmi_${CODENAME}_${CHRTVER}
+NORMAL_USER=greg
 
 set +vx
 



reply via email to

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