rice

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

commit 0c67f5b78553722f379694b0011cd6026f4e7330
parent 4b5f90de49dab3ce3e06839ac2aefa011a9b8f01
Author: Mark Feller <mjfeller1992@gmail.com>
Date:   Mon, 25 May 2020 09:47:09 -0600

cleanup installer

Diffstat:
MREADME | 4++--
Minstall | 128++++++++++++-------------------------------------------------------------------
2 files changed, 21 insertions(+), 111 deletions(-)

diff --git a/README b/README @@ -1,6 +1,6 @@ Installation ============ -Install packages and dot files:: +Install dot files:: - $ curl -L mfeller.io/install.sh | sudo sh + $ ./install diff --git a/install b/install @@ -1,117 +1,27 @@ #!/bin/sh -# -# Auto installer for Fedora packages and dot files -log() { - # Print a message prettily. - # - # This function uses the literal escape character (Ctrl+V+Escape) as - # a simple way of *safely* bypassing the escape sequence restrictions - # on 'printf %s'. Cheeky, I know. - # - # '\033[1;32m' Set text to color '2' and make it bold. - # '\033[m': Reset text formatting. - # '${3:-->}': If the 3rd argument is missing, set prefix to '->'. - # '${2:+[1;3Xm}': If the 2nd argument exists, set the text style of '$1'. - # '$((${#1}%5+1))': Color the package name based on its length. - # '${2:+[m}': If the 2nd argument exists, reset text formatting. - printf '\033[1;33m%s \033[m%s\033[m %s\n' \ - "${3:-->}" "${2:+}$1${2:+}" "$2" +shared() { + cp -rv dots/.config/git $HOME/.config + cp -rv dots/.config/lf $HOME/.config + cp -rv dots/.config/mpd $HOME/.config + cp -rv dots/.config/ncmpcpp $HOME/.config + cp -rv dots/.config/notmuch $HOME/.config + cp -rv dots/.config/zsh $HOME/.config + cp -rv dots/.config/aliases $HOME/.config + cp -rv dots/.emacs.d $HOME + cp -rv dots/.local $HOME } -die() { - # Print a message and exit with '1' (error). - log "$1" "$2" "!>" >&2 - exit 1 +linux() { + cp -rv dots/.config/compton $HOME/.config + cp -rv dots/.config/dunst $HOME/.config + cp -rv dots/.config/vis $HOME/.config } -try() { - # Attemped to run the command and exit on error - "$@" || die "Fatal: $*" +macos() { + shared + cp -rv dots/.zshenv $HOME + cp -rv dots/.config/alacritty $HOME/.config } -trim_string() { - # Usage: trim_string " example string " - trim=${1#${1%%[![:space:]]*}} - trim=${trim%${trim##*[![:space:]]}} - printf '%s\n' "$trim" -} - -pre_install() { - # Run any preinstall setup necessary - log "Enabling RPM Fustion..." - try dnf install -y \ - https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm \ - https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm \ - > "$debug" - - log "Enabling Fedora community repos..." - try dnf install dnf-plugins-core > "$debug" - - log "Enabling i3-gaps community repo..." - try dnf copr enable -y gregw/i3desktop > "$debug" - - log "Enabling alacritty community repo..." - try dnf copr enable -y pschyska/alacritty > "$debug" -} - -install_package() { - # Install a single package $1 based on its flags $2 - case $2 in - G) - log "Installing go package $1..." - try go get -u "$1" > "$debug" - ;; - *) - log "Installing $1..." - try dnf install -y "$1" > "$debug" - ;; - esac -} - -install_packages() { - # Fetch the package file and install all 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") - install_package $program $flag - done <<EOF -$packages -EOF -} - -install_dots() { - # Clone and install dot files - log "Fetching dot files" - git clone "$dotrepo" ~/.config/rice > "$debug" || log "Dots have already been cloned" - (cd ~/.config/rice && stow --target="$HOME" --ignore='gitignore' dots) -} - -cleanup() { - # Cleanup on exit or error. - die "Aborting auto rice" -} - -main() { - # Set the git repo location for downloading dotfiles. This can be overridden - # to install custom dotfiles. - dotrepo=${RICE_REPO:-"https://gitlab.com/mark.feller/rice.git"} - - # Set the package list file that contains all packages to be installed. - pkgfile=${RICE_PKG:-"https://gitlab.com/mark.feller/rice/raw/master/packages"} - - # Setup debug mode - if [ "$RICE_DEBUG" == 1 ]; then debug="/dev/stdout"; else debug="/dev/null"; fi - - trap cleanup INT - - pre_install - install_packages - install_dots -} - -main +macos