11#! /usr/bin/env bash
22# HypnoScript runtime installer / updater
3+ #
4+ # SECURITY NOTICE:
5+ # This installer script may be executed via a command like:
6+ # curl -fsSL <URL> | bash
7+ # Downloading and executing remote code via a pipe to bash can be dangerous.
8+ # You should always review the script before running it, and consider downloading
9+ # and inspecting it first:
10+ # curl -fsSL <URL> -o install.sh
11+ # less install.sh
12+ # bash install.sh
13+ #
314
415set -euo pipefail
516
387398
388399info " Installing to $DEST_DIR "
389400if [[ ! -w " $DEST_DIR " ]]; then
390- $SUDO_PREFIX mkdir -p " $DEST_DIR "
401+ ${ SUDO_PREFIX} mkdir -p " $DEST_DIR "
391402fi
392- $SUDO_PREFIX install -m 0755 " $UNPACK_DIR /hypnoscript" " $DEST_DIR /hypnoscript"
403+ ${ SUDO_PREFIX} install -m 0755 " $UNPACK_DIR /hypnoscript" " $DEST_DIR /hypnoscript"
393404
394405META_DIR=" $DEST_DIR /../share/hypnoscript"
395- $SUDO_PREFIX mkdir -p " $META_DIR "
406+ ${ SUDO_PREFIX} mkdir -p " $META_DIR "
396407
397408if [[ -f " $UNPACK_DIR /VERSION.txt" ]]; then
398- $SUDO_PREFIX install -m 0644 " $UNPACK_DIR /VERSION.txt" " $META_DIR /VERSION.txt"
409+ ${ SUDO_PREFIX} install -m 0644 " $UNPACK_DIR /VERSION.txt" " $META_DIR /VERSION.txt"
399410fi
400411
401412if [[ -f " $UNPACK_DIR /install.sh" ]]; then
402- $SUDO_PREFIX install -m 0755 " $UNPACK_DIR /install.sh" " $META_DIR /install.sh"
413+ ${ SUDO_PREFIX} install -m 0755 " $UNPACK_DIR /install.sh" " $META_DIR /install.sh"
403414elif [[ -n " $SCRIPT_DIR " && -f " $SCRIPT_DIR /install.sh" ]]; then
404- $SUDO_PREFIX install -m 0755 " $SCRIPT_DIR /install.sh" " $META_DIR /install.sh"
415+ ${ SUDO_PREFIX} install -m 0755 " $SCRIPT_DIR /install.sh" " $META_DIR /install.sh"
405416fi
406417
407418info_tmp=$( mktemp 2> /dev/null) || info_tmp=" /tmp/hyp-install-info-$$ "
@@ -415,7 +426,7 @@ cat >"$info_tmp" <<EOF
415426 "source": "installer"
416427}
417428EOF
418- $SUDO_PREFIX install -m 0644 " $info_tmp " " $META_DIR /installation.json"
429+ ${ SUDO_PREFIX} install -m 0644 " $info_tmp " " $META_DIR /installation.json"
419430rm -f " $info_tmp "
420431
421432trap - EXIT
0 commit comments