Files
RetroDebian/zzz-config-live.sh
2026-03-19 21:53:59 +01:00

57 lines
1.3 KiB
Bash

#!/bin/sh
set -e
USER_NAME="bob"
USER_HOME="/home/${USER_NAME}"
if ! id "${USER_NAME}" >/dev/null 2>&1; then
adduser --disabled-password --gecos "" "${USER_NAME}"
fi
mkdir -p "${USER_HOME}"
for grp in audio video cdrom games plugdev; do
if getent group "$grp" >/dev/null 2>&1; then
adduser "${USER_NAME}" "$grp" >/dev/null 2>&1 || true
fi
done
mkdir -p /etc/sudoers.d
echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${USER_NAME}"
chmod 0440 "/etc/sudoers.d/${USER_NAME}"
cat > "${USER_HOME}/.xinitrc" <<'EOF'
#!/bin/sh
pcmanfm --desktop &
exec startfluxbox
EOF
cat > "${USER_HOME}/.profile" <<'EOF'
#!/bin/sh
if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
exec startx
fi
EOF
cat > "${USER_HOME}/.bash_profile" <<'EOF'
if [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
fi
EOF
chown "${USER_NAME}:${USER_NAME}" \
"${USER_HOME}/.xinitrc" \
"${USER_HOME}/.profile" \
"${USER_HOME}/.bash_profile"
chmod 0644 \
"${USER_HOME}/.xinitrc" \
"${USER_HOME}/.profile" \
"${USER_HOME}/.bash_profile"
if grep -q '^1:2345:respawn:' /etc/inittab; then
sed -i 's|^1:2345:respawn:.*|1:2345:respawn:/sbin/getty -a '"${USER_NAME}"' 38400 tty1 linux|' /etc/inittab
else
printf '\n1:2345:respawn:/sbin/getty -a %s 38400 tty1 linux\n' "${USER_NAME}" >> /etc/inittab
fi