Skip to content

Commit

Permalink
Merge pull request #1 from adrian-gheorghe/develop
Browse files Browse the repository at this point in the history
Add Install Script
  • Loading branch information
adrian-gheorghe authored Jul 13, 2019
2 parents 6840246 + 4fe31bd commit 223940e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,35 @@ Flags:
-e, --extcopy strings List of extensions that should be copied automatically
-h, --help help for mediafaker
-j, --jsonlog Change logger format to json
-m, --maxcopy int Maximum Size a file should have to be copied automatically (default 300000)
-m, --maxcopy int Maximum Size(in bytes) a file should have to be copied automatically if it cannot be faked (default 30000)
--version version for mediafaker

Use "mediafaker [command] --help" for more information about a command.
```
## Installation
```bash
wget -O https://raw.githubusercontent.com/adrian-gheorghe/mediafaker/master/install.sh | bash
```
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/adrian-gheorghe/mediafaker/master/install.sh)"
```
## Download
Download latest from the releases page: https://github.com/adrian-gheorghe/mediafaker/releases.
# Usage
mediafaker can be used in 2 ways.
mediafaker can be used in 2 ways, to either fake a local path or a remote url / ssh path.
## local
## Local
The simplest way is when the path you want to fake is on the same host as the destination path. Then you can run mediafaker local
```sh
mediafaker local \
--source="/opt/media" \
--destination="/home/project/public/fake/destination"
```
## remote
## Remote
When the source and destination paths are on different hosts mediafaker uses https://github.com/adrian-gheorghe/moni in order to generate a json representation of the directory you want to fake.
```json
Expand Down Expand Up @@ -120,21 +132,21 @@ When the source and destination paths are on different hosts mediafaker uses htt
]
```
### url
### URL
You can use moni https://github.com/adrian-gheorghe/moni or any other tool to generate a json output of the following form. mediafaker can use this to generate a fake version of the tree in your desired source.
```bash
moni url \
--source="http://example.org/path/to/moni.output.json" \
--destination="/home/project/public/fake/destination" \
--destination="/home/project/public/fake/destination"
```
This flow can easily be automated to give you access to a fresh abstracted version of the tree on demand.
You can get moni to run on your server periodically and create a new version of the output.json file as often as you like.
You can run mediafaker locally or on your dev/stage environments in order to have an up to date faked version of the public assets in production.
### ssh
### SSH
mediafaker has a ssh client built in. When calling the ssh command, mediafaker attempts to:
- connect to your remote host using the credentials provided
- download moni from github
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

var AppVersion = "0.1.0"
var AppVersion = "0.1.1"

var RootCmd = &cobra.Command{
Use: "mediafaker",
Expand Down
31 changes: 31 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Get final URL after curl is redirected
RELEASE_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/adrian-gheorghe/mediafaker/releases/latest)
# Extract tag after the last forward slash
TAG="${RELEASE_URL##*/}"

# Check if moni is currently installed
LOCAL_PATH=$(which moni)
if [ -x "$LOCAL_PATH" ]; then
echo "Moni is already Installed"
echo "Try running $(moni --help)"
exit 0
fi

echo "Attempting to download moni v${TAG}"

if [[ "$OSTYPE" == "linux-gnu" ]]; then
BINARY_PATH="moni-linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
BINARY_PATH="moni-darwin"
else
BINARY_PATH="moni"
fi

curl -L "https://github.com/adrian-gheorghe/mediafaker/releases/download/$TAG/$BINARY_PATH" --output $BINARY_PATH
chmod +x $BINARY_PATH
mv $BINARY_PATH /usr/local/bin/moni

echo "Moni installed successfully!"
moni --help

0 comments on commit 223940e

Please sign in to comment.