Improve creation of regular user

Do it as part of %post instead of waiting until boot.

There are several advantages to this approach: it makes boot
a little bit faster, and prevents a warning about sysvinit
compatibility being deprecated from being printed.

Most importantly, if the user decides to change the password
after installation, that change will now stick instead of
being reverted every time the machine is booted.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 2e51a65e040ac1caf556d0f87e3facea407ca301)
This commit is contained in:
Andrea Bolognani 2024-04-18 19:31:45 +02:00 committed by David Abdurachmanov
parent 4a455dc878
commit 40b7729123
4 changed files with 28 additions and 120 deletions

View File

@ -60,6 +60,8 @@ uboot-images-riscv64
dracut-config-generic
-dracut-config-rescue
# For user creation and manipulation
shadow-utils
passwd
# Adding kiwi for disk image generation
@ -252,10 +254,6 @@ haveged
# end of gcc packages
watchdog
# No longer in @core since 2018-10, but needed for livesys script
initscripts
chkconfig
# Lets resize / on first boot
#dracut-modules-growroot
@ -423,32 +421,11 @@ dnf -y remove dracut-config-generic
# and mounting processes. This should help on systems where boot takes longer.
sed -i 's|noatime|noatime,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s|g' /etc/fstab
# Fedora 31
# https://fedoraproject.org/wiki/Changes/DisableRootPasswordLoginInSshd
cat > /etc/rc.d/init.d/livesys << EOF
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.
### BEGIN INIT INFO
# X-Start-Before: display-manager chronyd
### END INIT INFO
. /etc/rc.d/init.d/functions
useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv > /dev/null
usermod -aG wheel riscv > /dev/null
usermod -aG mock riscv > /dev/null
exit 0
EOF
chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys
# Create regular user
/usr/sbin/useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv
/usr/sbin/usermod -aG wheel riscv
/usr/sbin/usermod -aG mock riscv
# Create Fedora RISC-V repo
cat << EOF > /etc/yum.repos.d/fedora-riscv.repo

View File

@ -60,6 +60,8 @@ uboot-images-riscv64
dracut-config-generic
-dracut-config-rescue
# For user creation and manipulation
shadow-utils
passwd
# Install the English locale, but not all the other ones
@ -71,10 +73,6 @@ chrony
haveged
watchdog
# No longer in @core since 2018-10, but needed for livesys script
initscripts
chkconfig
# Lets resize / on first boot
#dracut-modules-growroot
@ -101,32 +99,11 @@ dnf -y remove dracut-config-generic
# and mounting processes. This should help on systems where boot takes longer.
sed -i 's|noatime|noatime,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s|g' /etc/fstab
# Fedora 31
# https://fedoraproject.org/wiki/Changes/DisableRootPasswordLoginInSshd
cat > /etc/rc.d/init.d/livesys << EOF
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.
### BEGIN INIT INFO
# X-Start-Before: display-manager chronyd
### END INIT INFO
. /etc/rc.d/init.d/functions
useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv > /dev/null
usermod -aG wheel riscv > /dev/null
usermod -aG mock riscv > /dev/null
exit 0
EOF
chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys
# Create regular user
/usr/sbin/useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv
/usr/sbin/usermod -aG wheel riscv
/usr/sbin/usermod -aG mock riscv
# Create Fedora RISC-V repo
cat << EOF > /etc/yum.repos.d/fedora-riscv.repo

View File

@ -57,6 +57,8 @@ uboot-images-riscv64
dracut-config-generic
-dracut-config-rescue
# For user creation and manipulation
shadow-utils
passwd
# Install the English locale, but not all the other ones
@ -68,10 +70,6 @@ chrony
haveged
watchdog
# No longer in @core since 2018-10, but needed for livesys script
initscripts
chkconfig
# Lets resize / on first boot
#dracut-modules-growroot
@ -98,32 +96,11 @@ dnf -y remove dracut-config-generic
# and mounting processes. This should help on systems where boot takes longer.
sed -i 's|noatime|noatime,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s|g' /etc/fstab
# Fedora 31
# https://fedoraproject.org/wiki/Changes/DisableRootPasswordLoginInSshd
cat > /etc/rc.d/init.d/livesys << EOF
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.
### BEGIN INIT INFO
# X-Start-Before: display-manager chronyd
### END INIT INFO
. /etc/rc.d/init.d/functions
useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv > /dev/null
usermod -aG wheel riscv > /dev/null
usermod -aG mock riscv > /dev/null
exit 0
EOF
chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys
# Create regular user
/usr/sbin/useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv
/usr/sbin/usermod -aG wheel riscv
/usr/sbin/usermod -aG mock riscv
# Create Fedora RISC-V repo
cat << EOF > /etc/yum.repos.d/fedora-riscv.repo

View File

@ -53,6 +53,8 @@ uboot-images-riscv64
dracut-config-generic
-dracut-config-rescue
# For user creation and manipulation
shadow-utils
passwd
# Install the English locale, but not all the other ones
@ -64,10 +66,6 @@ chrony
haveged
watchdog
# No longer in @core since 2018-10, but needed for livesys script
initscripts
chkconfig
# Lets resize / on first boot
#dracut-modules-growroot
@ -94,32 +92,11 @@ dnf -y remove dracut-config-generic
# and mounting processes. This should help on systems where boot takes longer.
sed -i 's|noatime|noatime,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s|g' /etc/fstab
# Fedora 31
# https://fedoraproject.org/wiki/Changes/DisableRootPasswordLoginInSshd
cat > /etc/rc.d/init.d/livesys << EOF
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.
### BEGIN INIT INFO
# X-Start-Before: display-manager chronyd
### END INIT INFO
. /etc/rc.d/init.d/functions
useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv > /dev/null
usermod -aG wheel riscv > /dev/null
usermod -aG mock riscv > /dev/null
exit 0
EOF
chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys
# Create regular user
/usr/sbin/useradd -c "Fedora RISCV User" riscv
echo fedora_rocks! | passwd --stdin riscv
/usr/sbin/usermod -aG wheel riscv
/usr/sbin/usermod -aG mock riscv
# Create Fedora RISC-V repo
cat << EOF > /etc/yum.repos.d/fedora-riscv.repo