From 2755f9521eb2d1c26df3a153e69b8834624b5101 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Sat, 21 Jan 2017 14:26:17 +0900 Subject: [PATCH] Add install script --- README.md | 5 +++++ install.sh | 20 ++++++++++++++++++++ meshi | 26 ++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 install.sh diff --git a/README.md b/README.md index 1fa1b94..822e587 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,9 @@ shokujin Bob < Whoo! Let's go to shokujin!!! +## Installation + +```bash +sudo ./install.sh # or $ PREFIX=/prefix/path ./install.sh +``` diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..77751d9 --- /dev/null +++ b/install.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +if [ -z "$PREFIX" ]; then + PREFIX='' +fi + +ASSET_INSTALL_DIR="$PREFIX/etc/meshi" +mkdir -p "$ASSET_INSTALL_DIR" +cp meshi.list "$ASSET_INSTALL_DIR" + +COMMAND_INSTALL_DIR="$PREFIX/opt/local/bin" +mkdir -p "$COMMAND_INSTALL_DIR" +cp meshi "$COMMAND_INSTALL_DIR/meshi" +case "$(uname -s)" in + Darwin ) sed -i '' -e "s|/etc/|$PREFIX/etc/|g" "$COMMAND_INSTALL_DIR/meshi" ;; + * ) sed -ie "s|/etc/|$PREFIX/etc/|g" "$COMMAND_INSTALL_DIR/meshi" ;; +esac + diff --git a/meshi b/meshi index 1637ddc..5502b41 100755 --- a/meshi +++ b/meshi @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eo pipefail +[ -n "$MESHI_DEBUG" ] && set -x SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) @@ -14,10 +15,31 @@ if ! type "$SHUF_COMMAND" > /dev/null 2>&1; then exit 1 fi -MESHI_LIST_PATH="$SCRIPT_DIR/meshi.list" + +function usage() { + cat <