From 32572e55f04ff96cf0d98fd566e93f048fa0afa8 Mon Sep 17 00:00:00 2001 From: Andrey Miroshnikov Date: Tue, 14 Sep 2021 21:57:23 +0100 Subject: [PATCH] cp-scripts-to-chroot.sh: New script for copying this repo's scripts over to specified chroot --- cp-scripts-to-chroot.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 cp-scripts-to-chroot.sh diff --git a/cp-scripts-to-chroot.sh b/cp-scripts-to-chroot.sh new file mode 100755 index 0000000..20ec540 --- /dev/null +++ b/cp-scripts-to-chroot.sh @@ -0,0 +1,27 @@ +#!/bin/bash +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi +if [ -z "$1" ] + then echo "Need arg $1 to specify which chroot to copy scripts to!" + exit +fi + +chrootdir="$1" + +if [ -e /opt/chroot/$chrootdir ]; then + + cur_dir=$(pwd | grep -o '[^/]*$') + if [ "$cur_dir" == "dev-env-setup" ]; then + echo "Copy over the dev-env-setup scripts to $chrootdir environment" + cp -R ../dev-env-setup /opt/chroot/$chrootdir/home/$SUDO_USER/ + chown -R $SUDO_USER /opt/chroot/$chrootdir/home/$SUDO_USER/dev-env-setup + chgrp -R $SUDO_USER /opt/chroot/$chrootdir/home/$SUDO_USER/dev-env-setup + else + echo "This script must be run from dev-env-setup directory!" + fi +else + echo "$chrootdir environment does not exist, cannot copy scripts!" +fi + -- 2.30.2