From a3ca0d0868d91e74ab17a99d5cbba3caddec9fbe Mon Sep 17 00:00:00 2001 From: kokkiemouse Date: Sat, 12 Sep 2020 11:27:44 +0900 Subject: [PATCH] fixed login Signed-off-by: kokkiemouse --- .../system/getty@tty1.service.d/autologin.conf | 3 ++ channels/share/airootfs/root/customize_airootfs.sh | 58 ++++++++++++++++++++++ lfbs | 18 ++++++- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 channels/share/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf create mode 100755 channels/share/airootfs/root/customize_airootfs.sh diff --git a/channels/share/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf b/channels/share/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf new file mode 100644 index 0000000..6122938 --- /dev/null +++ b/channels/share/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin %USERNAME% --noclear %I 38400 linux diff --git a/channels/share/airootfs/root/customize_airootfs.sh b/channels/share/airootfs/root/customize_airootfs.sh new file mode 100755 index 0000000..c2971e8 --- /dev/null +++ b/channels/share/airootfs/root/customize_airootfs.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -e -u + +password=fedora +username=fedora +usershell="/bin/bash" + +function create_user () { + local _password + local _username + + _username=${1} + _password=${2} + + set +u + if [[ -z "${_username}" ]]; then + echo "User name is not specified." >&2 + return 1 + fi + if [[ -z "${_password}" ]]; then + echo "No password has been specified." >&2 + return 1 + fi + set -u + + if [[ $(user_check ${_username}) = false ]]; then + useradd -m -s ${usershell} ${_username} + groupadd sudo + usermod -U -g ${_username} ${_username} + usermod -aG sudo ${_username} + usermod -aG storage ${_username} + cp -aT /etc/skel/ /home/${_username}/ + fi + chmod 700 -R /home/${_username} + chown ${_username}:${_username} -R /home/${_username} + echo -e "${_password}\n${_password}" | passwd ${_username} + set -u +} + +create_user "${username}" "${password}" + + +# Set up auto login +if [[ -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then + sed -i s/%USERNAME%/"${username}"/g /etc/systemd/system/getty@tty1.service.d/autologin.conf +fi + +# Set to execute calamares without password as alter user. +cat >> /etc/sudoers << "EOF" +Defaults pwfeedback +EOF +echo "${username} ALL=NOPASSWD: ALL" >> /etc/sudoers.d/fedoralive + + +# Chnage sudoers permission +chmod 750 -R /etc/sudoers.d/ +chown root:root -R /etc/sudoers.d/ diff --git a/lfbs b/lfbs index 98c7cbf..a37b34b 100755 --- a/lfbs +++ b/lfbs @@ -30,8 +30,6 @@ iso_application="${os_name} Live/Rescue CD" iso_version="${codename}-$(date +%Y.%m.%d)" iso_filename="${iso_name}-${iso_version}-${arch}.iso" -username="liveuser" -usershell="/bin/bash" debug=false cache_only=false @@ -283,6 +281,21 @@ make_dnf_packages() { remove "${work_dir}/airootfs/dnfpkglist" } +make_cp_airootfs() { + if [ -d ${channels_dir}/share/airootfs ]; then + cp -rf ${channels_dir}/share/airootfs/ ${work_dir} + fi + if [ -d ${channels_dir}/${channel_name}/airootfs ]; then + cp -rf ${channels_dir}/${channel_name}/airootfs/ ${work_dir} + fi +} + +make_config() { + run_cmd truncate -s 0 /etc/machine-id + if [ -f ${work_dir}/airootfs/root/customize_airootfs.sh ]; then + run_cmd /root/customize_airootfs.sh + fi +} # 引数解析() # 参考記事:https://0e0.pw/ci83 https://0e0.pw/VJlg @@ -408,6 +421,7 @@ prepare_build run_once make_basefs run_once make_systemd run_once make_dnf_packages +run_once make_cp_airootfs run_once make_config run_once make_add_user run_once make_clean -- 2.11.0