summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-09-01 20:43:23 +0200
committerKarel Kočí <cynerd@email.cz>2018-09-01 21:10:03 +0200
commit68a776e88d83602c43d34636b7abde5196e50f37 (patch)
treea4f4fade21879f7918bbad0dc7d3c3502453e3eb /scripts
parent50162678eb467b16970a3bdeed0a477f08c4025c (diff)
downloadlaminar-cnf-68a776e88d83602c43d34636b7abde5196e50f37.tar.gz
laminar-cnf-68a776e88d83602c43d34636b7abde5196e50f37.tar.bz2
laminar-cnf-68a776e88d83602c43d34636b7abde5196e50f37.zip
alpinelinux-amd64: add initial implementation
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/uchroot33
-rw-r--r--scripts/utils1
2 files changed, 34 insertions, 0 deletions
diff --git a/scripts/uchroot b/scripts/uchroot
new file mode 100755
index 0000000..77f3f10
--- /dev/null
+++ b/scripts/uchroot
@@ -0,0 +1,33 @@
+#!/bin/sh
+set -e
+[ $# -ge 1 ] || {
+ echo "Usage: uchroot ROOT [CMD] [ARG].." >&2
+ exit 1
+}
+
+if [ "$(id -u)" != "0" ]; then
+ exec uroot "$0" "$@"
+fi
+###############################################################
+
+ROOT="$1"
+shift
+[ -d "$ROOT" ] || {
+ echo "There is no such directory: $ROOT" >&2
+ exit 1
+}
+[ -d "$ROOT/proc" -a -d "$ROOT/dev" -a -d "$ROOT/sys" ] || {
+ echo "Root seems to not contain valid rootfs: $ROOT" >&2
+ exit 1
+}
+
+
+mount -t proc none "$ROOT/proc"
+mount --rbind /dev "$ROOT/dev"
+mount --rbind /sys "$ROOT/sys"
+cp -f /etc/resolv.conf "$ROOT/etc/resolv.conf"
+
+if [ $# -lt 1 ]; then
+ set "/bin/sh"
+fi
+exec chroot "$ROOT" "$@"
diff --git a/scripts/utils b/scripts/utils
index 8781882..103d471 100644
--- a/scripts/utils
+++ b/scripts/utils
@@ -1,6 +1,7 @@
# vim: ft=sh
[ -n "$LAMINAR_COMMON" ] # variables definition guard
+V="${V:-0}"
if [ "$V" -ge 3 ]; then
set -x
fi