]> git.armaanb.net Git - bin.git/commitdiff
chrooter: drop script
authorArmaan Bhojwani <me@armaanb.net>
Fri, 18 Jun 2021 22:03:30 +0000 (18:03 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Fri, 18 Jun 2021 22:03:47 +0000 (18:03 -0400)
chrooter [deleted file]
man/chrooter.1.scd [deleted file]

diff --git a/chrooter b/chrooter
deleted file mode 100755 (executable)
index 49d74fd..0000000
--- a/chrooter
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh -e
-# Enter a chroot nicely. Stolen from KISS Linux, MIT license Dylan Araps 2020.
-# Some slight modifications to make life easier.
-
-log() {
-    printf '\033[32m->\033[m %s.\n' "$*"
-}
-
-die() {
-    log "$*" >&2
-    exit 1
-}
-
-clean() {
-    log Unmounting /dev, /proc and /sys from chroot; {
-    umount "$1/sys/firmware/efi/efivars" 2>/dev/null ||:
-    umount "$1/dev"  ||:
-    umount "$1/proc" ||:
-    umount "$1/sys"  ||:
-}
-
-    log Cleaning leftover host files; {
-        rm -f "$1/root/.ash_history"
-        rm -f "$1/etc/resolv.conf"
-    }
-}
-
-mounted() {
-    # This is a pure shell mountpoint implementation. We're dealing
-    # with basic (and fixed/known) input so this doesn't need to
-    # handle more complex cases.
-    [ -e "$1" ]         || return 1
-    [ -e /proc/mounts ] || return 1
-
-    while read -r _ target _; do
-        [ "$target" = "$1" ] && return 0
-    done < /proc/mounts
-
-    return 1
-}
-
-[ -z "$1" ]        && die Need a path to the chroot
-[ -d "$1" ]        || die Given path does not exist
-[ "$(id -u)" = 0 ] || die Script needs to be run as root
-
-trap 'clean "$1"' EXIT INT
-
-log Mounting /dev, /proc and /sys from host; {
-    mounted "$1/dev"  || mount -o bind /dev "$1/dev"  ||:
-    mounted "$1/proc" || mount -t proc proc "$1/proc" ||:
-    mounted "$1/sys"  || mount -t sysfs sys "$1/sys"  ||:
-
-    mounted "$1/sys/firmware/efi/efivars" ||
-        mount -t efivarfs efivarfs "$1/sys/firmware/efi/efivars" 2>/dev/null ||:
-}
-
-log Copying /etc/resolv.conf from host; {
-    cp -f /etc/resolv.conf "$1/etc" ||:
-}
-
-NEWSHELL=${2:-"/bin/sh"} \
-
-                               log Entering chroot; {
-    chroot "$1" /usr/bin/env -i \
-                                        HOME=/root \
-                                        TERM="$TERM" \
-                                        SHELL=${NEWSHELL} \
-                                        USER=root \
-                                        CFLAGS="${CFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \
-                                        CXXFLAGS="${CXXFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \
-                                        MAKEFLAGS="${MAKEFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \
-                                        DISPLAY="$DISPLAY" \
-                                        "$NEWSHELL" -l
-}
diff --git a/man/chrooter.1.scd b/man/chrooter.1.scd
deleted file mode 100644 (file)
index 9370147..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-chrooter(1)
-
-# NAME
-chrooter - chroot wrapper
-
-# SYNOPSIS
-chrooter [mount point]
-
-# DESCRIPTION
-Directly based on Dylan Arap's kiss-chroot script, this
-
-# COPYRIGHT
-Copyright 2019-2020 Dylan Araps, 2021 Armaan Bhojwani, MIT License.
\ No newline at end of file