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 ++++++++++++++++++ dracut/conf.sh | 33 +++++++++++++++++++++ dracut/display-manager-autologin.sh | 36 ++++++++++++++++++++++ dracut/module-setup.sh | 10 +++---- dracut/polkit.sh | 46 +++++++++++++++++++++++++++++ dracut/vmklive-adduser.sh | 29 ------------------ dracut/vmklive-conf.sh | 33 --------------------- dracut/vmklive-display-manager-autologin.sh | 36 ---------------------- dracut/vmklive-polkit.sh | 46 ----------------------------- 9 files changed, 149 insertions(+), 149 deletions(-) create mode 100644 dracut/adduser.sh create mode 100644 dracut/conf.sh create mode 100644 dracut/display-manager-autologin.sh create mode 100644 dracut/polkit.sh delete mode 100644 dracut/vmklive-adduser.sh delete mode 100644 dracut/vmklive-conf.sh delete mode 100644 dracut/vmklive-display-manager-autologin.sh delete mode 100644 dracut/vmklive-polkit.sh (limited to 'dracut') 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 diff --git a/dracut/conf.sh b/dracut/conf.sh new file mode 100644 index 0000000..bb63e61 --- /dev/null +++ b/dracut/conf.sh @@ -0,0 +1,33 @@ +#!/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 + +KEYMAP=$(getarg vconsole.keymap) +FONT=$(getarg vconsole.font) +FONT_MAP=$(getarg vconsole.font.map) +FONT_UNIMAP=$(getarg vconsole.font.unimap) +LOCALE=$(getarg locale.LANG) + +if [ -n "$KEYMAP" ]; then + sed -i -e "s|^KEYMAP=.*|KEYMAP=$KEYMAP|g" ${NEWROOT}/etc/vconsole.conf +fi +if [ -n "$FONT" ]; then + sed -i -e "s|^FONT=.*|FONT=$FONT|g" ${NEWROOT}/etc/vconsole.conf +fi +if [ -n "$FONT_MAP" ]; then + sed -i -e "s|^FONT_MAP=.*|FONT_MAP=$FONT_MAP|g" ${NEWROOT}/etc/vconsole.conf +fi +if [ -n "$FONT_UNIMAP" ]; then + sed -i -e "s|^FONT_UNIMAP=.*|FONT_UNIMAP=$FONT_UNIMAP|g" ${NEWROOT}/etc/vconsole.conf +fi +if [ -n "$LOCALE" ]; then + sed -i -e "s|^LANG=.*|LANG=$LOCALE|g" ${NEWROOT}/etc/locale.conf +fi + +# Setup keymap for X.org evdev. +if [ -r "${NEWROOT}/etc/udev/rules.d/75-x11-input.rules" ]; then + sed -i -e "s|\(ENV{xkblayout}\=\)\"us\"|\1\"${KEYMAP}\"|" \ + ${NEWROOT}/etc/udev/rules.d/75-x11-input.rules +fi diff --git a/dracut/display-manager-autologin.sh b/dracut/display-manager-autologin.sh new file mode 100644 index 0000000..53a6a43 --- /dev/null +++ b/dracut/display-manager-autologin.sh @@ -0,0 +1,36 @@ +#!/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 + +# Configure GDM autologin +if [ -d ${NEWROOT}/etc/gdm ]; then + GDMCustomFile=${NEWROOT}/etc/gdm/custom.conf + AutologinParameters="AutomaticLoginEnable=true\nAutomaticLogin=$USERNAME" + + # Prevent from updating if parameters already present (persistent usb key) + if ! `grep -qs 'AutomaticLoginEnable' $GDMCustomFile` ; then + if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then + echo '[daemon]' >> $GDMCustomFile + fi + sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile + fi +fi + +# Configure lightdm autologin. +if [ -r ${NEWROOT}/etc/lightdm.conf ]; then + sed -i -e "s|^\#\(default-user=\).*|\1$USERNAME|" \ + ${NEWROOT}/etc/lightdm.conf + sed -i -e "s|^\#\(default-user-timeout=\).*|\10|" \ + ${NEWROOT}/etc/lightdm.conf +fi + +# Configure lxdm autologin. +if [ -r ${NEWROOT}/etc/lxdm/lxdm.conf ]; then + sed -i -e "s|^\#\# \(autologin=\).*|\1$USERNAME|" \ + ${NEWROOT}/etc/lxdm/lxdm.conf +fi diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh index 7585828..d837e94 100644 --- a/dracut/module-setup.sh +++ b/dracut/module-setup.sh @@ -11,9 +11,9 @@ depends() { } install() { - inst chmod - inst_hook pre-pivot 01 "$moddir/vmklive-adduser.sh" - inst_hook pre-pivot 02 "$moddir/vmklive-conf.sh" - inst_hook pre-pivot 03 "$moddir/vmklive-polkit.sh" - inst_hook pre-pivot 04 "$moddir/vmklive-display-manager-autologin.sh" + inst chmod sed + inst_hook pre-pivot 01 "$moddir/adduser.sh" + inst_hook pre-pivot 02 "$moddir/conf.sh" + inst_hook pre-pivot 03 "$moddir/polkit.sh" + inst_hook pre-pivot 04 "$moddir/display-manager-autologin.sh" } diff --git a/dracut/polkit.sh b/dracut/polkit.sh new file mode 100644 index 0000000..c6dfd7f --- /dev/null +++ b/dracut/polkit.sh @@ -0,0 +1,46 @@ +#!/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 + +# Check that polkit is installed. +if [ ! -x ${NEWROOT}/usr/libexec/polkitd ]; then + exit 0 +fi + +# configure PolicyKit in live session +mkdir -m0755 -p ${NEWROOT}/etc/PolicyKit +cat << EOF > ${NEWROOT}/etc/PolicyKit/PolicyKit.conf + + + + + + + + + + + + + + + + +EOF + +mkdir -m0750 -p ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d +cat << EOF > ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d/10-live-cd.pkla +# Policy to allow the livecd user to bypass policykit +[Live CD user permissions] +Identity=unix-user:$USERNAME +Action=* +ResultAny=no +ResultInactive=no +ResultActive=yes +EOF diff --git a/dracut/vmklive-adduser.sh b/dracut/vmklive-adduser.sh deleted file mode 100644 index e242529..0000000 --- a/dracut/vmklive-adduser.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 diff --git a/dracut/vmklive-conf.sh b/dracut/vmklive-conf.sh deleted file mode 100644 index bb63e61..0000000 --- a/dracut/vmklive-conf.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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 - -KEYMAP=$(getarg vconsole.keymap) -FONT=$(getarg vconsole.font) -FONT_MAP=$(getarg vconsole.font.map) -FONT_UNIMAP=$(getarg vconsole.font.unimap) -LOCALE=$(getarg locale.LANG) - -if [ -n "$KEYMAP" ]; then - sed -i -e "s|^KEYMAP=.*|KEYMAP=$KEYMAP|g" ${NEWROOT}/etc/vconsole.conf -fi -if [ -n "$FONT" ]; then - sed -i -e "s|^FONT=.*|FONT=$FONT|g" ${NEWROOT}/etc/vconsole.conf -fi -if [ -n "$FONT_MAP" ]; then - sed -i -e "s|^FONT_MAP=.*|FONT_MAP=$FONT_MAP|g" ${NEWROOT}/etc/vconsole.conf -fi -if [ -n "$FONT_UNIMAP" ]; then - sed -i -e "s|^FONT_UNIMAP=.*|FONT_UNIMAP=$FONT_UNIMAP|g" ${NEWROOT}/etc/vconsole.conf -fi -if [ -n "$LOCALE" ]; then - sed -i -e "s|^LANG=.*|LANG=$LOCALE|g" ${NEWROOT}/etc/locale.conf -fi - -# Setup keymap for X.org evdev. -if [ -r "${NEWROOT}/etc/udev/rules.d/75-x11-input.rules" ]; then - sed -i -e "s|\(ENV{xkblayout}\=\)\"us\"|\1\"${KEYMAP}\"|" \ - ${NEWROOT}/etc/udev/rules.d/75-x11-input.rules -fi diff --git a/dracut/vmklive-display-manager-autologin.sh b/dracut/vmklive-display-manager-autologin.sh deleted file mode 100644 index 53a6a43..0000000 --- a/dracut/vmklive-display-manager-autologin.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 - -# Configure GDM autologin -if [ -d ${NEWROOT}/etc/gdm ]; then - GDMCustomFile=${NEWROOT}/etc/gdm/custom.conf - AutologinParameters="AutomaticLoginEnable=true\nAutomaticLogin=$USERNAME" - - # Prevent from updating if parameters already present (persistent usb key) - if ! `grep -qs 'AutomaticLoginEnable' $GDMCustomFile` ; then - if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then - echo '[daemon]' >> $GDMCustomFile - fi - sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile - fi -fi - -# Configure lightdm autologin. -if [ -r ${NEWROOT}/etc/lightdm.conf ]; then - sed -i -e "s|^\#\(default-user=\).*|\1$USERNAME|" \ - ${NEWROOT}/etc/lightdm.conf - sed -i -e "s|^\#\(default-user-timeout=\).*|\10|" \ - ${NEWROOT}/etc/lightdm.conf -fi - -# Configure lxdm autologin. -if [ -r ${NEWROOT}/etc/lxdm/lxdm.conf ]; then - sed -i -e "s|^\#\# \(autologin=\).*|\1$USERNAME|" \ - ${NEWROOT}/etc/lxdm/lxdm.conf -fi diff --git a/dracut/vmklive-polkit.sh b/dracut/vmklive-polkit.sh deleted file mode 100644 index c6dfd7f..0000000 --- a/dracut/vmklive-polkit.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/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 - -# Check that polkit is installed. -if [ ! -x ${NEWROOT}/usr/libexec/polkitd ]; then - exit 0 -fi - -# configure PolicyKit in live session -mkdir -m0755 -p ${NEWROOT}/etc/PolicyKit -cat << EOF > ${NEWROOT}/etc/PolicyKit/PolicyKit.conf - - - - - - - - - - - - - - - - -EOF - -mkdir -m0750 -p ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d -cat << EOF > ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d/10-live-cd.pkla -# Policy to allow the livecd user to bypass policykit -[Live CD user permissions] -Identity=unix-user:$USERNAME -Action=* -ResultAny=no -ResultInactive=no -ResultActive=yes -EOF -- cgit 1.4.1