Skip to content

Commit

Permalink
Add install script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizunashi Mana committed Feb 13, 2017
1 parent 0f3a86b commit 2755f95
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ shokujin

Bob < Whoo! Let's go to shokujin!!!

## Installation

```bash
sudo ./install.sh # or $ PREFIX=/prefix/path ./install.sh
```

20 changes: 20 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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

26 changes: 24 additions & 2 deletions meshi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -e
set -eo pipefail
[ -n "$MESHI_DEBUG" ] && set -x

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

Expand All @@ -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 <<EOS
Usage: meshi [option] [name]
--help : Show this help
-l/--list : Use custom meshi list (default: /etc/meshi/meshi.list)
EOS
[ -z "$1" ] || exit "$1"
}

if [[ "$1" == '--help' ]]; then
usage 0
fi

MESHI_LIST_PATH="/etc/meshi/meshi.list"
if [[ "$1" == '-l' ]] || [[ "$1" == '--list' ]]; then
MESHI_LIST_PATH="$2"
shift 2
fi


if [ "$1" != '' ]; then
echo $1
else
cat $MESHI_LIST_PATH | $SHUF_COMMAND | head -1
fi

0 comments on commit 2755f95

Please sign in to comment.