diff --git a/scripts/install_didier_stevens_pdf_tools.sh b/scripts/install_didier_stevens_pdf_tools.sh index 2722b2e..58344b3 100755 --- a/scripts/install_didier_stevens_pdf_tools.sh +++ b/scripts/install_didier_stevens_pdf_tools.sh @@ -1,20 +1,26 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + # Get Didier Stevens's pdf-parser.py and pdfid.py from github, place them in tools/ dir, and make executable -SCRIPT_PATH=$(dirname -- "$(readlink -f -- "$0";)";) -. "$SCRIPT_PATH/lib/project_paths.sh" +SCRIPT_PATH="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")" +. "${SCRIPT_PATH}/lib/project_paths.sh" TOOL_EXECUTABLES=(pdfid.py pdf-parser.py xorsearch.py) -DIDIER_STEVENS_RAW_GITHUB_URL='https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/' +DIDIER_STEVENS_RAW_GITHUB_URL="https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/" -mkdir -p "$PDFALYZER_TOOLS_DIR" -pushd "$PDFALYZER_TOOLS_DIR" +mkdir -p -v "${PDFALYZER_TOOLS_DIR}" +pushd "${PDFALYZER_TOOLS_DIR}" || exit 1 for tool_executable in "${TOOL_EXECUTABLES[@]}"; do - wget $DIDIER_STEVENS_RAW_GITHUB_URL/$tool_executable - chmod 744 "$PDFALYZER_TOOLS_DIR/$tool_executable" + wget --secure-protocol=auto --https-only --continue --verbose -N --tries=10 --check-certificate "${DIDIER_STEVENS_RAW_GITHUB_URL}/${tool_executable}" + chmod 744 "${PDFALYZER_TOOLS_DIR}/${tool_executable}" done -echo -e "\n\n\nDidier Stevens recommends always using the -O option with pdf-parser.py. This can be accomplished by setting the PDFPARSER_OPTIONS environment variable:\n" -echo -e " PDFPARSER_OPTIONS=-O\n\nYou are encouraged to add that to your environment via your .bash_profile or similar.\nThis has NOT been done automatically." -popd +printf "\n\n\nDidier Stevens recommends always using the -O option with pdf-parser.py. This can be accomplished by setting the PDFPARSER_OPTIONS environment variable:\n\n" +printf " PDFPARSER_OPTIONS=-O\n\nYou are encouraged to add that to your environment via your .bash_profile or similar.\nThis has NOT been done automatically.\n" +popd || exit 1 + diff --git a/scripts/install_t1utils.sh b/scripts/install_t1utils.sh index b2844e9..b35a4fa 100755 --- a/scripts/install_t1utils.sh +++ b/scripts/install_t1utils.sh @@ -3,19 +3,19 @@ # Requires autoconf and automake on macOS. if cat /etc/*release | grep ^NAME | egrep 'CentOS|Red|Fedora'; then - echo "Installing t1utils with yum..." + echo "Info: Installing t1utils with yum..." sudo yum install -y t1utils exit 0 elif cat /etc/*release | grep ^NAME | egrep 'Ubuntu|Debian|Mint|Knoppix'; then - echo "Installing t1utils with apt-get..." + echo "Info: Installing t1utils with apt-get..." sudo apt-get install -y t1utils exit 0 elif ! echo `uname -a` | grep Darwin 2>&1 >/dev/null; then - echo "OS NOT DETECTED, couldn't install t1utils" + echo "Warning: OS NOT DETECTED, couldn't install t1utils" exit 1; fi -echo "macOS detected, building t1utils from source..." +echo "Info: macOS detected, building t1utils from source..." for required_build_tool in automake autoconf make; do @@ -26,9 +26,8 @@ done SCRIPT_PATH=$(dirname -- "$(readlink -f -- "$0";)";) source "$SCRIPT_PATH/lib/project_paths.sh" -TMP_DIR="$PDFALYZER_PROJECT_PATH/tmp" +TMP_DIR="$(mktemp -d -p "${PDFALYZER_PROJECT_PATH}" -t "tmp.XXXXXXXXXX")" -mkdir -p "$TMP_DIR" pushd "$TMP_DIR" >/dev/null git clone https://github.com/kohler/t1utils.git