diff --git a/extra/schroot b/extra/schroot deleted file mode 100755 index 1289c7e..0000000 --- a/extra/schroot +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# scratchpkg -# -# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -RED='\e[0;31m' #Red -GREEN='\e[0;32m' #Green -CRESET='\e[0m' #Reset color - -msg() { - echo -e "${GREEN}==>${CRESET} $1" -} - -msgerr() { - echo -e "${RED}==> ERROR:${CRESET} $1" -} - -if [ "$UID" != "0" ]; then - msgerr "Chroot need root access!" - exit 1 -fi - -LFS=$1 - -if [ -z $1 ]; then - msgerr "Please set directory for chroot!" - exit 1 -fi - -if [ ! -d $LFS ]; then - msgerr "Directory '$LFS' not exist" - exit 1 -fi - -pushd $LFS - -mount -v --bind /dev $LFS/dev -mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620 -mount -vt proc proc $LFS/proc -mount -vt sysfs sysfs $LFS/sys -mount -vt tmpfs tmpfs $LFS/run - -if [ -h $LFS/dev/shm ]; then - mkdir -pv $LFS/$(readlink $LFS/dev/shm) -fi - -chroot "$LFS" /usr/bin/env -i \ -HOME=/root \ -TERM="$TERM" \ -PS1='\u:\w\$ ' \ -PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login - -popd -msg "Chroot exited" - -msg "Unmounting virtual filesystem" -umount -v $LFS/dev/pts -umount -v $LFS/dev -umount -v $LFS/run -umount -v $LFS/proc -umount -v $LFS/sys - -exit $? diff --git a/extra/vchroot b/extra/vchroot new file mode 100755 index 0000000..8b495ce --- /dev/null +++ b/extra/vchroot @@ -0,0 +1,73 @@ +#!/bin/bash + +printhelp() { + cat << EOF + +Usage: + $(basename $0) + +(omit command to chroot only) + +EOF +} + +msgerr() { + echo -e "ERROR: $@" +} + +if [ "$UID" != "0" ]; then + msgerr "$(basename $0) need root access!" + printhelp + exit 1 +fi + +LFS=$1 + +if [ -z $1 ]; then + msgerr "Please set directory for chroot!" + printhelp + exit 1 +fi + +if [ ! -d $LFS ]; then + msgerr "Directory '$LFS' not exist" + printhelp + exit 1 +fi + +shift + +CMD=$@ +if [ -z $2 ]; then + CMD="/bin/bash --login" +fi + +pushd $LFS &>/dev/null + +mount --bind /dev $LFS/dev +mount -t devpts devpts $LFS/dev/pts -o gid=5,mode=620 +mount -t proc proc $LFS/proc +mount -t sysfs sysfs $LFS/sys +mount -t tmpfs tmpfs $LFS/run + +if [ -h $LFS/dev/shm ]; then + mkdir -p $LFS/$(readlink $LFS/dev/shm) +fi + +cp -L /etc/resolv.conf $LFS/etc + +chroot "$LFS" /usr/bin/env -i \ +HOME=/root \ +TERM="$TERM" \ +PS1='\u:\w\$ ' \ +PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD + +popd &>/dev/null + +umount $LFS/dev/pts +umount $LFS/dev +umount $LFS/run +umount $LFS/proc +umount $LFS/sys + +exit $?