Last active
December 12, 2018 21:14
-
-
Save deathtenk/7fd58c978010c432a5ec62013ce9983b to your computer and use it in GitHub Desktop.
modified version of clj install script for AWS lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
# Start | |
do_usage() { | |
echo "Installs the Clojure command line tools." | |
echo -e | |
echo "Usage:" | |
echo "linux-install.sh [-p|--prefix <dir>]" | |
exit 1 | |
} | |
default_prefix_dir="/usr/local" | |
# use getopt if the number of params grows | |
prefix_dir=$default_prefix_dir | |
prefix_param=${1:-} | |
prefix_value=${2:-} | |
if [[ "$prefix_param" = "-p" || "$prefix_param" = "--prefix" ]]; then | |
if [[ -z "$prefix_value" ]]; then | |
do_usage | |
else | |
prefix_dir="$prefix_value" | |
fi | |
fi | |
echo "Downloading and expanding tar" | |
curl -o /tmp/clojure-tools.tar.gz https://download.clojure.org/install/clojure-tools-1.9.0.397.tar.gz | |
tar xf /tmp/clojure-tools.tar.gz -C /tmp | |
lib_dir="$prefix_dir/lib" | |
bin_dir="$prefix_dir/bin" | |
man_dir="$prefix_dir/share/man/man1" | |
clojure_lib_dir="$lib_dir/clojure" | |
echo "Installing libs into $clojure_lib_dir" | |
install -Dm644 /tmp/clojure-tools/deps.edn "$clojure_lib_dir/deps.edn" | |
install -Dm644 /tmp/clojure-tools/example-deps.edn "$clojure_lib_dir/example-deps.edn" | |
install -Dm644 /tmp/clojure-tools/clojure-tools-1.9.0.397.jar "$clojure_lib_dir/libexec/clojure-tools-1.9.0.397.jar" | |
echo "Installing clojure and clj into $bin_dir" | |
sed -i -e 's@PREFIX@'"$clojure_lib_dir"'@g' /tmp/clojure-tools/clojure | |
install -Dm755 /tmp/clojure-tools/clojure "$bin_dir/clojure" | |
install -Dm755 /tmp/clojure-tools/clj "$bin_dir/clj" | |
echo "Installing man pages into $man_dir" | |
install -Dm644 /tmp/clojure-tools/clojure.1 "$man_dir/clojure.1" | |
install -Dm644 /tmp/clojure-tools/clj.1 "$man_dir/clj.1" | |
echo "Removing download" | |
rm -rf /tmp/clojure-tools | |
rm -rf /tmp/clojure-tools.tar.gz | |
echo "Use clj -h for help." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May I touch your hair???