2012-06-12 14:27:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
|
|
2012-11-22 10:19:12 -01:00
|
|
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
|
|
|
|
2012-06-12 14:27:17 +00:00
|
|
|
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.
|
2013-05-20 11:15:21 +00:00
|
|
|
chroot ${NEWROOT} useradd -c $USERNAME -m $USERNAME -G \
|
|
|
|
systemd-journal,wheel -s /bin/bash
|
|
|
|
chroot ${NEWROOT} passwd -d $USERNAME >/dev/null 2>&1
|
2012-06-12 14:27:17 +00:00
|
|
|
|
|
|
|
# Enable sudo permission by default.
|
|
|
|
if [ -f ${NEWROOT}/etc/sudoers ]; then
|
2013-05-20 11:15:21 +00:00
|
|
|
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers
|
2012-06-12 14:27:17 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-22 08:30:58 -01:00
|
|
|
# Enable autologin for agetty(8).
|
2013-05-20 11:15:21 +00:00
|
|
|
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"
|
2013-06-02 10:08:27 +00:00
|
|
|
|
|
|
|
if [ -d ${NEWROOT}/etc/polkit-1 ]; then
|
|
|
|
# If polkit is installed allow users in the wheel group to run anything.
|
|
|
|
cat > ${NEWROOT}/etc/polkit-1/rules.d/void-live.rules <<_EOF
|
|
|
|
polkit.addAdminRule(function(action, subject) {
|
|
|
|
return ["unix-group:wheel"];
|
|
|
|
});
|
|
|
|
|
|
|
|
polkit.addRule(function(action, subject) {
|
|
|
|
if (subject.isInGroup("wheel")) {
|
|
|
|
return polkit.Result.YES;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_EOF
|
2013-06-02 10:32:57 +00:00
|
|
|
chroot ${NEWROOT} chown polkitd:polkitd /etc/polkit-1/rules.d/void-live.rules
|
2013-06-02 10:08:27 +00:00
|
|
|
fi
|