diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-02-05 19:13:08 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-02-05 19:13:08 +0100 |
commit | b854e8abb7e1ff0b43c9f99e9b641895e4d6c148 (patch) | |
tree | ab8061666835221d155cfb259559752353c8a2e9 /util | |
parent | 2a218ea1205c8dd547b742931290058def5de85f (diff) |
WIP busybox
Diffstat (limited to 'util')
-rwxr-xr-x | util/mkrootfs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/util/mkrootfs b/util/mkrootfs new file mode 100755 index 0000000..5818fdb --- /dev/null +++ b/util/mkrootfs @@ -0,0 +1,40 @@ +#!/bin/sh +OLDPWD="$PWD" +cd "$(dirname "$0")" +BUSYBOX_FS="$(realpath ../busybox/rootfs)" +OVERLAY_FS="$(realpath ../rootfs)" +cd "$OLDPWD" + +# change into the (mounted) target rootfs folder +cd "$1" + +# scaffold folders +for dir in bin dev etc home lib mnt opt proc root run sbin srv sys tmp usr var ; do + mkdir -p "$dir" +done + +# create special devices +! [ -c dev/mem ] && mknod dev/mem c 1 1 +! [ -c dev/null ] && mknod dev/null c 1 3 +! [ -c dev/random ] && mknod dev/random c 1 8 +! [ -c dev/urandom ] && mknod dev/urandom c 1 9 +! [ -c dev/zero ] && mknod dev/zero c 1 5 + +# copy busybox files and overlay files +CPFLAGS='--no-dereference --recursive --preserve=mode,timestamps,links --no-preserve=owner' +cp $CPFLAGS "$BUSYBOX_FS/." . +cp $CPFLAGS "$OVERLAY_FS/." . + +# setuid busybox +chmod a=xrs,u+w bin/busybox + +# # create /etc/passwd +# if ! [ -e etc/passwd ] ; then +# # TODO: add root to a group +# echo "root:x:0:0::/root:/bin/sh" > etc/passwd +# fi +# # and /etc/shadow +# if ! [ -e etc/shadow ] ; then +# echo "root:$(mkpasswd alpine):::::::" > etc/shadow +# fi +# |