#!/bin/sh ############# # CONSTANTS # ############# # default installation directory INSTALL_DIR_DEFAULT="/usr/local/bin" ############ # CLI ARGS # ############ # installation directory install_dir="${1}" # adjust default if given INSTALL_DIR_DEFAULT="${1:-${INSTALL_DIR_DEFAULT}}" ######## # MAIN # ######## # prompt for installation directory while [ ! -d "${install_dir}" ]; do printf "Select installation directory [Default: '%s']: " "${INSTALL_DIR_DEFAULT}" read -r install_dir /dev/stderr exit 1 fi fi fi done if [ ! -d "${install_dir}" ]; then echo "wtf?" exit 1 fi # start actual installation printf "Installing into '%s' ... " "${install_dir}" # install "kiwi" script uri="https://raw.githubusercontent.com/ldericher/kiwi-config/master/kiwi" tmp_file="$(mktemp)" if ! curl --proto '=https' --tlsv1.2 -sSf -o "${tmp_file}" "${uri}" >/dev/null 2>/dev/null; then rm "${tmp_file}" echo "Download 'kiwi' failed!" >/dev/stderr exit 1 fi if ! install -m 0755 "${tmp_file}" "${install_dir}/kiwi" >/dev/null 2>/dev/null; then rm "${tmp_file}" echo "Install 'kiwi' failed!" >/dev/stderr exit 1 fi rm "${tmp_file}" # finalization echo "OK" exit 0