From c70ef1451b726b74b2e51cbc6256430484d6dc33 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 22 Nov 2012 15:28:13 +0100 Subject: Make dracut scripts shorter in name; they are part of vmklive module anyway... --- dracut/adduser.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 dracut/adduser.sh (limited to 'dracut/adduser.sh') diff --git a/dracut/adduser.sh b/dracut/adduser.sh new file mode 100644 index 0000000..e242529 --- /dev/null +++ b/dracut/adduser.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +USERNAME=$(getarg live.user) +[ -z "$USERNAME" ] && USERNAME=anon + +# Create /etc/default/live.conf to store USER. +echo "USERNAME=$USERNAME" >> ${NEWROOT}/etc/default/live.conf +chmod 644 ${NEWROOT}/etc/default/live.conf + +# Create new user and remove password. We'll use autologin by default. +chroot ${NEWROOT} useradd -c $USERNAME -m $USERNAME -G audio,video,wheel -s /bin/sh +chroot ${NEWROOT} passwd -d $USERNAME 2>&1 >/dev/null + +# Enable sudo permission by default. +if [ -f ${NEWROOT}/etc/sudoers ]; then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers +fi + +# Enable autologin for agetty(8). +if [ -f ${NEWROOT}/usr/lib/systemd/system/getty@.service ]; then + rm -f "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service" + sed -e "s|/sbin/agetty --noclear|& -a ${USERNAME}|g" \ + "${NEWROOT}/usr/lib/systemd/system/getty@.service" > \ + "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service" +fi -- cgit 1.4.1