2 # SPDX-License-Identifier: GPL-3.0
6 # Email : m.k419sabuaka@gmail.com
10 # Email : hayao@fascode.net
12 # (c) 2019-2020 Fascode Network.
14 # customize_airootfs.sh
20 # All values can be changed by arguments.
28 while getopts 'p:u:s:dxa:' arg; do
30 p) password="${OPTARG}" ;;
31 u) username="${OPTARG}" ;;
32 s) usershell="${OPTARG}" ;;
34 x) debug=true; set -xv ;;
40 # Creating a root user.
41 # usermod -s /usr/bin/zsh root
42 function user_check () {
43 if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
53 if [[ $(user_check root) = false ]]; then
54 usermod -s "${usershell}" root
55 cp -aT /etc/skel/ /root/
57 LC_ALL=C LANG=C xdg-user-dirs-update
59 echo -e "${password}\n${password}" | passwd root
61 # Allow sudo group to run sudo
62 sed -i 's/^#\s*\(%sudo\s\+ALL=(ALL)\s\+ALL\)/\1/' /etc/sudoers
65 # create_user <username> <password>
66 function create_user () {
74 if [[ -z "${_username}" ]]; then
75 echo "User name is not specified." >&2
78 if [[ -z "${_password}" ]]; then
79 echo "No password has been specified." >&2
84 if [[ $(user_check ${_username}) = false ]]; then
85 useradd -m -s ${usershell} ${_username}
86 usermod -U -g ${_username} ${_username}
87 usermod -aG sudo ${_username}
88 cp -aT /etc/skel/ /home/${_username}/
90 chmod 700 -R /home/${_username}
91 chown ${_username}:${_username} -R /home/${_username}
92 echo -e "${_password}\n${_password}" | passwd ${_username}
96 create_user "${username}" "${password}"
100 if [[ -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then
101 sed -i s/%USERNAME%/"${username}"/g /etc/systemd/system/getty@tty1.service.d/autologin.conf
105 # Set to execute calamares without password as alter user.
106 cat >> /etc/sudoers << "EOF"
109 echo "${username} ALL=NOPASSWD: ALL" >> /etc/sudoers.d/alterlive
112 # Chnage sudoers permission
113 chmod 750 -R /etc/sudoers.d/
114 chown root:root -R /etc/sudoers.d/