From Jack, 2 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2. # Archtoarmtix alpha by Jack.
  3. # This scripts converts Arch Linux Arm minimal image to Armtix with Dinit.
  4. # Born to convert Danct alarm (barebone) to armtix on the pinephone. Boot and kernel
  5. # should not change.
  6. # GUIDE:
  7. # - review the script.
  8. #   If its not Danct distro comment / uncomment the lines in the script, or remove
  9. #   its repo after the script.
  10. #   For a better (but slower) installation, uncomment the lines to reinstall all the
  11. #   packages.
  12. # - flash and boot a minimal alarm image
  13. # - conntect to internet and become root
  14. # - run the script
  15. # - review the patched pacman.conf.
  16. # - reboot
  17. #
  18. printf "Arch Linux Arm to Armtix script\nInternet required."
  19. read -n 1 -s -r -p "press any key to continue or ctrl+c..."
  20. # update  and time sync
  21. echo "Updating arch..."
  22. pacman -Syyu --noconfirm
  23. if [ $? -gt 0 ]; then read -p "Update failed! Continue ? (y/n): " ireply; if [ "$ireply" != "y" ]; then exit 1; fi fi
  24. pacman -S ntp wget --noconfirm
  25. echo "Updating time..."
  26. ntpdate pool.ntp.org && hwclock -w
  27. # fix pacman.conf and mirrorlist
  28. mv -f /etc/pacman.conf /etc/pacman.conf.arch
  29. wget -O /etc/pacman.conf https://gitlab.com/phkr/artixarm/-/raw/master/system/pacman/pacman.conf?inline=false
  30. if [ $? -gt 0 ]; then echo "Error downloading pacman.conf! Using the local one..."; cp -f oldpacman.conf /etc/pacman.conf; fi
  31. sed -i 's/@CARCH@/aarch64/' /etc/pacman.conf
  32. sed -i 's|\[system\].*|\[danctnix\]\nServer = https://p64.arikawa-hi.me/danctnix/aarch64/\n\n\[system\]\nSigLevel=Never|' /etc/pacman.conf
  33. #sed -i 's|\[system\].*|\[system\]\nSigLevel=Never|' /etc/pacman.conf
  34. sed -i 's|\[world\].*|\[world\]\nSigLevel=Never|' /etc/pacman.conf
  35. sed -i 's|\[galaxy\].*|\[galaxy\]\nSigLevel=Never|' /etc/pacman.conf
  36. sed -i '/\[extra\]/s/^#//' /etc/pacman.conf
  37. sed -i '/\[community\]/s/^#//' /etc/pacman.conf
  38. sed -i '/\[alarm\]/s/^#//' /etc/pacman.conf
  39. sed -i '/\[aur\]/s/^#//' /etc/pacman.conf
  40. sed -i '/mirrorlist-archlinuxarm/s/^#//' /etc/pacman.conf
  41. mv -f /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-archlinuxarm
  42. wget -O /etc/pacman.d/mirrorlist https://gitlab.com/phkr/artixarm/-/raw/master/system/artix-mirrorlist/mirrorlist?inline=false
  43. if [ $? -gt 0 ]; then echo "Error downloading mirrorlist! Using the local one..."; cp -f oldmirrorlist /etc/pacman.d/mirrorlist; fi
  44. cp -f /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-armtix
  45. # refresh repos
  46. # clear cache and sync
  47. pacman -Scc << EOF
  48. y
  49. n
  50. EOF
  51. echo "Updating repositories..."
  52. pacman -Syy --noconfirm
  53. if [ $? -gt 0 ]; then read -p "Repositories update failed! Continue ? (y/n): " ireply; if [ "$ireply" != "y" ]; then exit 1; fi fi
  54. pacman -S artix-keyring --noconfirm
  55. pacman-key --populate artix
  56. # backup enabled services on arch
  57. systemctl list-units --state=running | grep -v systemd | awk '{print $1}' | grep service > arch-autostarted-services
  58. # download Dinit and tools
  59. echo "Installing the init and software..."
  60. pacman -Sw base base-devel dinit dinit-system udev elogind dbus networkmanager samba archlinuxarm-mirrorlist openssh net-tools rsync nano lsb-release esysusers etmpfiles --noconfirm
  61. if [ $? -gt 0 ]; then read -p "Download failed! Continue ? (y/n): " ireply; if [ "$ireply" != "y" ]; then exit 1; fi fi
  62. # remove systemd
  63. pacman -Rdd --noconfirm systemd systemd-libs systemd-sysvcompat pacman-mirrorlist --noconfirm
  64. rm -fv /etc/resolv.conf
  65. cp -vf /etc/pacman.d/mirrorlist-armtix /etc/pacman.d/mirrorlist
  66. rm /usr/share/libalpm/hooks/dbus-reload.hook
  67. dhcpcd
  68. # install Dinit and tools
  69. pacman -S base base-devel dinit dinit-system udev elogind dbus networkmanager samba archlinuxarm-mirrorlist openssh net-tools rsync nano lsb-release esysusers etmpfiles --noconfirm
  70. if [ $? -gt 0 ]; then read -p "Update failed! Continue ? (y/n): " ireply; if [ "$ireply" != "y" ]; then exit 1; fi fi
  71. export LC_ALL=C
  72. # install services scripts
  73. pacman -S elogind-dinit dbus-dinit networkmanager-dinit alsa-utils alsa-utils-dinit haveged haveged-dinit openssh-dinit --noconfirm # autofs-dinit?
  74. if [ $? -gt 0 ]; then read -p "Update failed! Continue ? (y/n): " ireply; if [ "$ireply" != "y" ]; then exit 1; fi fi
  75. pacman -Syu --noconfirm
  76. # enable important services
  77. #dinitctl enable udevd
  78. #dinitctl enable NetworkManager
  79. #dinitctl enable dbus
  80. #dinitctl enable sshd
  81. ln -s /etc/dinit.d/udevd /etc/dinit.d/boot.d/
  82. ln -s /etc/dinit.d/NetworkManager /etc/dinit.d/boot.d/
  83. ln -s /etc/dinit.d/dbus /etc/dinit.d/boot.d/
  84. ln -s /etc/dinit.d/sshd /etc/dinit.d/boot.d/
  85. # reinstall packages - skipped
  86. #pacman -Sl system | grep installed | cut -d" " -f2 | pacman -S -
  87. #pacman -Sl world | grep installed | cut -d" " -f2 | pacman -S -
  88. #pacman -Sl galaxy | grep installed | cut -d" " -f2 | pacman -S -
  89. # remove more systemd files
  90. echo "Removing more systemd files..."
  91. for user in journal journal-gateway timesync network bus-proxy journal-remote journal-upload resolve coredump; do
  92. userdel systemd-$user
  93. done
  94. rm -vfr /{etc,var/lib}/systemd
  95. echo "All done!"
  96. read -p "Reboot ? (y/n): " ireply
  97. if [ "$ireply" = "y" ]; then
  98. reboot
  99. fi
  100. exit 0
  101.  
captcha