zerog

[archived] simple Parabola GNU/Linux post-install script
git clone git://git.hanetzok.net/zerog
Log | Files | Refs | README | LICENSE

zerog (3793B)


      1 #!/bin/bash
      2 
      3 ### VARIABLES ###
      4 
      5 name="$(logname)"
      6 homedir="/home/$name"
      7 progs="https://hanetzok.net/zerog/progs.list"
      8 dotfiles="git://git.hanetzok.net/dotfiles"
      9 logfile="/var/log/zerog.log"
     10 suckless="git://git.hanetzok.net"
     11 
     12 ### FUNCTIONS ###
     13 
     14 error() { # Write to logfile and exit script
     15     printf "#######\n#ERROR#\n#######\n$1\n" >> "$logfile"
     16     clear
     17     printf "Error: $1\n"
     18     exit 1
     19 }
     20 prepare() {
     21     printf "#############\n### zerog ###\n#############" > "$logfile"
     22     printf "Preparing...\n"
     23     printf "Refreshing keys...\n(This might take a while!)\n"
     24 
     25     # Refresh keyring and update keyrings
     26     pacman -Sy --noconfirm archlinux-keyring parabola-keyring >/dev/null 2>>"$logfile" || { error "Could not install keyrings"; }
     27 
     28     # Install some essential programs
     29     pacman -S --noconfirm --needed git zsh ca-certificates >/dev/null 2>>"$logfile" || { error "Initial installs failed"; }
     30 
     31     # Enable parallel downloads and make pacman look nice
     32     grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf
     33     sed -Ei "s/^#(ParallelDownloads).*/\1 = 5/;/^#Color$/s/#//" /etc/pacman.conf
     34 
     35     # Get progs.list
     36     cd /tmp && curl -O "$progs" || { error "Could not download progs.list"; }
     37 
     38     # Check for src dir and create if not found
     39     [ -d "$homedir/.local/src" ] || sudo -u "$name" mkdir -p "$homedir"/.local/src
     40 
     41 }
     42 
     43 install_programs() { # Read from progs.list and install each entry
     44     printf "### Installing from progs.list ###\n"
     45     while read -r program; do
     46 	printf "Installing $program\n"
     47 	pacman -S --noconfirm --needed  "$program" >/dev/null 2>>"$logfile" || printf "WARN: $program could not be installed\n" >> "$logfile"
     48     done < /tmp/progs.list
     49 }
     50 
     51 get_dotfiles() { # Download dotfiles and place them in $HOME
     52     printf "### Installing dotfiles ###\n"
     53     sudo -u "$name" git clone "$dotfiles" /tmp/dotfiles >/dev/null 2>>"$logfile" || { error "Could not clone dotfiles"; }
     54     sudo -u "$name" cp -rfT /tmp/dotfiles "$homedir" >/dev/null 2>>"$logfile"
     55     [ -d "$homedir/.git" ] && rm -rf "$homedir/.git"
     56     [ -d "$homedir/.config/mpop" ] && rm -rf "$homedir/.config/mpop"
     57     [ -d "$homedir/.config/msmtp" ] && rm -rf "$homedir/.msmtp"
     58 }
     59 
     60 suckless() { # Clone and install suckless programs
     61     printf "### Installing suckless software ###\n"
     62     for program in dwm st dmenu; do
     63 	cd "$homedir"/.local/src
     64 	printf "Installing $program\n"
     65 	sudo -u "$name" git clone "$suckless"/"$program" >/dev/null 2>>"$logfile" || { error "Could not clone $program"; }
     66 	cd "$program" && make clean install >/dev/null 2>>"$logfile" || { error "Could not install $program"; }
     67     done
     68 }
     69 
     70 follow_up() {
     71     printf "### Finishing touches ###\n"
     72 
     73     # Make zsh the default shell
     74     chsh -s /bin/zsh "$name" >/dev/null 2>>"$logfile"
     75 
     76     # Create some needed dirs
     77     sudo -u "$name" mkdir -p "$homedir/.cache/zsh/"
     78     sudo -u "$name" mkdir -p "$homedir/.config/mpd/playlists/"
     79 
     80     # Turn off the computer beep
     81     rmmod pcspkr
     82     printf "blacklist pcspkr\n" >/etc/modprobe.d/nobeep.conf
     83 
     84     # Get rid of no longer needed bash files
     85     yes | rm $homedir/.bash*
     86 
     87     # Add some services to default runtime
     88     rc-update add avahi-daemon default >/dev/null
     89     rc-update add cupsd default >/dev/null
     90     rc-update add tor default >/dev/null
     91 }
     92 
     93 ### SCRIPT ###
     94 clear
     95 printf "###########################\n########## ZEROG ##########\n###########################\n"
     96 
     97 prepare
     98 
     99 install_programs
    100 
    101 get_dotfiles
    102 
    103 suckless
    104 
    105 follow_up
    106 
    107 printf "###########################\n########## ZEROG ##########\n###########\
    108     ################\nZEROG flight finished. Log in again and run 'startx' to \
    109     start your new system\nIf you liked this script, want to report bugs/issues \
    110 	or contribute to it, let me know via mail <zerog@cybvik.xyz>\n"