norisa.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/bin/bash
  2. # install git, vim, opendoas and (base-devel minus sudo)
  3. pacman -Sy --noconfirm --needed git vim opendoas autoconf automake binutils bison fakeroot file findutils flex gawk gcc gettext grep groff gzip libtool m4 make pacman patch pkgconf sed texinfo which || { printf "Error at script start:\n\nAre you sure you're running this as the root user?\n\t(Tip: run 'whoami' to check)\n\nAre you sure you have an internet connection?\n\t(Tip: run 'ip a' to check)\n"; exit; }
  4. setup_temporary_doas() {
  5. printf "permit nopass :wheel
  6. permit nopass root as $username\n" > /etc/doas.conf
  7. chown -c root:root /etc/doas.conf
  8. chmod -c 0400 /etc/doas.conf
  9. }
  10. setup_final_doas() {
  11. printf "permit persist :wheel
  12. permit nopass root as $username\n" > /etc/doas.conf
  13. chown -c root:root /etc/doas.conf
  14. chmod -c 0400 /etc/doas.conf
  15. }
  16. create_new_user() {
  17. read -rp "What is your desired username >>> " username
  18. useradd -m -g users -G wheel "$username"
  19. while true; do
  20. passwd "$username" && break
  21. done
  22. }
  23. choose_user() {
  24. echo "Available users:"
  25. ls /home
  26. while true; do
  27. read -rp "Enter in your chosen user >>> " username
  28. ls /home/ | grep -q "^$username$" && break
  29. done
  30. }
  31. # ask for new user if /home is not empty
  32. if [ "$(ls -A /home)" ]; then
  33. echo "/home/ not empty, human users already available"
  34. while true; do
  35. read -rp "Do you want to create a new user? [y/n] " want_new_user
  36. if echo "$want_new_user" | grep -q "y\|Y"; then
  37. create_new_user; break
  38. elif echo "$want_new_user" | grep -q "n\|N"; then
  39. choose_user; break
  40. fi
  41. done
  42. fi
  43. # create ~/ folders
  44. mkdir -p /home/"$username"/dox /home/"$username"/pix /home/"$username"/dl
  45. mkdir -p /home/"$username"/vids /home/"$username"/mus
  46. mkdir -p /home/"$username"/.local/bin /home/"$username"/.config
  47. mkdir -p /home/"$username"/.local/share /home/"$username"/.local/src
  48. chown -R "$username":users /home/"$username"/* /home/"$username"/.*
  49. setup_temporary_doas
  50. # install aur helper (paru)
  51. if ! pacman -Q | grep -q paru; then
  52. cd /home/"$username"/.local/src || exit
  53. pacman -S --noconfirm --needed asp bat devtools
  54. curl -sO https://aur.archlinux.org/cgit/aur.git/snapshot/paru-bin.tar.gz &&
  55. tar xvf paru-bin.tar.gz
  56. cd /home/"$username" && chown -R "$username":wheel /home/"$username"/.local/src/ && cd .local/src || exit
  57. cd paru-bin || exit
  58. doas -u "$username" makepkg --noconfirm -si
  59. rm /home/"$username"/.local/src/paru-bin.tar.gz
  60. fi
  61. # need to use piped yes as --noconfirm doesn't work with package conflicts
  62. if ! pacman -Q | grep -q libxft-bgra; then
  63. yes | doas -u "$username" paru -S --needed libxft-bgra
  64. fi
  65. # fetch dotfiles repo + apply dotfiles
  66. if [ ! -d /home/"$username"/.local/src/dotfiles ]; then
  67. cd /home/"$username"/.local/src || exit
  68. git clone https://github.com/noahvogt/dotfiles.git
  69. fi
  70. cd /home/"$username"/.local/src/dotfiles || exit
  71. doas -u "$username" /home/"$username"/.local/src/dotfiles/apply-dotfiles
  72. # download packages from the official repos
  73. pacman -S --noconfirm --needed xorg-server xorg-xinit xorg-xwininfo xorg-xprop xorg-xbacklight xorg-xdpyinfo xorg-xsetroot xbindkeys xf86-video-modesetting xf86-video-vesa xf86-video-fbdev libxinerama jdk-openjdk geogebra shellcheck neovim ranger xournalpp ffmpeg obs-studio sxiv arandr man-db brightnessctl unzip python mupdf-gl mediainfo highlight pulseaudio-alsa pulsemixer pamixer ttf-linux-libertine calcurse xclip noto-fonts-emoji imagemagick gimp xorg-setxkbmap wavemon texlive-most dash neofetch htop wireless_tools alsa-utils acpi zip libreoffice nm-connection-editor dunst libnotify dosfstools tlp mpv xorg-xinput cpupower zsh zsh-syntax-highlighting newsboat nomacs pcmanfm openbsd-netcat powertop mupdf-tools wget nomacs stow zsh-autosuggestions xf86-video-amdgpu xf86-video-intel xf86-video-nouveau npm fzf unclutter
  74. # install aur packages
  75. doas -u "$username" paru -S --noconfirm --needed betterlockscreen simple-mtpfs tibasicc-git redshift dashbinsh devour vim-plug lf-bin brave-bin picom-ibhagwan-git doasedit
  76. # build dwm
  77. if [ ! -d /home/"$username"/.local/src/dwm ]; then
  78. cd /home/"$username"/.local/src || exit
  79. git clone https://github.com/noahvogt/dwm.git
  80. fi
  81. cd /home/"$username"/.local/src/dwm || exit
  82. make install
  83. # build st
  84. if [ ! -d /home/"$username"/.local/src/st ]; then
  85. cd /home/"$username"/.local/src || exit
  86. git clone https://github.com/noahvogt/st.git
  87. fi
  88. cd /home/"$username"/.local/src/st || exit
  89. make install
  90. # build dwmblocks
  91. if [ ! -d /home/"$username"/.local/src/dwmblocks ]; then
  92. cd /home/"$username"/.local/src || exit
  93. git clone https://github.com/noahvogt/dwmblocks.git
  94. fi
  95. cd /home/"$username"/.local/src/dwmblocks || exit
  96. make install
  97. # build dmenu
  98. if [ ! -d /home/"$username"/.local/src/dmenu ]; then
  99. cd /home/"$username"/.local/src || exit
  100. git clone https://github.com/noahvogt/dmenu.git
  101. fi
  102. cd /home/"$username"/.local/src/dmenu || exit
  103. make install
  104. # set global zshenv
  105. mkdir -p /etc/zsh
  106. echo "export ZDOTDIR=\$HOME/.config/zsh" > /etc/zsh/zshenv
  107. # make initial history file
  108. mkdir -p /home/"$username"/.cache/zsh
  109. [ -f /home/"$username"/.cache/zsh/history ] ||
  110. touch /home/"$username"/.cache/zsh/history
  111. # make user to owner of ~/ and /mnt/
  112. chown -R "$username":users /home/"$username"/
  113. chown -R "$username":users /mnt/
  114. # change shell to zsh
  115. while true; do
  116. doas -u "$username" chsh -s "$(which zsh)" && break
  117. done
  118. # enable tap to click
  119. [ ! -f /etc/X11/xorg.conf.d/40-libinput.conf ] && printf 'Section "InputClass"
  120. Identifier "libinput touchpad catchall"
  121. MatchIsTouchpad "on"
  122. MatchDevicePath "/dev/input/event*"
  123. Driver "libinput"
  124. # Enable left mouse button by tapping
  125. Option "Tapping" "on"
  126. EndSection' > /etc/X11/xorg.conf.d/40-libinput.conf
  127. setup_final_doas
  128. # cleanup
  129. ls -A /home/"$username" | grep -q "\.bash" && rm /home/"$username"/.bash*
  130. ls -A /home/"$username" | grep -q "\.less" && rm /home/"$username"/.less*