POSIX rewrite: uth.bash

This commit is contained in:
Syahrial Agni Prasetya 2021-05-27 18:07:36 +07:00
parent 01f0cb9923
commit 72ab95d4bf
No known key found for this signature in database
GPG Key ID: 46F88749C8C79383
3 changed files with 32 additions and 32 deletions

View File

@ -50,7 +50,7 @@ install -v -D -m 755 ./src/exec $PREFIX/share/archbox/bin/exec
install -v -D -m 755 ./src/enter $PREFIX/share/archbox/bin/enter
install -v -D -m 755 ./src/chroot_setup $PREFIX/share/archbox/chroot_setup
install -v -D -m 755 ./src/init $PREFIX/share/archbox/bin/init
install -v -D -m 755 ./src/uth.bash $PREFIX/share/archbox/bin/uth
install -v -D -m 755 ./src/uth $PREFIX/share/archbox/bin/uth
grep 'PREFIX=' $ETC_DIR/archbox.conf >/dev/null 2>&1 || cat << EOF >> $ETC_DIR/archbox.conf

31
src/uth Normal file
View File

@ -0,0 +1,31 @@
#!/bin/sh
. /etc/archbox.conf >/dev/null 2>&1
. /tmp/archbox_env >/dev/null 2>&1
case $1 in
copyresolv)
cp /etc/resolv.conf "${CHROOT}"/etc/resolv.conf
;;
killxdg)
umount -l "${CHROOT}"/run
fuser -km $XDG_RUNTIME_DIR
exit $?
;;
runtimeonly)
mkdir -p "${CHROOT}"${XDG_RUNTIME_DIR}
umount -Rl "${CHROOT}"${XDG_RUNTIME_DIR} 2>/dev/null
mount | grep "${CHROOT}"${XDG_RUNTIME_DIR} || \
mount --rbind $XDG_RUNTIME_DIR "${CHROOT}"${XDG_RUNTIME_DIR}
exit $?
;;
remountrun)
umount -l "${CHROOT}"/run 2>/dev/null
mount --rbind /run "${CHROOT}"/run
exit $?
;;
chownvar)
chown $2 /tmp/archbox_env
chmod 755 /tmp/archbox_env
;;
esac

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
source /etc/archbox.conf &>/dev/null
source /tmp/archbox_env &>/dev/null
case $1 in
copyresolv)
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
;;
killxdg)
umount -l $CHROOT/run
fuser -km $XDG_RUNTIME_DIR
exit $?
;;
runtimeonly)
mkdir -p $CHROOT$XDG_RUNTIME_DIR
umount -Rl $CHROOT$XDG_RUNTIME_DIR 2>/dev/null
mount | grep $CHROOT$XDG_RUNTIME_DIR || \
mount --rbind $XDG_RUNTIME_DIR $CHROOT$XDG_RUNTIME_DIR
exit $?
;;
remountrun)
umount -l $CHROOT/run 2>/dev/null
mount --rbind /run $CHROOT/run
exit $?
;;
chownvar)
chown $2 /tmp/archbox_env
chmod 755 /tmp/archbox_env
;;
esac