about summary refs log tree commit diff
path: root/dracut/adduser.sh
diff options
context:
space:
mode:
authorJuan RP <xtraeme@gmail.com>2012-11-22 15:28:13 +0100
committerJuan RP <xtraeme@gmail.com>2012-11-22 15:28:13 +0100
commitc70ef1451b726b74b2e51cbc6256430484d6dc33 (patch)
tree2b5b039dd81ddbe0e95564ef7e3907c920999c2e /dracut/adduser.sh
parent8783414cc73347ea78e6c2442ecc8f4678d40b84 (diff)
downloadhrmpf-c70ef1451b726b74b2e51cbc6256430484d6dc33.tar.gz
hrmpf-c70ef1451b726b74b2e51cbc6256430484d6dc33.tar.xz
hrmpf-c70ef1451b726b74b2e51cbc6256430484d6dc33.zip
Make dracut scripts shorter in name; they are part of vmklive module anyway...
Diffstat (limited to 'dracut/adduser.sh')
-rw-r--r--dracut/adduser.sh29
1 files changed, 29 insertions, 0 deletions
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