README.md - fiche - A pastebin adjusted for gopher use
 (HTM) git clone git://vernunftzentrum.de/fiche.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       README.md (6935B)
       ---
            1 fiche [![Build Status](https://travis-ci.org/solusipse/fiche.svg?branch=master)](https://travis-ci.org/solusipse/fiche)
            2 =====
            3 
            4 Command line pastebin for sharing terminal output.
            5 
            6 # Client-side usage
            7 
            8 Self-explanatory live examples (using public server):
            9 
           10 ```
           11 echo just testing! | nc termbin.com 9999
           12 ```
           13 
           14 ```
           15 cat file.txt | nc termbin.com 9999
           16 ```
           17 
           18 In case you installed and started fiche on localhost:
           19 
           20 ```
           21 ls -la | nc localhost 9999
           22 ```
           23 
           24 You will get an url to your paste as a response, e.g.:
           25 
           26 ```
           27 http://termbin.com/ydxh
           28 ```
           29 
           30 You can use our beautification service to get any paste colored and numbered. Just ask for it using `l.termbin.com` subdomain, e.g.:
           31 
           32 ```
           33 http://l.termbin.com/ydxh
           34 ```
           35 
           36 -------------------------------------------------------------------------------
           37 
           38 ## Useful aliases
           39 
           40 You can make your life easier by adding a termbin alias to your rc file. We list some of them here:
           41 
           42 -------------------------------------------------------------------------------
           43 
           44 ### Pure-bash alternative to netcat
           45 
           46 __Linux/macOS:__
           47 ```
           48 alias tb="(exec 3<>/dev/tcp/termbin.com/9999; cat >&3; cat <&3; exec 3<&-)"
           49 ```
           50 
           51 ```
           52 echo less typing now! | tb
           53 ```
           54 
           55 _See [#42](https://github.com/solusipse/fiche/issues/42), [#43](https://github.com/solusipse/fiche/issues/43) for more info._
           56 
           57 -------------------------------------------------------------------------------
           58 
           59 ### `tb` alias
           60 
           61 __Linux (Bash):__
           62 ```
           63 echo 'alias tb="nc termbin.com 9999"' >> .bashrc
           64 ```
           65 
           66 ```
           67 echo less typing now! | tb
           68 ```
           69 
           70 __macOS:__
           71 
           72 ```
           73 echo 'alias tb="nc termbin.com 9999"' >> .bash_profile
           74 ```
           75 
           76 ```
           77 echo less typing now! | tb
           78 ```
           79 
           80 -------------------------------------------------------------------------------
           81 
           82 ### Copy output to clipboard
           83 
           84 __Linux (Bash):__
           85 ```
           86 echo 'alias tbc="netcat termbin.com 9999 | xclip -selection c"' >> .bashrc
           87 ```
           88 
           89 ```
           90 echo less typing now! | tbc
           91 ```
           92 
           93 __macOS:__
           94 
           95 ```
           96 echo 'alias tbc="nc termbin.com 9999 | pbcopy"' >> .bash_profile
           97 ```
           98 
           99 ```
          100 echo less typing now! | tbc
          101 ```
          102 
          103 __Remember__ to reload the shell with `source ~/.bashrc` or `source ~/.bash_profile` after adding any of provided above!
          104 
          105 -------------------------------------------------------------------------------
          106 
          107 ## Requirements
          108 To use fiche you have to have netcat installed. You probably already have it - try typing `nc` or `netcat` into your terminal!
          109 
          110 -------------------------------------------------------------------------------
          111 
          112 # Server-side usage
          113 
          114 ## Installation
          115 
          116 1. Clone:
          117 
          118     ```
          119     git clone https://github.com/solusipse/fiche.git
          120     ```
          121 
          122 2. Build:
          123 
          124     ```
          125     make
          126     ```
          127     
          128 3. Install:
          129 
          130     ```
          131     sudo make install
          132     ```
          133 
          134 -------------------------------------------------------------------------------
          135 
          136 ## Usage
          137 
          138 ```
          139 usage: fiche [-D6epbsdSolBuw].
          140              [-d domain] [-p port] [-s slug size]
          141              [-o output directory] [-B buffer size] [-u user name]
          142              [-l log file] [-b banlist] [-w whitelist] [-S]
          143 ```
          144 
          145 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.
          146 
          147 ### Settings
          148 
          149 -------------------------------------------------------------------------------
          150 
          151 #### Output directory `-o`
          152 
          153 Relative or absolute path to the directory where you want to store user-posted pastes.
          154 
          155 ```
          156 fiche -o ./code
          157 ```
          158 
          159 ```
          160 fiche -o /home/www/code/
          161 ```
          162 
          163 __Default value:__ `./code`
          164 
          165 -------------------------------------------------------------------------------
          166 
          167 #### Domain `-d`
          168 
          169 This will be used as a prefix for an output received by the client.
          170 Value will be prepended with the domain prefix (see -P) if set or `http` otherwise.
          171 
          172 ```
          173 fiche -d domain.com
          174 ```
          175 
          176 ```
          177 fiche -d subdomain.domain.com
          178 ```
          179 
          180 ```
          181 fiche -d subdomain.domain.com/some_directory
          182 ```
          183 
          184 __Default value:__ `localhost`
          185 
          186 -------------------------------------------------------------------------------
          187 
          188 #### Slug size `-s`
          189 
          190 This will force slugs to be of required length:
          191 
          192 ```
          193 fiche -s 6
          194 ```
          195 
          196 __Output url with default value__: `http://localhost/xxxx`,
          197 where x is a randomized character
          198 
          199 __Output url with example value 6__: `http://localhost/xxxx`,
          200 where is a randomized character
          201 
          202 __Default value:__ 4
          203 
          204 -------------------------------------------------------------------------------
          205 
          206 #### protocol prefix `-P`
          207 
          208 If set, fiche returns url with protocol prefix 'prefix' instead of http
          209 
          210 ```
          211 fiche -P https
          212 ```
          213 
          214 __Output url with this parameter__: `https://localhost/xxxx`,
          215 where x is a randomized character
          216 
          217 -------------------------------------------------------------------------------
          218 
          219 #### User name `-u`
          220 
          221 Fiche will try to switch to the requested user on startup if any is provided.
          222 
          223 ```
          224 fiche -u _fiche
          225 ```
          226 
          227 __Default value:__ not set
          228 
          229 __WARNING:__ This requires that fiche is started as a root.
          230 
          231 -------------------------------------------------------------------------------
          232 
          233 #### Buffer size `-B`
          234 
          235 This parameter defines size of the buffer used for getting data from the user.
          236 Maximum size (in bytes) of all input files is defined by this value.
          237 
          238 ```
          239 fiche -B 2048
          240 ```
          241 
          242 __Default value:__ 32768
          243 
          244 -------------------------------------------------------------------------------
          245 
          246 #### Log file `-l`
          247 
          248 ```
          249 fiche -l /home/www/fiche-log.txt
          250 ```
          251 
          252 __Default value:__ not set
          253 
          254 __WARNING:__ this file has to be user-writable
          255 
          256 -------------------------------------------------------------------------------
          257 
          258 #### Ban list `-b`
          259 
          260 Relative or absolute path to a file containing IP addresses of banned users.
          261 
          262 ```
          263 fiche -b fiche-bans.txt
          264 ```
          265 
          266 __Format of the file:__ this file should contain only addresses, one per line.
          267 
          268 __Default value:__ not set
          269 
          270 __WARNING:__ not implemented yet
          271 
          272 -------------------------------------------------------------------------------
          273 
          274 #### White list `-w`
          275 
          276 If whitelist mode is enabled, only addresses from the list will be able
          277 to upload files.
          278 
          279 ```
          280 fiche -w fiche-whitelist.txt
          281 ```
          282 
          283 __Format of the file:__ this file should contain only addresses, one per line.
          284 
          285 __Default value:__ not set
          286 
          287 __WARNING:__ not implemented yet
          288 
          289 -------------------------------------------------------------------------------
          290 
          291 ### Running as a service
          292 
          293 There's a simple systemd example:
          294 ```
          295 [Unit]
          296 Description=FICHE-SERVER
          297 
          298 [Service]
          299 ExecStart=/usr/local/bin/fiche -d yourdomain.com -o /path/to/output -l /path/to/log -u youruser
          300 
          301 [Install]
          302 WantedBy=multi-user.target
          303 ```
          304 
          305 __WARNING:__ In service mode you have to set output directory with `-o` parameter.
          306 
          307 -------------------------------------------------------------------------------
          308 
          309 ### Example nginx config
          310 
          311 Fiche has no http server built-in, thus you need to setup one if you want to make files available through http.
          312 
          313 There's a sample configuration for nginx:
          314 
          315 ```
          316 server {
          317     listen 80;
          318     server_name mysite.com www.mysite.com;
          319     charset utf-8;
          320 
          321     location / {
          322             root /home/www/code/;
          323             index index.txt index.html;
          324     }
          325 }
          326 ```
          327 
          328 ## License
          329 
          330 Fiche is MIT licensed.