Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

systemd: configure emergency.service to autologin if set on kernel co… #213

Merged
merged 1 commit into from Jul 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions systemd/system-generators/coreos-autologin-generator
Expand Up @@ -38,6 +38,21 @@ EOF
fi
}

# reconfigure emergency.service to autologin as root
emergency_autologin() {
# only autologin if our tty is the active one
grep -q "$1$" /sys/class/tty/console/active || return

local out_dir="${DEST}/emergency.service.d"
local out_file="${out_dir}/10-autologin.conf"
mkdir -p "${out_dir}"
cat << 'EOF' > "${out_file}"
[Service]
ExecStart=
ExecStart=-/bin/sh -c "/usr/bin/login -f root; /usr/bin/systemctl --job-mode=fail --no-block default"
EOF
}

autologin() {
param="$1"
arg=$(echo "${param}" | awk -F'=' '{print $2}')
Expand All @@ -52,6 +67,8 @@ autologin() {
overlay_unit "getty@.service"
overlay_unit "serial-getty@.service"
fi

emergency_autologin "${arg}"
}

read -r CMDLINE </proc/cmdline;
Expand Down