2022-04-25 23:10:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-04-25 23:36:44 +00:00
|
|
|
[ "$(id -u)" = 0 ] || DOAS="${DOAS:-doas}"
|
|
|
|
[ "$unshared" = 1 ] || exec $DOAS env unshared=1 unshare -m $0 $@
|
2022-04-25 23:10:13 +00:00
|
|
|
|
|
|
|
bindpoints="/etc/resolv.conf"
|
|
|
|
user="patrycja"
|
|
|
|
command="ash -l"
|
|
|
|
|
|
|
|
while getopts "be:u:s:" opt; do
|
|
|
|
case $opt in
|
|
|
|
'b') bindpoints="
|
|
|
|
$bindpoints
|
|
|
|
/home/patrycja/aports
|
|
|
|
/home/patrycja/packages
|
|
|
|
/home/patrycja/.abuild
|
|
|
|
" ;;
|
|
|
|
'e') bindpoints="$bindpoints $OPTARG" ;;
|
|
|
|
'u') user=$OPTARG ;;
|
|
|
|
'c') command=$OPTARG ;;
|
|
|
|
*) echo "unknown $opt" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
|
|
|
|
mount -t devtmpfs devtmpfs $1/dev
|
|
|
|
mount -t tmpfs shm $1/dev/shm
|
|
|
|
mount -t sysfs sysfs $1/sys
|
|
|
|
mount -t proc proc $1/proc
|
|
|
|
mount -t tmpfs tmpfs $1/tmp
|
|
|
|
for point in $bindpoints; do
|
|
|
|
if [ -f $point ]; then
|
|
|
|
touch $1$point
|
|
|
|
else
|
|
|
|
mkdir -p $1$point
|
|
|
|
fi
|
|
|
|
mount --bind $point $1$point
|
|
|
|
done
|
|
|
|
|
|
|
|
chroot $1 /bin/sh -c "su $user -c '$command'"
|