summaryrefslogtreecommitdiff
path: root/librechroot
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-05-16 00:44:39 -0500
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-05-16 00:44:39 -0500
commit7f118f53283d7e228c40a40076815ce94ebb94a7 (patch)
treee7b70c0f9f297edc42a1333b38e6e06357edcdd8 /librechroot
parent0fa9894cbc10f0742c3076666524956f7279e8af (diff)
Cleaned up some things, added option parse to some scripts.
Diffstat (limited to 'librechroot')
-rwxr-xr-xlibrechroot39
1 files changed, 26 insertions, 13 deletions
diff --git a/librechroot b/librechroot
index ec437de..b308b7d 100755
--- a/librechroot
+++ b/librechroot
@@ -23,6 +23,19 @@
source /etc/libretools.conf
+function usage {
+ echo "Usage: $0 chrootname"
+ echo "Change to a chroot in $CHROOTDIR. Use it as root."
+ echo
+ echo "Default chroot name: $CHCOPY"
+}
+
+while getopts 'h' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ esac
+done
+
[[ "$UID" != "0" ]] && {
error "This script must be run as root."
exit 1
@@ -32,28 +45,28 @@ custom_config=${XDG_CONFIG_HOME}/libretools/libretools.conf
[[ -e ${custom_config} ]] && source ${custom_config}
# Enter the chroot copy by default
-root=${1:-$CHCOPY}
+chrootname=${1:-$CHCOPY}
CACHEDIR=${CACHEDIR:-/var/cache/pacman/pkg}
-[[ ! -d ${CHROOTDIR}/${root} ]] && {
- error "${CHROOTDIR}/$root is not a dir."
+[[ ! -d ${CHROOTDIR}/${chrootname} ]] && {
+ error "${CHROOTDIR}/${chrootname} is not a dir."
exit 1
}
-mount -t proc proc ${CHROOTDIR}/${root}/proc/
-mount -t sysfs sys ${CHROOTDIR}/${root}/sys/
-mount -o bind /dev ${CHROOTDIR}/${root}/dev/
+mount -t proc proc ${CHROOTDIR}/${chrootname}/proc/
+mount -t sysfs sys ${CHROOTDIR}/${chrootname}/sys/
+mount -o bind /dev ${CHROOTDIR}/${chrootname}/dev/
# Share pacman cache
-mount -o bind ${CACHEDIR} ${CHROOTDIR}/${root}/var/cache/pacman/pkg
+mount -o bind ${CACHEDIR} ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg
-cp -L /etc/resolv.conf ${CHROOTDIR}/${root}/etc/resolv.conf
+cp -L /etc/resolv.conf ${CHROOTDIR}/${chrootname}/etc/resolv.conf
-chroot ${CHROOTDIR}/${root} /bin/bash
+chroot ${CHROOTDIR}/${chrootname} /bin/bash
-umount ${CHROOTDIR}/${root}/proc/
-umount ${CHROOTDIR}/${root}/sys/
-umount ${CHROOTDIR}/${root}/dev/
-umount ${CHROOTDIR}/${root}/var/cache/pacman/pkg
+umount ${CHROOTDIR}/${chrootname}/proc/
+umount ${CHROOTDIR}/${chrootname}/sys/
+umount ${CHROOTDIR}/${chrootname}/dev/
+umount ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg
exit 0