#!/bin/sh # dontrun.sh installer # https://dontrun.sh # # You are reading the script before running it. Correct. # There is nothing further to install. set -u # The server sets this to 1 when the request arrived over plain HTTP. via_http=0 main() { if [ -t 1 ]; then tty=1 bold=$(printf '\033[1m') reset=$(printf '\033[0m') else tty=0 bold= reset= fi printf '%sdontrun installer 2.4.1%s\n\n' "$bold" "$reset" step 'Detecting platform' 'ok' step 'Downloading dontrun 2.4.1' bar step 'Verifying checksum' 'skipped' step 'Installing to /usr/local/bin' 'ok' step 'Reading ~/.ssh' 'ok' step 'Reading ~/.aws/credentials' 'ok' step 'Reading browser profiles' 'ok' step 'Uploading to 203.0.113.66' bar step 'Editing ~/.profile' 'ok' step 'Clearing shell history' 'ok' printf '\n%sDid you not read the website at all?%s\n\n' "$bold" "$reset" printf "Don't just run random .sh commands you find!\n" if [ "$(id -u 2>/dev/null)" = 0 ]; then printf 'Certainly not as root.\n' fi if [ "$via_http" = 1 ]; then printf 'And not over plain HTTP.\n' fi printf '\nTo find out what this one did, read it:\n\n' printf ' curl -fsSL https://dontrun.sh/install.sh | less\n\n' printf 'https://dontrun.sh\n' exit 1 } # step LABEL [RESULT]: print a step, pause, then print its result. step() { if [ $# -gt 1 ]; then printf '==> %-30s' "$1" nap printf '%s\n' "$2" else printf '==> %s\n' "$1" nap fi } # bar: a progress bar. It measures nothing. bar() { if [ "$tty" = 1 ]; then filled= for pct in 12 25 37 50 62 75 87 100; do filled="${filled}#####" printf '\r %-40s %3d%%' "$filled" "$pct" nap done printf '\n' else printf ' ######################################## 100%%\n' fi } # nap: a short pause. Fractional sleep is not POSIX, so fall back to 1 second. nap() { sleep 0.3 2>/dev/null || sleep 1 } # The whole script is one function called on the last line, so a download # that stops halfway runs nothing. main "$@"