rice.sh (7399B)
1 #!/bin/sh 2 set -e 3 WORKDIRECTORY=$PWD 4 5 if [ "$(id -u)" -ne 0 ] 6 then printf "The script has to be run as root.\n" 7 exit 8 fi 9 10 PERMUSER="$(id -nu "1000")" 11 12 id "$PERMUSER" > /dev/null 2>&1 || { echo "User $PERMUSER does not exist. Exiting."; exit 1; } 13 14 if [ -x "$(command -v doas)" ]; then 15 evalcommand="doas -u $PERMUSER" 16 else 17 evalcommand="sudo -u $PERMUSER" 18 echo "%wheel ALL=(ALL) NOPASSWD: ALL 19 Defaults:%wheel,root runcwd=*" >/etc/sudoers.d/temp 20 fi 21 22 run_as_user() { 23 $evalcommand "$@" 24 } 25 26 DEPLIST="`sed -e 's/#.*$//' -e '/^$/d' dependencies.txt | tr '\n' ' '`" 27 pacman -Sy --noconfirm 28 pacman -S $DEPLIST --noconfirm --needed 29 30 run_as_user cp -r "$WORKDIRECTORY"/.config /home/"$PERMUSER" 31 run_as_user cp -r "$WORKDIRECTORY"/.local /home/"$PERMUSER" 32 run_as_user cp -a "$WORKDIRECTORY"/.zprofile /home/"$PERMUSER" 33 34 run_as_user mkdir -p /home/"$PERMUSER"/.config/git 35 run_as_user touch /home/"$PERMUSER"/.config/git/config 36 run_as_user mkdir -p /home/"$PERMUSER"/.config/npm 37 run_as_user touch /home/"$PERMUSER"/.config/npm/npmrc 38 run_as_user mkdir -p /home/"$PERMUSER"/.cache/zsh 39 run_as_user mkdir -p /home/"$PERMUSER"/.config/mpd/playlists 40 run_as_user mkdir -p /home/"$PERMUSER"/.local/share/themes 41 run_as_user mkdir -p /home/"$PERMUSER"/.local/share/icons 42 43 cd "$WORKDIRECTORY" || exit 44 run_as_user git clone https://github.com/zdharma-continuum/fast-syntax-highlighting 45 mkdir -p /usr/share/zsh/plugins 46 cp -rf fast-syntax-highlighting /usr/share/zsh/plugins 47 cd "$WORKDIRECTORY" 48 49 run_as_user mkdir -p /home/"$PERMUSER"/.ssh 50 run_as_user mkdir -p /home/"$PERMUSER"/.gnupg 51 run_as_user touch /home/"$PERMUSER"/.gnupg/gpg-agent.conf 52 53 cat <<EOL >> /home/$PERMUSER/.gnupg/gpg-agent.conf 54 enable-ssh-support 55 pinentry-program /usr/bin/pinentry-gnome3 56 default-cache-ttl 34560000 57 max-cache-ttl 34560000 58 EOL 59 60 cat <<EOL >> /home/$PERMUSER/.config/npm/npmrc 61 prefix=\${XDG_DATA_HOME}/npm 62 cache=\${XDG_CACHE_HOME}/npm 63 init-module=\${XDG_CONFIG_HOME}/npm/config/npm-init.js 64 logs-dir=\${XDG_STATE_HOME}/npm/logs 65 EOL 66 67 run_as_user find /home/"$PERMUSER"/.gnupg -type f -exec chmod 600 {} \; 68 run_as_user find /home/"$PERMUSER"/.gnupg -type d -exec chmod 700 {} \; 69 run_as_user find /home/"$PERMUSER"/.ssh -type f -exec chmod 600 {} \; 70 run_as_user find /home/"$PERMUSER"/.ssh -type d -exec chmod 700 {} \; 71 72 chsh -s /bin/zsh "$PERMUSER" 73 74 mkdir -p /root/.config/nvim 75 cat <<EOL >> /root/.config/nvim/init.vim 76 set title 77 set clipboard+=unnamedplus 78 set relativenumber 79 colorscheme vim 80 EOL 81 82 # Make pacman colorful, concurrent downloads and Pacman eye-candy. 83 grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf 84 sed -Ei "s/^#(ParallelDownloads).*/\1 = 5/;/^#Color$/s/#//" /etc/pacman.conf 85 86 # Disable Pacman sandbox since kernel doesn't support landlock (only for custom kernels from my artix script) 87 # sed -Ei "s/^#(DisableSandbox).*/\1/" /etc/pacman.conf 88 89 # Use all cores for compilation. 90 sed -i "s/-j2/-j$(nproc)/;/^#MAKEFLAGS/s/^#//" /etc/makepkg.conf 91 92 if [ -x "$(command -v doas)" ]; then 93 # Use doas for Pacman authentification 94 sed -i 's/#PACMAN_AUTH=.*$/PACMAN_AUTH=(doas)/' /etc/makepkg.conf 95 fi 96 97 cat <<EOL >> /usr/share/libalpm/hooks/statusbar.hook 98 [Trigger] 99 Operation = Upgrade 100 Type = Package 101 Target = * 102 103 [Action] 104 Description = Updating statusbar... 105 When = PostTransaction 106 Exec = /usr/bin/pkill -RTMIN+8 waybar 107 EOL 108 109 110 cat <<EOL >> /etc/pacman.d/hooks/sing-box.hook 111 [Trigger] 112 Type = Package 113 Operation = Install 114 Operation = Upgrade 115 Target = sing-box 116 117 [Action] 118 Description = Setting rights for sing-box... 119 When = PostTransaction 120 Exec = /usr/bin/setcap cap_net_admin=ep /usr/sbin/sing-box 121 EOL 122 123 run_as_user git clone https://aur.archlinux.org/yay.git 124 cd yay 125 run_as_user makepkg -csi --noconfirm 126 cd "$WORKDIRECTORY" 127 DEPLIST="`sed -e 's/#.*$//' -e '/^$/d' aurdeps.txt | tr '\n' ' '`" 128 run_as_user yay -S $DEPLIST --noconfirm 129 run_as_user dbus-launch gsettings set org.gnome.desktop.interface gtk-theme "Gruvbox-Material-Dark-HIDPI" 130 run_as_user dbus-launch gsettings set org.gnome.desktop.wm.preferences theme "Gruvbox-Material-Dark-HIDPI" 131 run_as_user dbus-launch gsettings set org.gnome.desktop.interface icon-theme "Gruvbox-Material-Dark" 132 run_as_user dbus-launch gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu' 133 run_as_user dbus-launch gsettings set org.gnome.desktop.interface font-name "Sans 11" 134 cd .. 135 rm -rf hyprdots 136 rm -rf yay 137 rm -rf go 138 139 dinitctl enable cronie 140 echo "*/30 * * * * /home/$PERMUSER/.local/bin/cron/newsup\n*/30 * * * * /home/$PERMUSER/.local/bin/cron/checkup\n*/10 * * * * /usr/local/bin/mailsync" | run_as_user crontab - 141 142 run_as_user git clone https://github.com/lukesmithxyz/mutt-wizard /home/"$PERMUSER"/mutt-wizard 143 cd /home/"$PERMUSER"/mutt-wizard 144 make install 145 146 cd /home/"$PERMUSER" 147 run_as_user git clone https://git.awy.one/autowolf 148 cd autowolf 149 run_as_user ./configure_librewolf.sh 150 cd /home/"$PERMUSER" 151 152 run_as_user git clone https://git.awy.one/wmenu 153 cd /home/"$PERMUSER"/wmenu 154 run_as_user meson build 155 ninja -C build install 156 cd /home/"$PERMUSER" 157 158 rm -rf autowolf 159 rm -rf mutt-wizard 160 rm -rf wmenu 161 162 # MPV 163 zip_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip 164 conf_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf 165 thumbfastlua_url=https://raw.githubusercontent.com/po5/thumbfast/refs/heads/master/thumbfast.lua 166 thumbfastconf_url=https://raw.githubusercontent.com/po5/thumbfast/refs/heads/master/thumbfast.conf 167 sponsorblock_url=https://codeberg.org/jouni/mpv_sponsorblock_minimal/raw/branch/master/sponsorblock_minimal.lua 168 zip_file=/tmp/uosc.zip 169 config_dir="/home/$PERMUSER/.config/mpv" 170 scriptopts_dir="$config_dir/script-opts" 171 conf_file="$scriptopts_dir/uosc.conf" 172 173 echo "Downloading archive..." 174 run_as_user curl -Ls -o $zip_file $zip_url || abort "Couldn't download: $zip_url" 175 echo "Extracting archive..." 176 run_as_user unzip -qod $config_dir $zip_file || abort "Couldn't extract: $zip_file" 177 echo "Deleting archive..." 178 rm -f $zip_file || echo "Couldn't delete: $zip_file" 179 180 run_as_user mkdir -p $scriptopts_dir || echo "Couldn't create: $scriptopts_dir" 181 run_as_user curl -Ls -o $conf_file $conf_url || echo "Couldn't download: $conf_url" 182 183 # thumbfast 184 run_as_user curl -Ls -o "$config_dir/scripts/thumbfast.lua" $thumbfastlua_url || echo "Couldn't download: $thumbfastlua_url" 185 run_as_user curl -Ls -o "$scriptopts_dir/thumbfast.conf" $thumbfastconf_url || echo "Couldn't download: $thumbfastconf_url" 186 sed -Ei "s/(network).*/\1=yes/" "$scriptopts_dir/thumbfast.conf" 187 188 # sponsorblock 189 run_as_user curl -Ls -o "$config_dir/scripts/sponsorblock_minimal.lua" $sponsorblock_url || echo "Couldn't download: $sponsorblock_url" 190 191 # necessary symlinks (pass for mutt-wizard and bemenu for tessen) 192 ln -s /bin/gopass /bin/pass 193 ln -s /usr/local/bin/wmenu /bin/bemenu 194 195 # nvchad 196 run_as_user git clone https://git.awy.one/nvchad /home/"$PERMUSER"/.config/nvim 197 rm -rf /home/"$PERMUSER"/.config/nvim/.git 198 199 # pam 200 sed -i '/auth[[:space:]]*include[[:space:]]*system-local-login/a auth optional pam_gnome_keyring.so' /etc/pam.d/login 201 sed -i '/session[[:space:]]*include[[:space:]]*system-local-login/a session optional pam_gnome_keyring.so auto_start' /etc/pam.d/login 202 echo "password optional pam_gnome_keyring.so" >> /etc/pam.d/passwd 203 204 if [ -x "$(command -v sudo)" ]; then 205 rm /etc/sudoers.d/temp 206 fi 207 208 yes | yay -Scc 209 rm -rf /home/"$PERMUSER"/.cargo 210 211 chown -R $PERMUSER:wheel /home/$PERMUSER 212 213 echo 214 echo "Your linux is riced!"