X-Git-Url: https://git.rapsys.eu/distcook/blobdiff_plain/349a7680c2ba05772cba6f4a9e0092b8cf83f4e2..1aa323398b3be427e4adab91386d2c98da3c69e8:/lib/pattern.sh diff --git a/lib/pattern.sh b/lib/pattern.sh index ee96dec..4c167fb 100755 --- a/lib/pattern.sh +++ b/lib/pattern.sh @@ -4,7 +4,8 @@ perl -pne 's%(?:(COMP_CONFIGURE_HINTS|COMP_TAR_INTERNAL_PATHS)=1?)%${1}=1%' -i "$PWD/root/etc/sysconfig/bash-completion" #Disable gpg agent -perl -pne 's%(?:(START_GPGAGENT|START_GPGAGENT_SH)=(?:"?(no|yes)"?)?)%${1}="no"%' -i "$PWD/root/etc/sysconfig/gnupg2" +#XXX: moved to a user systemd service +#perl -pne 's%(?:(START_GPGAGENT|START_GPGAGENT_SH)=(?:"?(no|yes)"?)?)%${1}="no"%' -i "$PWD/root/etc/sysconfig/gnupg2" #Locale config cat << EOF > "$PWD/root/etc/vconsole.conf" @@ -82,13 +83,21 @@ DHCP=yes EOF fi +#Mysql +mkdir -p "$PWD/root/var/lib/mysql" + +#Mail +mkdir -p "$PWD/root/var/spool/mail" + #Fstab cat << EOF > "$PWD/root/etc/fstab" -UUID=${BOOTUUID} /boot ext3 defaults,noatime 1 2 -UUID=${DATAUUID} / btrfs subvol=/slash,defaults,relatime 1 1 -UUID=${SWAPAUUID} none swap sw 0 0 -UUID=${SWAPBUUID} none swap sw 0 0 -UUID=${DATAUUID} /home btrfs subvol=/home,defaults,relatime 1 1 +UUID=${BOOTUUID} /boot ext3 defaults,noatime 1 2 +UUID=${DATAUUID} / btrfs subvol=/slash,defaults,relatime 1 1 +UUID=${SWAPAUUID} none swap sw 0 0 +UUID=${SWAPBUUID} none swap sw 0 0 +UUID=${DATAUUID} /home btrfs subvol=/home,defaults,relatime 1 1 +UUID=${DATAUUID} /var/lib/mysql btrfs subvol=/mysql,defaults,relatime 1 1 +UUID=${DATAUUID} /var/spool/mail btrfs subvol=/mail,defaults,relatime 1 1 proc /proc proc defaults 0 0 EOF @@ -221,14 +230,38 @@ chroot "$PWD/root" /usr/sbin/sshd-keygen #XXX: forced because msec decides otherwise perl -pne 's%^PermitRootLogin .*%PermitRootLogin yes%' -i "$PWD/root/etc/ssh/sshd_config" -# Add rsa key if available -#XXX: dsa is unsupported anymore -if [ -e "$HOME/.ssh/id_rsa.pub" ]; then - [ ! -d "$PWD/root/root/.ssh" ] && mkdir -m 0700 "$PWD/root/root/.ssh" - cp -f "$HOME/.ssh/id_rsa.pub" "$PWD/root/root/.ssh/authorized_keys" +# Prevent btmp warning +cat << EOF > "$PWD/root/etc/tmpfiles.d/var.conf" +# See tmpfiles.d(5) for details + +# Prevent msec warning about enforcing permissions +f /var/log/btmp 0600 root utmp - +EOF + +# Authorized keys +if [ -e "$HOME/.ssh/id_rsa.pub" -o -e "$HOME/.ssh/id_ed25519.pub" ]; then + mkdir -m 0700 "$PWD/root/root/.ssh" + touch "$PWD/root/root/.ssh/authorized_keys" + chmod u=rw,go=r "$PWD/root/root/.ssh/authorized_keys" + + # Add rsa key if available + if [ -e "$HOME/.ssh/id_rsa.pub" ]; then + cat "$HOME/.ssh/id_rsa.pub" >> "$PWD/root/root/.ssh/authorized_keys" + fi + + # Add ed25519 key if available + if [ -e "$HOME/.ssh/id_ed25519.pub" ]; then + cat "$HOME/.ssh/id_ed25519.pub" >> "$PWD/root/root/.ssh/authorized_keys" + fi fi #TODO ntp /etc/systemd/timesyncd.conf +# Force enable systemd-networkd.service +chroot "$PWD/root" /usr/bin/systemctl enable systemd-networkd.service + +# Force enable systemd-resolved.service +chroot "$PWD/root" /usr/bin/systemctl enable systemd-resolved.service + # Cleanup tmp and run rm -fr $PWD/root/tmp/* $PWD/root/run/*