root-enter: new aport
This commit is contained in:
parent
751ea8fef1
commit
87a825d85f
2 changed files with 60 additions and 0 deletions
19
root-enter/APKBUILD
Normal file
19
root-enter/APKBUILD
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
|
||||||
|
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
|
||||||
|
pkgname=root-enter
|
||||||
|
pkgver=1.0.0
|
||||||
|
pkgrel=0
|
||||||
|
pkgdesc="enter chroot with mounts"
|
||||||
|
url="https://git.ddd.rip/ptrcnull/ptrcports"
|
||||||
|
arch="noarch"
|
||||||
|
license="BSD-2-Clause"
|
||||||
|
source="enter"
|
||||||
|
options="!check"
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 enter "$pkgdir"/usr/bin/enter
|
||||||
|
}
|
||||||
|
|
||||||
|
sha512sums="
|
||||||
|
f64c60c1937f4ac6145b3fc00dc9dce8205328009e60219282e8cba5837aff63674d4b3bef2fb751323e21720ab9ff251356817b0c2734ef2ebe315162e6caf8 enter
|
||||||
|
"
|
41
root-enter/enter
Executable file
41
root-enter/enter
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
[ "$unshared" = 1 ] || exec doas env unshared=1 unshare -m $0 $@
|
||||||
|
|
||||||
|
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'"
|
Loading…
Reference in a new issue