rice

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

commit 54d8cb2b6f4dbf70c4c50f6d18bd0435c704124b
parent 1b0ea743288135ec7aa0273a0c1775de8f36bb79
Author: Mark Feller <mfeller@recurly.com>
Date:   Wed, 15 Jan 2020 14:35:40 -0700

setup debug mode

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

Diffstat:
Minstall | 63+++++++++++++--------------------------------------------------
1 file changed, 13 insertions(+), 50 deletions(-)

diff --git a/install b/install @@ -16,7 +16,7 @@ log() { # '$((${#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" | tee "$logfile" + "${3:-->}" "${2:+}$1${2:+}" "$2" } die() { @@ -30,16 +30,6 @@ try() { "$@" || die "Fatal: $*" } -prompt() { - # Ask the user for some input. - log "$1" - - # POSIX 'read' has none of the "nice" options like '-n', '-p' - # etc etc. This is the most basic usage of 'read'. - # '_' is used as 'dash' errors when no variable is given to 'read'. - read -r "$2" -} - trim_string() { # Usage: trim_string " example string " trim=${1#${1%%[![:space:]]*}} @@ -47,45 +37,22 @@ trim_string() { printf '%s\n' "$trim" } -getuserandpass() { - # Prompts user for new username an password. - prompt "Username?" name - while ! echo "$name" | grep "^[a-z_][a-z0-9_-]*$" >/dev/null 2>&1; do - prompt "Username?" name - done - prompt "Enter a password for that user." pass1 - prompt "Retype password." pass2 - while ! [ "$pass1" = "$pass2" ]; do - unset pass2 - log "Passwords do not match." "" "!>" - prompt "Enter password again." pass2 - done -} - -adduserandpass() { - # Adds user `$name` with password $pass1. - useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 || - usermod -a -G wheel "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name" - echo "$name:$pass1" | chpasswd - unset pass1 pass2 -} - 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 \ - >> "$logfile" + > "$debug" log "Enabling Fedora community repos..." - try dnf install dnf-plugins-core >> "$logfile" + try dnf install dnf-plugins-core > "$debug" log "Enabling i3-gaps community repo..." - try dnf copr enable -y gregw/i3desktop >> "$logfile" + try dnf copr enable -y gregw/i3desktop > "$debug" log "Enabling alacritty community repo..." - try dnf copr enable -y pschyska/alacritty >> "$logfile" + try dnf copr enable -y pschyska/alacritty > "$debug" } install_package() { @@ -93,11 +60,11 @@ install_package() { case $2 in G) log "Installing go package $1..." - try go get -u "$1" >> "$logfile" + try go get -u "$1" > "$debug" ;; *) log "Installing $1..." - try dnf install -y "$1" >> "$logfile" + try dnf install -y "$1" > "$debug" ;; esac } @@ -121,7 +88,7 @@ install_dots() { # Clone and install dot files log "Fetching dot files" su $name - git clone "$dotrepo" ~/.config/rice >> "$logfile" || log "Dots have already been cloned" + git clone "$dotrepo" ~/.config/rice > "$debug" || log "Dots have already been cloned" (cd ~/.config/rice && stow --target="$HOME" --ignore='gitignore' dots) exit } @@ -134,21 +101,17 @@ cleanup() { main() { # Set the git repo location for downloading dotfiles. This can be overridden # to install custom dotfiles. - dotrepo=${dotrepo:-"https://gitlab.com/mark.feller/rice.git"} + dotrepo=${RICE_REPO:-"https://gitlab.com/mark.feller/rice.git"} # Set the package list file that contains all packages to be installed. - pkgfile=${pkgfile:-"https://gitlab.com/mark.feller/rice/raw/master/packages"} + pkgfile=${RICE_PKG:-"https://gitlab.com/mark.feller/rice/raw/master/packages"} - # Set the log output file - logfile=${logfile:-"/var/log/rice.log"} + # Setup debug mode + debug="/dev/null" + [ "$RICE_DEBUG" != 1 ] || debug="/dev/stdout" trap cleanup INT - # Setup user - try getuserandpass - try adduserandpass - - # Install packages pre_install install_packages install_dots