mirror of https://github.com/ericonr/dotfiles.git
Add scripts for chrooting into a glibc boot env.
- fish_prompt: to indicate that one is inside the chrooted fs - launch-chroot: chroots into the folder, can be turned into C program at some point to become setuid - mount-zvol: commmand to mount zvols that have mountpoint= set - chroot-mnt service: starts up the mounts, kills them with `sv down`. service-and-tz.sh script was updated to install it
This commit is contained in:
parent
19786cf9bc
commit
064c9b09bb
|
@ -1 +1,5 @@
|
|||
source ("starship" init fish --print-full-init | psub)
|
||||
if [ $CHROOTED ]
|
||||
alias fish_prompt='echo "[chroot]" (pwd) "> "'
|
||||
else
|
||||
source ("starship" init fish --print-full-init | psub)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
# use with sudo -E
|
||||
|
||||
ROOTDIR="${1:-/mnt}"
|
||||
USERNAME="${SUDO_USER:-ericonr}"
|
||||
|
||||
chroot "$ROOTDIR" /bin/sudo -u $USERNAME \
|
||||
env CHROOTED=1 \
|
||||
XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
|
||||
WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
|
||||
DISPLAY=$DISPLAY \
|
||||
/bin/fish -C "cd"
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
DEVICE="${1:-zroot/ROOT/glibc}"
|
||||
MOUNT="${2:-/mnt}"
|
||||
|
||||
mount -o zfsutil -t zfs "$DEVICE" "$MOUNT"
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
ROOTDIR=/mnt
|
||||
|
||||
umount -R \
|
||||
"$ROOTDIR/dev" \
|
||||
"$ROOTDIR/proc" \
|
||||
"$ROOTDIR/sys" \
|
||||
"$ROOTDIR/etc/resolv.conf" \
|
||||
"$ROOTDIR/tmp" \
|
||||
"$ROOTDIR/home" \
|
||||
"$ROOTDIR/run"
|
||||
|
||||
rm -f "$ROOTDIR/chrooted"
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
ROOTDIR=/mnt
|
||||
|
||||
mount -o zfsutil -t zfs zroot/ROOT/glibc "$ROOTDIR"
|
||||
|
||||
if ! [ -e "$ROOTDIR/chrooted" ]; then
|
||||
# chroot has been launched already
|
||||
|
||||
# xchroot commands
|
||||
mount --rbind /dev "$ROOTDIR/dev"
|
||||
mount --rbind /proc "$ROOTDIR/proc"
|
||||
mount --rbind /sys "$ROOTDIR/sys"
|
||||
touch "$ROOTDIR/etc/resolv.conf"
|
||||
mount --bind /etc/resolv.conf "$ROOTDIR/etc/resolv.conf"
|
||||
|
||||
mount --bind /tmp "$ROOTDIR/tmp"
|
||||
mount --bind /home "$ROOTDIR/home"
|
||||
mount --rbind /run "$ROOTDIR/run"
|
||||
|
||||
touch "$ROOTDIR/chrooted"
|
||||
fi
|
||||
|
||||
exec pause
|
|
@ -0,0 +1 @@
|
|||
/run/runit/supervise.chroot-mnt
|
|
@ -10,9 +10,9 @@ fi
|
|||
|
||||
echo "Installing services"
|
||||
for service in \
|
||||
alsa bluetoothd boltd chronyd dbus dhcpcd elogind iwd popcorn snooze-daily
|
||||
bluetoothd boltd chronyd dbus dhcpcd elogind iwd popcorn snooze-daily
|
||||
do
|
||||
if [ -r "/etc/sv/${service}" ] ; then
|
||||
if [ -r "$MOUNTDIR/etc/sv/${service}" ] ; then
|
||||
ln -s "/etc/sv/${service}" "$SERVICES"
|
||||
echo "Installed service ${service}"
|
||||
else
|
||||
|
@ -20,5 +20,7 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
cp -r etc-x86/sv/chroot-mnt "$SERVICES"
|
||||
|
||||
echo "Setting timezone"
|
||||
ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
|
||||
|
|
Loading…
Reference in New Issue