linux-deployment-scripts/configs/scripts/user.sh

50 lines
1.2 KiB
Bash
Raw Normal View History

2024-11-11 07:45:44 +01:00
#!/bin/bash
# This file is part of VM-Experiments.
# Licensed under the GPL-3.0-or-later. See LICENSE for details.
trap '' SIGINT SIGTERM
while true; do
2024-11-15 23:50:18 +01:00
read -p "Enter a username (letters, prefferably only lowercase, digits, underscores and hyphens): " username
2024-11-11 07:45:44 +01:00
chroot /mnt /bin/bash -c "useradd -m '$username'"
if [ $? -eq 0 ]; then
break
fi
done
2024-11-15 23:50:18 +01:00
while true; do
read -p "Enter a display name: " fullname
chroot /mnt /bin/bash -c "usermod -c '$fullname' '$username'"
if [ $? -eq 0 ]; then
break
fi
done
2024-11-11 07:45:44 +01:00
while true; do
chroot /mnt /bin/bash -c "passwd '$username'"
if [ $? -eq 0 ]; then
break
fi
done
while true; do
read -p "Enter the hostname: " hostname
chroot /mnt /bin/bash -c "echo $hostname > /etc/hostname"
if [ $? -eq 0 ]; then
break
fi
2024-11-14 16:10:32 +01:00
done
2024-11-14 18:28:25 +01:00
cp /mnt/root/ca.crt /mnt/usr/local/share/ca-certificates/
2024-11-15 23:12:57 +01:00
mkdir -p /mnt/usr/share/ca-certificates/mozilla/
cp /mnt/root/ca.crt /mnt/usr/share/ca-certificates/
cp /mnt/root/ca.crt /mnt/usr/share/ca-certificates/mozilla/
2024-11-15 22:23:10 +01:00
cp /mnt/root/ca.crt /mnt/etc/ssl/certs/
2024-11-15 23:44:08 +01:00
cp /mnt/root/ca.crt /mnt/home/$username/
2024-11-14 16:10:32 +01:00
chroot /mnt /bin/bash -c "update-ca-certificates"