cp-scripts-to-chroot.sh: New script for copying this repo's scripts over to specified...
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 14 Sep 2021 20:57:23 +0000 (21:57 +0100)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 14 Sep 2021 20:57:23 +0000 (21:57 +0100)
cp-scripts-to-chroot.sh [new file with mode: 0755]

diff --git a/cp-scripts-to-chroot.sh b/cp-scripts-to-chroot.sh
new file mode 100755 (executable)
index 0000000..20ec540
--- /dev/null
@@ -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
+