about summary refs log tree commit diff
path: root/dracut/dracut-vmklive-adduser.sh
diff options
context:
space:
mode:
authorJuan RP <xtraeme@gmail.com>2012-06-12 16:27:17 +0200
committerJuan RP <xtraeme@gmail.com>2012-06-12 16:27:17 +0200
commitf23d55be2bd378f82d53f1cc6eba9c0b07c17c32 (patch)
treecb2c61c05a6421052d7dae668482c4d5579f5e6a /dracut/dracut-vmklive-adduser.sh
downloadhrmpf-f23d55be2bd378f82d53f1cc6eba9c0b07c17c32.tar.gz
hrmpf-f23d55be2bd378f82d53f1cc6eba9c0b07c17c32.tar.xz
hrmpf-f23d55be2bd378f82d53f1cc6eba9c0b07c17c32.zip
Initial import of void-mklive 0.9.5 (from srcpkgs/vmklive).
Diffstat (limited to 'dracut/dracut-vmklive-adduser.sh')
-rw-r--r--dracut/dracut-vmklive-adduser.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/dracut/dracut-vmklive-adduser.sh b/dracut/dracut-vmklive-adduser.sh
new file mode 100644
index 0000000..9f95c65
--- /dev/null
+++ b/dracut/dracut-vmklive-adduser.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=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 getty(1).
+if [ -f ${NEWROOT}/lib/systemd/system/getty@.service ]; then
+        rm -f "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service"
+	sed -e "s|/sbin/agetty|/sbin/live-getty|g" \
+                "${NEWROOT}/lib/systemd/system/getty@.service" > \
+                "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service"
+fi
+
+# Create /sbin/live-getty.
+cat > ${NEWROOT}/sbin/live-getty <<_EOF
+#!/bin/sh
+
+if [ -x /sbin/agetty ]; then
+	_getty=/sbin/agetty
+elif [ -x /sbin/getty ]; then
+	_getty=/sbin/getty
+fi
+
+exec \${_getty} -n -l /sbin/live-autologin \$*
+_EOF
+chmod 755 ${NEWROOT}/sbin/live-getty
+
+# Create /sbin/live-autologin.
+cat > ${NEWROOT}/sbin/live-autologin <<_EOF
+#!/bin/sh
+
+. /etc/default/live.conf
+exec /bin/login -f \$USERNAME
+_EOF
+chmod 755 ${NEWROOT}/sbin/live-autologin