#!/bin/sh default_programs="./default-programs" dependencies=$(sed -n '/DEPENDENCIES_START/,/DEPENDENCIES_END/p' $default_programs | sed -e 's/DEPENDENCIES_START//' -e 's/DEPENDENCIES_END//') # check user is happy to run this script echo "This script is going to install all of the programs required for my scripts and dotfiles to function in a bisic manner. As such it will ask for root privilages." echo "Dependencies:$dependencies" read -r -p "Are you sure you want to continue? [y/N] " input case $input in [yY][eE][sS] | [yY]) echo "The program will continue..." ;; [nN][oO] | [nN]) exit 0 ;; *) echo "Invalid input..." exit 1 ;; esac # if yay is not installed the run the install script if ! command -v yay &> /dev/null; then ./install-yay fi failures=() # run though each dependency and install it if it's not already installed for dependency in $dependencies do if ! yay -Qi $dependency &> /dev/null; then echo "Installing $dependency and it's dependencies..." yay -S --noconfirm $dependency &> /dev/null fi if ! yay -Qi $dependency &> /dev/null; then failures+=("$dependency\n") fi done total_failures=$((${#failures[@]})) if [ $total_failures -gt 0 ]; then echo "Some of the programs failed to install..." echo "$failures" echo "Please manually rectify this and then rerun this setup with: ./setup deps" exit 1 else echo "Dependencies sucessfully installed" fi exit 0