rice

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c283ac1dbf1e3fe8cb9fc3bc16ddcca75460e2d2
parent 19d3acac4a77461b5191ab9b0b107b410e9e38f3
Author: Mark Feller <mfeller@recurly.com>
Date:   Thu, 19 Dec 2019 17:58:58 -0700

update installer

Signed-off-by: Mark Feller <mfeller@recurly.com>

Diffstat:
Minstall | 59++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Dpkgs/fedora/install | 29-----------------------------
Dpkgs/macos/install | 45---------------------------------------------
3 files changed, 58 insertions(+), 75 deletions(-)

diff --git a/install b/install @@ -1,3 +1,60 @@ #!/bin/sh +# +# Auto installer for macOS packages and dot files -stow --target=$HOME --ignore='gitignore' dots +log() { printf '\033[1;33m%s \033[m%s\033[m %s\n' "->" "${2:+}$1${2:+}" "$2" ; } + +# Determine which package manager exists on the system +if [ $(command -v dnf) ]; then + log "Installing packages for Fedora" + os=fedora + installpkg() { + dnf install -y "$1" + } +elif [ $(command -v brew) ]; then + log "Installing packages for macOS" + os=macos + installpkg() { + case $2 in + C) + log "Installing $program cask..." + brew cask install "$1" 2> /dev/null || brew cask upgrade "$1" + ;; + *) + log "Installing $program..." + brew install "$1" 2> /dev/null || brew upgrade "$1" + ;; + esac + } +fi + +dotsrepo=${dotfilesrepo:-"https://gitlab.com/mark.feller/rice.git"} +pkgfile=${pkgfile:-"https://gitlab.com/mark.feller/rice/raw/master/pkgs/$os/packages"} + +trim_string() { + # Usage: trim_string " example string " + trim=${1#${1%%[![:space:]]*}} + trim=${trim%${trim##*[![:space:]]}} + printf '%s\n' "$trim" +} + +install_packages() { + # Copy a real file to our temp pkgfile or attempt to curl the pkgfile + ([ -f "$pkgfile" ] && cp "$pkgfile" /tmp/pkgs) || (log "Downloading package list..." && curl -Ls "$pkgfile" > /tmp/pkgs) + + packages=$(sed '/^$/d' /tmp/pkgs | sed '/^#/d') + while IFS=' ' read -r flag program comment; do + program=$(trim_string "$program") + installpkg $progrm $flag + done <<EOF +$packages +EOF +} + +install_dots() { + git clone "$dotsrepo" ~/.config/rice || log "Dots have already been cloned" + (cd ~/.config/rice && stow --target=$HOME --ignore='gitignore' dots) +} + +install_packages +install_dots diff --git a/pkgs/fedora/install b/pkgs/fedora/install @@ -1,29 +0,0 @@ -#!/bin/sh -# -# Auto installer for Fedora packages and dot files - -dotsrepo=${dotfilesrepo:-"https://gitlab.com/mark.feller/rice.git"} -pkgfile=${pkgfile:-"https://gitlab.com/mark.feller/rice/raw/master/pkgs/fedora/packages"} - -log() { printf '\033[1;33m%s \033[m%s\033[m %s\n' "->" "${2:+}$1${2:+}" "$2" ; } - -install_packages() { - # Copy a real file to our temp progsfile or attempt to curl the progsfile - ([ -f "$pkgfile" ] && cp "$pkgfile" /tmp/pkgs) || curl -Ls "$pkgfile" > /tmp/pkgs - - packages=$(sed '/^$/d' /tmp/pkgs | sed '/^#/d') - while IFS=' ' read -r program comment; do - log "Installing $program..." - dnf install -y $program - done <<EOF -$packages -EOF -} - -install_dots() { - git clone "$dotsrepo" ~/.config/rice || log "Dots have already been cloned" - (cd ~/.config/rice && ./install) -} - -install_packages -install_dots diff --git a/pkgs/macos/install b/pkgs/macos/install @@ -1,45 +0,0 @@ -#!/bin/sh -# -# Auto installer for macOS packages and dot files - -dotsrepo=${dotfilesrepo:-"https://gitlab.com/mark.feller/rice.git"} -pkgfile=${pkgfile:-"https://gitlab.com/mark.feller/rice/raw/master/pkgs/macos/packages"} - -log() { printf '\033[1;33m%s \033[m%s\033[m %s\n' "->" "${2:+}$1${2:+}" "$2" ; } - -trim_string() { - # Usage: trim_string " example string " - trim=${1#${1%%[![:space:]]*}} - trim=${trim%${trim##*[![:space:]]}} - printf '%s\n' "$trim" -} - -install_packages() { - # Copy a real file to our temp pkgfile or attempt to curl the pkgfile - ([ -f "$pkgfile" ] && cp "$pkgfile" /tmp/pkgs) || (log "Downloading package list..." && curl -Ls "$pkgfile" > /tmp/pkgs) - - packages=$(sed '/^$/d' /tmp/pkgs | sed '/^#/d') - while IFS=' ' read -r flag program comment; do - program=$(trim_string "$program") - case $flag in - C) - log "Installing $program cask..." - brew cask install "$program" 2> /dev/null || brew cask upgrade "$program" - ;; - *) - log "Installing $program..." - brew install "$program" 2> /dev/null || brew upgrade "$program" - ;; - esac - done <<EOF -$packages -EOF -} - -install_dots() { - git clone "$dotsrepo" ~/.config/rice || log "Dots have already been cloned" - (cd ~/.config/rice && ./install) -} - -install_packages -install_dots