rice.sh (7675B)
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 130 run_as_user curl -LO "https://github.com/catppuccin/gtk/releases/download/v1.0.3/catppuccin-mocha-mauve-standard+default.zip" 131 run_as_user unzip "catppuccin-mocha-mauve-standard+default.zip" 132 run_as_user mv catppuccin-mocha-mauve-standard+default /home/$PERMUSER/.local/share/themes/catppuccin 133 134 run_as_user dbus-launch gsettings set org.gnome.desktop.interface gtk-theme "catppuccin" 135 run_as_user dbus-launch gsettings set org.gnome.desktop.wm.preferences theme "catppuccin" 136 run_as_user dbus-launch gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu' 137 run_as_user dbus-launch gsettings set org.gnome.desktop.interface font-name "Sans 11" 138 139 cd .. 140 rm -rf hyprdots 141 rm -rf yay 142 rm -rf go 143 144 dinitctl enable cronie 145 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 - 146 147 run_as_user git clone https://github.com/lukesmithxyz/mutt-wizard /home/"$PERMUSER"/mutt-wizard 148 cd /home/"$PERMUSER"/mutt-wizard 149 make install 150 151 cd /home/"$PERMUSER" 152 run_as_user git clone https://git.awy.one/autofox 153 cd autofox 154 run_as_user ./configure_firefox.sh 155 cd /home/"$PERMUSER" 156 157 run_as_user git clone https://git.awy.one/wmenu 158 cd /home/"$PERMUSER"/wmenu 159 run_as_user git checkout gruvbox 160 run_as_user meson build 161 ninja -C build install 162 cd /home/"$PERMUSER" 163 164 rm -rf autofox 165 rm -rf mutt-wizard 166 rm -rf wmenu 167 168 # MPV 169 zip_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip 170 conf_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf 171 thumbfastlua_url=https://raw.githubusercontent.com/po5/thumbfast/refs/heads/master/thumbfast.lua 172 thumbfastconf_url=https://raw.githubusercontent.com/po5/thumbfast/refs/heads/master/thumbfast.conf 173 sponsorblock_url=https://codeberg.org/jouni/mpv_sponsorblock_minimal/raw/branch/master/sponsorblock_minimal.lua 174 zip_file=/tmp/uosc.zip 175 config_dir="/home/$PERMUSER/.config/mpv" 176 scriptopts_dir="$config_dir/script-opts" 177 conf_file="$scriptopts_dir/uosc.conf" 178 179 echo "Downloading archive..." 180 run_as_user curl -Ls -o $zip_file $zip_url || abort "Couldn't download: $zip_url" 181 echo "Extracting archive..." 182 run_as_user unzip -qod $config_dir $zip_file || abort "Couldn't extract: $zip_file" 183 echo "Deleting archive..." 184 rm -f $zip_file || echo "Couldn't delete: $zip_file" 185 186 run_as_user mkdir -p $scriptopts_dir || echo "Couldn't create: $scriptopts_dir" 187 run_as_user curl -Ls -o $conf_file $conf_url || echo "Couldn't download: $conf_url" 188 189 # thumbfast 190 run_as_user curl -Ls -o "$config_dir/scripts/thumbfast.lua" $thumbfastlua_url || echo "Couldn't download: $thumbfastlua_url" 191 run_as_user curl -Ls -o "$scriptopts_dir/thumbfast.conf" $thumbfastconf_url || echo "Couldn't download: $thumbfastconf_url" 192 sed -Ei "s/(network).*/\1=yes/" "$scriptopts_dir/thumbfast.conf" 193 194 # sponsorblock 195 run_as_user curl -Ls -o "$config_dir/scripts/sponsorblock_minimal.lua" $sponsorblock_url || echo "Couldn't download: $sponsorblock_url" 196 197 # necessary symlinks (pass for mutt-wizard and bemenu for tessen) 198 ln -s /bin/gopass /bin/pass 199 ln -s /usr/local/bin/wmenu /bin/bemenu 200 201 # nvchad 202 run_as_user git clone https://git.awy.one/nvchad /home/"$PERMUSER"/.config/nvim 203 cd /home/"$PERMUSER"/.config/nvim 204 run_as_user git checkout gruvbox 205 rm -rf /home/"$PERMUSER"/.config/nvim/.git 206 cd "/home/$PERMUSER" 207 208 # pam 209 sed -i '/auth[[:space:]]*include[[:space:]]*system-local-login/a auth optional pam_gnome_keyring.so' /etc/pam.d/login 210 sed -i '/session[[:space:]]*include[[:space:]]*system-local-login/a session optional pam_gnome_keyring.so auto_start' /etc/pam.d/login 211 echo "password optional pam_gnome_keyring.so" >> /etc/pam.d/passwd 212 213 if [ -x "$(command -v sudo)" ]; then 214 rm /etc/sudoers.d/temp 215 fi 216 217 yes | yay -Scc 218 rm -rf /home/"$PERMUSER"/.cargo 219 220 chown -R $PERMUSER:wheel /home/$PERMUSER 221 222 echo 223 echo "Your linux is riced!"