You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 4 години
преди 3 години
преди 4 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash -e
  2. install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/"
  3. install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d"
  4. install -m 644 files/ttyoutput.conf "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/"
  5. install -m 644 files/50raspi "${ROOTFS_DIR}/etc/apt/apt.conf.d/"
  6. install -m 644 files/console-setup "${ROOTFS_DIR}/etc/default/"
  7. install -m 755 files/rc.local "${ROOTFS_DIR}/etc/"
  8. if [ -n "${PUBKEY_SSH_FIRST_USER}" ]; then
  9. install -v -m 0700 -o 1000 -g 1000 -d "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh
  10. echo "${PUBKEY_SSH_FIRST_USER}" >"${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys
  11. chown 1000:1000 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys
  12. chmod 0600 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys
  13. fi
  14. if [ "${PUBKEY_ONLY_SSH}" = "1" ]; then
  15. sed -i -Ee 's/^#?[[:blank:]]*PubkeyAuthentication[[:blank:]]*no[[:blank:]]*$/PubkeyAuthentication yes/
  16. s/^#?[[:blank:]]*PasswordAuthentication[[:blank:]]*yes[[:blank:]]*$/PasswordAuthentication no/' "${ROOTFS_DIR}"/etc/ssh/sshd_config
  17. fi
  18. on_chroot << EOF
  19. systemctl disable hwclock.sh
  20. systemctl disable nfs-common
  21. systemctl disable rpcbind
  22. if [ "${ENABLE_SSH}" == "1" ]; then
  23. systemctl enable ssh
  24. else
  25. systemctl disable ssh
  26. fi
  27. systemctl enable regenerate_ssh_host_keys
  28. EOF
  29. if [ "${USE_QEMU}" = "1" ]; then
  30. echo "enter QEMU mode"
  31. install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/"
  32. on_chroot << EOF
  33. systemctl disable resize2fs_once
  34. EOF
  35. echo "leaving QEMU mode"
  36. else
  37. on_chroot << EOF
  38. systemctl enable resize2fs_once
  39. EOF
  40. fi
  41. on_chroot <<EOF
  42. for GRP in input spi i2c gpio; do
  43. groupadd -f -r "\$GRP"
  44. done
  45. for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do
  46. adduser $FIRST_USER_NAME \$GRP
  47. done
  48. EOF
  49. on_chroot << EOF
  50. setupcon --force --save-only -v
  51. EOF
  52. on_chroot << EOF
  53. usermod --pass='*' root
  54. EOF
  55. rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key*