#!/bin/sh umask 022 set -e if [ "$(id -u)" != "0" ]; then echo "Please run this script as root" 1>&2 exit 1 fi if [ ! "$rocket" ]; then echo 'Please set the $rocket variable' 1>&2 exit 1 fi echo "Changing ownership of $rocket to root" chown -R 0.0 "$rocket" echo "Creating device nodes" mkdir -p "$rocket/dev" umount -R "$rocket/dev" 2> /dev/null || true mknod -m 600 "$rocket/dev/console" c 5 1 2> /dev/null || true mknod -m 666 "$rocket/dev/null" c 1 3 2> /dev/null || true echo "Creating directories" install -dm750 "$rocket/root" install -dm1777 "$rocket/tmp" mkdir -p "$rocket/etc" "$rocket/usr/pkg" "$rocket/usr/sat" echo "Creating temporary symlinks" mkdir -p "$rocket/usr/pkg/tmp-coreutils/bin" ln -f "$rocket/tools/bin/busybox" "$rocket/usr/pkg/tmp-coreutils/bin/pwd" mkdir -p "$rocket/usr/pkg/tmp-sh/bin" ln -f "$rocket/tools/bin/busybox" "$rocket/usr/pkg/tmp-sh/bin/sh" mkdir -p "$rocket/usr/pkg/tmp-bash/bin" ln -f "$rocket/tools/bin/bash" "$rocket/usr/pkg/tmp-bash/bin/bash" mkdir -p "$rocket/usr/pkg/tmp-ca-certificates/etc/ssl" ln -sf /tools/ssl/certs "$rocket/usr/pkg/tmp-ca-certificates/etc/ssl/certs" mkdir -p "$rocket/usr/pkg/tmp-gcc/usr/lib" ln -f "$rocket/tools/lib/libgcc_s.so" "$rocket/usr/pkg/tmp-gcc/usr/lib/libgcc_s.so" ln -f "$rocket/tools/lib/libgcc_s.so.1" "$rocket/usr/pkg/tmp-gcc/usr/lib/libgcc_s.so.1" ln -f "$rocket/tools/lib/libstdc++.so" "$rocket/usr/pkg/tmp-gcc/usr/lib/libstdc++.so" ln -f "$rocket/tools/lib/libstdc++.so.6" "$rocket/usr/pkg/tmp-gcc/usr/lib/libstdc++.so.6" ln -f "$rocket/tools/lib/libstdc++.so.6.0.21" "$rocket/usr/pkg/tmp-gcc/usr/lib/libstdc++.so.6.0.21" echo "Creating users and groups" echo 'root:x:0:0:root:/root:/bin/sh nobody:x:99:99:Unprivileged User:/dev/null:/bin/false' > "$rocket/etc/passwd" echo 'root:x:0: tty:x:1: nogroup:x:99:' > "$rocket/etc/group" echo "Configuring stow" echo '-d /usr/pkg -t /' > "$rocket/etc/stowrc"