2014-09-09 05:49:43 +02:00
fiche [](https://travis-ci.org/solusipse/fiche)
2013-09-05 18:59:56 -07:00
=====
Command line pastebin for sharing terminal output.
2013-09-06 04:01:55 +02:00
2017-09-02 21:38:03 +02:00
# Client-side usage
2017-09-02 18:53:43 +02:00
Self-explanatory live examples (using public server):
```
echo just testing! | nc termbin.com 9999
```
```
cat file.txt | nc termbin.com 9999
```
In case you installed and started fiche on localhost:
```
ls -la | nc localhost 9999
```
2017-10-16 16:34:00 +02:00
You will get an url to your paste as a response, e.g.:
```
http://termbin.com/ydxh
```
You can use our beautification service to get any paste colored and numbered. Just ask for it using `l.termbin.com` subdomain, e.g.:
```
http://l.termbin.com/ydxh
```
2017-09-02 21:38:03 +02:00
-------------------------------------------------------------------------------
## Useful aliases
2017-09-02 21:22:35 +02:00
You can make your life easier by adding a termbin alias to your rc file. We list some of them here:
2017-09-02 21:38:03 +02:00
-------------------------------------------------------------------------------
### Pure-bash alternative to netcat
2017-09-02 21:39:15 +02:00
__Linux/macOS:__
2017-09-02 21:38:03 +02:00
```
alias tb="(exec 3< >/dev/tcp/termbin.com/9999; cat >&3; cat < &3; exec 3< & -)"
```
```
echo less typing now! | tb
```
_See [#42 ](https://github.com/solusipse/fiche/issues/42 ), [#43 ](https://github.com/solusipse/fiche/issues/43 ) for more info._
-------------------------------------------------------------------------------
### `tb` alias
2017-09-02 21:22:35 +02:00
__Linux (Bash):__
```
echo 'alias tb="nc termbin.com 9999"' >> .bashrc
```
```
echo less typing now! | tb
```
__macOS:__
```
echo 'alias tb="nc termbin.com 9999"' >> .bash_profile
```
```
echo less typing now! | tb
```
2017-09-02 21:38:03 +02:00
-------------------------------------------------------------------------------
### Copy output to clipboard
2017-09-02 21:22:35 +02:00
__Linux (Bash):__
```
echo 'alias tbc="netcat termbin.com 9999 | xclip -selection c"' >> .bashrc
```
```
echo less typing now! | tbc
```
__macOS:__
```
echo 'alias tbc="nc termbin.com 9999 | pbcopy"' >> .bash_profile
```
```
echo less typing now! | tbc
```
2018-02-18 04:17:35 +11:00
__Remember__ to reload the shell with `source ~/.bashrc` or `source ~/.bash_profile` after adding any of provided above!
2017-09-02 21:22:35 +02:00
2017-09-02 21:38:03 +02:00
-------------------------------------------------------------------------------
2017-09-02 18:53:43 +02:00
## Requirements
To use fiche you have to have netcat installed. You probably already have it - try typing `nc` or `netcat` into your terminal!
-------------------------------------------------------------------------------
2017-09-02 21:38:03 +02:00
# Server-side usage
2017-09-02 18:53:43 +02:00
2017-09-02 21:38:03 +02:00
## Installation
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
1. Clone:
2013-09-06 04:01:55 +02:00
```
2017-09-02 18:53:43 +02:00
git clone https://github.com/solusipse/fiche.git
2013-09-06 04:01:55 +02:00
```
2017-09-02 18:53:43 +02:00
2. Build:
2013-09-06 04:01:55 +02:00
```
make
```
3. Install:
```
sudo make install
```
2018-12-20 14:15:52 +01:00
### Using Ports on FreeBSD
To install the port: `cd /usr/ports/net/fiche/ && make install clean` . To add the package: `pkg install fiche` .
_See [#86 ](https://github.com/solusipse/fiche/issues/86 ) for more info._
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-06 04:01:55 +02:00
2017-09-02 21:38:03 +02:00
## Usage
2013-09-06 04:01:55 +02:00
```
2016-03-15 14:13:08 +01:00
usage: fiche [-D6epbsdSolBuw].
2018-02-27 11:24:58 -05:00
[-d domain] [-L listen_addr ] [-p port] [-s slug size]
2013-09-14 01:00:23 +02:00
[-o output directory] [-B buffer size] [-u user name]
2017-09-17 15:13:17 +02:00
[-l log file] [-b banlist] [-w whitelist] [-S]
2013-09-06 04:01:55 +02:00
```
2017-09-02 21:22:35 +02:00
These are command line arguments. You don't have to provide any of them to run the application. Default settings will be used in such case. See section below for more info.
2013-09-14 01:00:23 +02:00
2017-09-02 21:22:35 +02:00
### Settings
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
#### Output directory `-o`
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
Relative or absolute path to the directory where you want to store user-posted pastes.
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
fiche -o ./code
2013-09-14 01:00:23 +02:00
```
```
2013-09-15 23:41:16 +02:00
fiche -o /home/www/code/
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
__Default value:__ `./code`
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
#### Domain `-d`
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
This will be used as a prefix for an output received by the client.
Value will be prepended with `http` .
2013-09-09 01:15:55 +02:00
```
fiche -d domain.com
```
```
2013-09-14 01:00:23 +02:00
fiche -d subdomain.domain.com
2013-09-09 01:15:55 +02:00
```
2017-09-18 02:27:24 +02:00
```
fiche -d subdomain.domain.com/some_directory
```
2017-09-02 18:53:43 +02:00
__Default value:__ `localhost`
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
#### Slug size `-s`
2017-09-17 15:13:17 +02:00
This will force slugs to be of required length:
2013-09-06 04:01:55 +02:00
2013-09-14 01:00:23 +02:00
```
fiche -s 6
```
2017-09-02 18:53:43 +02:00
__Output url with default value__: `http://localhost/xxxx` ,
where x is a randomized character
2018-03-05 21:47:03 -05:00
__Output url with example value 6__: `http://localhost/xxxxxx` ,
where x is a randomized character
2017-09-02 18:53:43 +02:00
__Default value:__ 4
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-17 15:13:17 +02:00
#### HTTPS `-S`
If set, fiche returns url with https prefix instead of http
```
fiche -S
```
__Output url with this parameter__: `https://localhost/xxxx` ,
where x is a randomized character
-------------------------------------------------------------------------------
2017-09-02 18:53:43 +02:00
#### User name `-u`
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
Fiche will try to switch to the requested user on startup if any is provided.
2013-09-14 01:00:23 +02:00
```
2015-09-04 16:40:29 +02:00
fiche -u _fiche
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
__Default value:__ not set
2015-09-04 16:40:29 +02:00
2017-09-02 18:53:43 +02:00
__WARNING:__ This requires that fiche is started as a root.
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
#### Buffer size `-B`
This parameter defines size of the buffer used for getting data from the user.
Maximum size (in bytes) of all input files is defined by this value.
2013-09-14 01:00:23 +02:00
```
fiche -B 2048
```
2017-09-02 18:53:43 +02:00
__Default value:__ 32768
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
#### Log file `-l`
2013-09-14 01:00:23 +02:00
```
fiche -l /home/www/fiche-log.txt
```
2017-09-02 18:53:43 +02:00
__Default value:__ not set
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
__WARNING:__ this file has to be user-writable
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
#### Ban list `-b`
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
Relative or absolute path to a file containing IP addresses of banned users.
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
fiche -b fiche-bans.txt
2013-09-14 01:00:23 +02:00
```
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
__Format of the file:__ this file should contain only addresses, one per line.
2015-09-04 14:26:59 +02:00
2017-09-02 18:53:43 +02:00
__Default value:__ not set
2015-09-04 14:26:59 +02:00
2017-09-02 18:53:43 +02:00
__WARNING:__ not implemented yet
2015-09-04 14:26:59 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2015-09-04 14:26:59 +02:00
2017-09-02 18:53:43 +02:00
#### White list `-w`
2015-09-04 14:26:59 +02:00
2017-09-02 18:53:43 +02:00
If whitelist mode is enabled, only addresses from the list will be able
to upload files.
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
fiche -w fiche-whitelist.txt
2013-09-14 01:00:23 +02:00
```
2017-09-02 18:53:43 +02:00
__Format of the file:__ this file should contain only addresses, one per line.
2013-09-14 01:00:23 +02:00
2017-09-02 18:53:43 +02:00
__Default value:__ not set
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
__WARNING:__ not implemented yet
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-06 04:01:55 +02:00
2017-09-02 18:53:43 +02:00
### Running as a service
2013-09-06 14:44:38 +02:00
2017-09-02 18:53:43 +02:00
There's a simple systemd example:
2013-09-06 14:44:38 +02:00
```
[Unit]
Description=FICHE-SERVER
[Service]
2017-09-02 18:53:43 +02:00
ExecStart=/usr/local/bin/fiche -d yourdomain.com -o /path/to/output -l /path/to/log -u youruser
2013-09-06 14:44:38 +02:00
[Install]
WantedBy=multi-user.target
```
2017-09-02 21:22:35 +02:00
__WARNING:__ In service mode you have to set output directory with `-o` parameter.
2013-09-09 01:15:55 +02:00
2017-09-02 18:53:43 +02:00
-------------------------------------------------------------------------------
2013-09-09 01:15:55 +02:00
2017-09-02 21:22:35 +02:00
### Example nginx config
2013-09-06 04:20:35 +02:00
2017-09-02 18:53:43 +02:00
Fiche has no http server built-in, thus you need to setup one if you want to make files available through http.
2013-09-06 04:20:35 +02:00
2017-09-02 18:53:43 +02:00
There's a sample configuration for nginx:
2013-09-06 04:20:35 +02:00
```
server {
listen 80;
server_name mysite.com www.mysite.com;
2013-09-14 01:00:23 +02:00
charset utf-8;
2013-09-06 04:20:35 +02:00
location / {
root /home/www/code/;
2013-09-14 01:00:23 +02:00
index index.txt index.html;
2013-09-06 04:20:35 +02:00
}
}
```
2017-09-02 21:22:35 +02:00
## License
2013-09-06 04:01:55 +02:00
Fiche is MIT licensed.