forked from emily/nixfiles
28 lines
904 B
Bash
28 lines
904 B
Bash
#!/usr/bin/env bash
|
|
|
|
cat /etc/passwd > /root/passwd
|
|
rm -f /etc/passwd
|
|
cp /root/passwd /etc/passwd
|
|
echo "sshd:x:498:65534::/var/empty:/run/current-system/sw/bin/nologin" >> /etc/passwd
|
|
cat /etc/shadow > /root/shadow
|
|
rm -f /etc/shadow
|
|
cp /root/shadow /etc/shadow
|
|
/bin/sed -i "s/root:!/root:*/g" /etc/shadow
|
|
|
|
[[ ! -d "/mnt/data/ssh" ]] && mkdir -p /mnt/data/ssh
|
|
if [[ "$(ls /mnt/data/ssh/*_key)" = "" ]]; then
|
|
ssh-keygen -t "ed25519" -f "/mnt/data/ssh/ssh_host_ed25519_key" -N ""
|
|
fi
|
|
|
|
[[ ! -d "/mnt/data/nix-store" ]] && mkdir -p /mnt/data/nix-store
|
|
[[ ! -d "/mnt/data/workdir" ]] && mkdir -p /mnt/data/workdir
|
|
rm -rf /mnt/data/nix-store/*
|
|
|
|
rm -f /etc/nix/nix.conf
|
|
cp /root/nix.conf /etc/nix/nix.conf
|
|
|
|
/bin/mount -t overlay overlay -o lowerdir=/nix/store,upperdir=/mnt/data/nix-store,workdir=/mnt/data/workdir /nix/store
|
|
|
|
#nix-store --gc --max-freed 1T
|
|
|
|
/root/.nix-profile/bin/sshd -D -f /root/sshd_config
|