diff --git a/PRbL b/PRbL index c03ad9e..2fac6ba 160000 --- a/PRbL +++ b/PRbL @@ -1 +1 @@ -Subproject commit c03ad9e03328fe3f915b5995fc754e64b17c515d +Subproject commit 2fac6ba3a335a89acc07287928446bd6b92169d1 diff --git a/extras/Slipstream.install b/extras/Slipstream.install index 207a52a..811134b 100755 --- a/extras/Slipstream.install +++ b/extras/Slipstream.install @@ -1,6 +1,7 @@ #!/bin/bash # CodeDog Bootstrap installer script - +# To run this script without cloning or downloading anything: +# bash <(curl -ks 'https://github.com/pyr0ball/PRbL-bashrc/raw/main/extras/Slipstream.install') # Bash expansions to get the name and location of this script when run scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" @@ -12,7 +13,17 @@ else if [ -f ${rundir}/functions ] ; then source ${rundir}/functions else - source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') + # Iterate through get commands and fall back on next if unavailable + if command -v curl >/dev/null 2>&1; then + source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v wget >/dev/null 2>&1; then + source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v fetch >/dev/null 2>&1; then + source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + else + echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions." + exit 1 + fi fi fi @@ -56,12 +67,12 @@ check-deps(){ done pybin=$(which python3) if [ -z $pybin ] ; then - run sudo apt-get install -y python3 python3-pip + run install-packages python3 python3-pip # TODO: make a universal package install function fi pipbin=$(which pip3) if [ -z $pipbin ] ; then - run sudo apt-get install -y python3-pip + run install-packages python3-pip fi for pkg in ${pip_packages[@]} ; do pippkg_installed=$(pip list | grep -F $pkg ; echo $?) @@ -87,29 +98,32 @@ check-deps(){ } install-deps(){ - logger echo "Installing packages $sys_packages" - for _package in $sys_packages ; do - run sudo apt-get install -y $_package + logger echo "Installing packages: $sys_packages" + for _package in ${sys_packages[@]} ; do + run install-packages $_package done if [ -f ${rundir}/requirements.txt ] ; then pip install -y ${rundir}/requirements.txt else if [ ! -z $pip_packages ] ; then - pip install -y ${pip_packages[@]} + pip install ${pip_packages[@]} fi fi for _package in $prbl_packages ; do if [ -f ${rundir}/$_package ] ; then if [[ $dry_run != true ]] ; then - bash "${rundir}/$_package -i" + boxline "running extra $extra" + run "${rundir}/$_package -i" else - bash "${rundir}/$_package -D" + dry_run=false + run "${rundir}/$_package -D" + dry_run=true fi else if [[ $dry_run != true ]] ; then - run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/master/extras/$_package -i + run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/main/extras/$_package -i else - run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/master/extras/$_package -D + run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/main/extras/$_package -D fi fi done @@ -141,9 +155,9 @@ install(){ if ! check-deps ; then warn "Some of the utilities needed by this install are missing" boxtop - logger echo -e "Missing utilities:" + logger boxline "Missing utilities:" for bin in ${bins_missing[@]} ; do - logger echo -e "${bins_missing[$bin]}" + logger boxline "$bin" done boxbottom boxborder "Would you like to install them? (this will require root password)" diff --git a/extras/golang.install b/extras/golang.install old mode 100644 new mode 100755 index 6c2e6fd..74f362b --- a/extras/golang.install +++ b/extras/golang.install @@ -6,6 +6,7 @@ scriptname="${BASH_SOURCE[0]##*/}" script_title="${grn}Go${blu}la${red}n${ylw}g${dfl}" rundir="${BASH_SOURCE[0]%/*}" sys_arch=$(uname -m) +req_go_ver="1.19" golang_bashrc="# Golang system path setup export PATH=\$PATH:/usr/local/go/bin @@ -15,7 +16,21 @@ export PATH=\$PATH:/usr/local/go/bin if [ ! -z $prbl_functions ] ; then source $prbl_functions else - source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') + if [ -f ${rundir}/functions ] ; then + source ${rundir}/functions + else + # Iterate through get commands and fall back on next if unavailable + if command -v curl >/dev/null 2>&1; then + source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v wget >/dev/null 2>&1; then + source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v fetch >/dev/null 2>&1; then + source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + else + echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions." + exit 1 + fi + fi fi logfile="${rundir}/${pretty_date}_${scriptname}.log" @@ -63,6 +78,17 @@ check-deps(){ fi } +check-go(){ + if [[ -x /usr/bin/go ]] ; then + # TODO: Add version checking rather than just whether the binary is executible + #inst_go_ver=$(/usr/bin/go version | awl {'print $3'} | cut -c 3-) + #if [[ $(vercomp )]] + return 0 + else + return 1 + fi +} + install-deps(){ logger echo "Installing packages $sys_packages" run "for $_package in $sys_packages ; do sudo apt-get install -y $_package ; done" @@ -93,22 +119,45 @@ dry-run-report(){ } install(){ - local _golang_html=$(curl -ks "https://go.dev/dl/" | grep linux-amd64 | grep 1.19 | head -n 1) + if check-go ; then + boxline "golang already installed!" + return 0 + fi + if ! check-deps ; then + warn "Some of the utilities needed by this script are missing" + boxlinelog "Missing utilities:" + boxlinelog "${bins_missing[@]}" + boxlinelog "Would you like to install them? (this will require root password)" + utilsmissing_menu=( + "$(boxline "${green_check} Yes")" + "$(boxline "${red_x} No")" + ) + case `select_opt "${utilsmissing_menu[@]}"` in + 0) boxlinelog "${grn}Installing dependencies...${dfl}" + install-deps + ;; + 1) warn "Dependent Utilities missing: $bins_missing" ;; + esac + fi + + local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_arch | grep $req_go_ver | head -n 1) local golang_current=$(strip-html-tags "$_golang_html") #golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX` + logger boxborder "Pulling golang v$req_go_ver for installation" run wget "https://go.dev/dl/${golang_current}" -O $tmp_dir/$golang_current run sudo rm -rf /usr/local/go run sudo tar -C /usr/local -xzf $tmp_dir/$golang_current if [ ! -f $HOME/.bashrc.d/11-golang.bashrc ] ; then run echo -e "$codedog_bashrc" >> $HOME/.bashrc.d/11-golang.bashrc && \ - boxborder ".bashrc.d/11-golang.bashrc installed..." + logger boxborder ".bashrc.d/11-golang.bashrc installed..." fi export PATH=$PATH:/usr/local/go/bin - if [ ! -f /usr/bin/go ] ; then + if [ ! -x /usr/bin/go ] ; then run sudo ln -s /usr/local/go/bin/go /usr/bin/go && \ - boxborder "golang symlink created at /usr/bin/go" + logger boxborder "golang symlink created at /usr/bin/go" fi + return 0 } # Function for displaying the usage of this script diff --git a/install.sh b/install.sh index 0314b74..939797e 100755 --- a/install.sh +++ b/install.sh @@ -4,26 +4,34 @@ ################################################################### # initial vars -VERSION=2.3.3 +VERSION=2.3.4 scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION" # Bash expansions to get the name and location of this script when run scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" - -# Source PRbL functions from installer directory # Source PRbL Functions locally or retrieve from online -# TODO: Add version check to this if [ ! -z $prbl_functions ] ; then source $prbl_functions else if [ -f ${rundir}/functions ] ; then source ${rundir}/functions else - source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') + # Iterate through get commands and fall back on next if unavailable + if command -v curl >/dev/null 2>&1; then + source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v wget >/dev/null 2>&1; then + source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + elif command -v fetch >/dev/null 2>&1; then + source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions') + else + echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions." + exit 1 + fi fi fi + rundir_absolute=$(pushd $rundir ; pwd ; popd) escape_dir=$(printf %q "${rundir_absolute}") logfile="${rundir}/${pretty_date}_${scriptname}.log" @@ -196,14 +204,14 @@ install-functions(){ if [ -f ${rundir}/PRbL/functions ] ; then install-file ${rundir}/PRbL/functions ${installdir} else - curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions' > ${rundir}/functions + curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions' > ${rundir}/functions install-file ${rundir}/functions ${installdir} fi } take-backup(){ name="$1" - if [[ $update_run != true ]] ; then + # if [[ $update_run != true ]] ; then # Check if a backup file or symbolic link already exists if [[ -e "$name.bak" || -L "$name.bak" ]]; then run boxline " $name.bak backup already exists" @@ -219,11 +227,11 @@ take-backup(){ # Copy the file to the backup file with preservation of file attributes run cp -p "$name" "$backup_name" # Add the original file to the list of backup files - backup_files+=("$name") + run boxline " $name.bak backup already exists" # Log the original file name to the backup file list file run echo "$name" >> "$rundir/backup_files.list" fi - fi + # fi } restore-backup(){ @@ -232,7 +240,7 @@ restore-backup(){ run cp "$file".bak $file run echo "$file is restored" done - backup_files=() + run boxline " $name.bak backup already exists" if [ -f $rundir/backup_files.list ] ; then run rm $rundir/backup_files.list fi @@ -292,14 +300,17 @@ install-deps(){ } install-extras(){ - _extras=() - extra_installs=$(ls ${escape_dir}/extras/) - for file in $extra_installs ; do - _extras+=("$file") - done + _extras=($(ls ${escape_dir}/extras/ | grep -v 'log$')) + # extra_installs=$(ls ${escape_dir}/extras/) + # for file in $extra_installs ; do + # _extras+=("$file") + # done boxborder "Which extras should be installed?" - multiselect result _extras "false" + for each in {1..${#_extras[@]}} ; do + preselect+=("false") + done + multiselect result _extras preselect # For each extra, compare input choice and apply installs idx=0 @@ -307,12 +318,15 @@ install-extras(){ # If the selected user is set to true if [[ "${result[idx]}" == "true" ]] ; then if [[ $dry_run != true ]] ; then + boxline "running extra $extra" run "${escape_dir}/extras/$extra -i" else dry_run=false run "${escape_dir}/extras/$extra -D" dry_run=true fi + # else + # echo "index for $extra is ${result[idx]}" fi done } @@ -339,15 +353,6 @@ userinstall(){ # Create install directory under user's home directory run mkdir -p ${installdir} - # Check if functions already exist, and check if functions are out of date - if [ -f ${installdir}/functions ] ; then - # if functions are out of date, remove before installing new version - local installerfrev=$(cat ${rundir}/functions | grep functionsrev ) - if [[ $(vercomp ${installerfrev##*=} $installer_functionsrev ) == 2 ]] ; then - run rm ${installdir}/functions - fi - fi - # Copy functions first install-functions @@ -359,11 +364,17 @@ userinstall(){ warn "Some of the utilities needed by this script are missing" boxlinelog "Missing utilities:" boxlinelog "${bins_missing[@]}" - boxlinelog "After this installer completes, run:" - boxseparator - echo -en "\n${lbl}sudo apt install -y ${bins_missing[@]}\n${dfl}" - boxborder "Press 'Enter' key when ready to proceed" - read proceed + boxlinelog "Would you like to install them? (this will require root password)" + utilsmissing_menu=( + "$(boxline "${green_check} Yes")" + "$(boxline "${red_x} No")" + ) + case `select_opt "${utilsmissing_menu[@]}"` in + 0) boxlinelog "${grn}Installing dependencies...${dfl}" + install-deps + ;; + 1) warn "Dependent Utilities missing: $bins_missing" ;; + esac fi # Check for and parse the installed vim version @@ -513,7 +524,7 @@ update(){ run git stash -m "$pretty_date stashing changes before update to latest" run git fetch && run git pull --recurse-submodules pushd PRbL - run git checkout master + run git checkout main run git pull popd install