Move /etc/{passwd,group} creation to login-inner

This commit is contained in:
Alexander Sosedkin 2019-10-05 02:40:10 +02:00
parent 57fc985455
commit 0c0f62f604
2 changed files with 17 additions and 14 deletions

View file

@ -11,8 +11,8 @@ writeTextDir "usr/lib/login-inner" ''
[ "$#" -gt 0 ] || echo "If nothing works, use the rescue shell and read ${instDir}/usr/lib/login-inner" [ "$#" -gt 0 ] || echo "If nothing works, use the rescue shell and read ${instDir}/usr/lib/login-inner"
[ "$#" -gt 0 ] || echo "If it does not help, report bugs at https://github.com/t184256/nix-on-droid-bootstrap/issues" [ "$#" -gt 0 ] || echo "If it does not help, report bugs at https://github.com/t184256/nix-on-droid-bootstrap/issues"
export USER=nix-on-droid export USER='nix-on-droid'
export HOME="/data/data/com.termux.nix/files/home" export HOME='/data/data/com.termux.nix/files/home'
${ ${
if initialBuild if initialBuild
@ -33,6 +33,21 @@ writeTextDir "usr/lib/login-inner" ''
echo "Setting up dynamic symlinks via nix-on-droid-linker" echo "Setting up dynamic symlinks via nix-on-droid-linker"
nix-on-droid-linker nix-on-droid-linker
[ "$#" -gt 0 ] || echo "Sourcing Nix environment..."
. $HOME/.nix-profile/etc/profile.d/nix.sh
if [ ! -e ${instDir}/etc/passwd ]; then
[ -n "$@" ] || echo "Creating /etc/passwd..."
echo "root:x:0:0:System administrator:${instDir}/root:/bin/sh" > ${instDir}/etc/passwd
echo "$USER:x:$(id -u):$USER:/data/data/com.termux.nix/files/home:/bin/sh" >> ${instDir}/etc/passwd
fi
if [ ! -e ${instDir}/etc/group ]; then
[ -n "$@" ] || echo "Creating /etc/group..."
echo "root:x:0:" > ${instDir}/etc/group
echo "$USER:x:$(id -g):$USER" >> ${instDir}/etc/group
fi
echo echo
echo "Congratulations! Now you have Nix installed with some basic packages like" echo "Congratulations! Now you have Nix installed with some basic packages like"
echo "bashInteractive, coreutils, cacert and some scripts provided by nix-on-droid" echo "bashInteractive, coreutils, cacert and some scripts provided by nix-on-droid"

View file

@ -11,18 +11,6 @@ writeScriptBin "login" ''
export PROOT_TMP_DIR=${instDir}/tmp export PROOT_TMP_DIR=${instDir}/tmp
export PROOT_L2S_DIR=${instDir}/.l2s export PROOT_L2S_DIR=${instDir}/.l2s
if [ ! -e ${instDir}/etc/passwd ]; then
[ -n "$@" ] || echo "Creating /etc/passwd..."
echo "root:x:0:0:System administrator:${instDir}/root:/bin/sh" > ${instDir}/etc/passwd
echo "$USER:x:$(/system/bin/stat -c '%u:%g' ${instDir}):$USER:/data/data/com.termux.nix/files/home:/bin/sh" >> ${instDir}/etc/passwd
fi
if [ ! -e ${instDir}/etc/group ]; then
[ -n "$@" ] || echo "Creating /etc/group..."
echo "root:x:0:" > ${instDir}/etc/group
echo "$USER:x:$(/system/bin/stat -c '%g' ${instDir}):$USER" >> ${instDir}/etc/group
fi
exec ${instDir}/bin/proot \ exec ${instDir}/bin/proot \
-b ${instDir}/nix:/nix \ -b ${instDir}/nix:/nix \
-b ${instDir}/bin:/bin \ -b ${instDir}/bin:/bin \