added more to readme
This commit is contained in:
parent
f2c076cb88
commit
e38a69d010
46
README.md
46
README.md
|
@ -2,11 +2,45 @@
|
|||
|
||||
`tildebin` creates customizable [pastebin](https://pastebin.com/) pages from plain text commands received via a unix sockets. It sets up a socket within your filesystem to which users can connect to with tools like `nc` and send their requests. Requests are then applied to a template and saved to disk.
|
||||
|
||||
## Example
|
||||
```bash
|
||||
# Session 1 starts the server...
|
||||
./tildebin
|
||||
## Usage
|
||||
```
|
||||
Usage: tildebin [OPTIONS]
|
||||
Takes user's copy/paste requests from a socket and
|
||||
saves them onto disk based on a user defined template
|
||||
|
||||
# Session 2 sends a request...
|
||||
echo "My Request!"
|
||||
None of the options below are mandatory
|
||||
-s socket path sets socket path
|
||||
-t template path sets template path
|
||||
-o output dir sets output directory
|
||||
-n output filename sets user's output filename
|
||||
-c enables html curation (set to true if no template is provided)
|
||||
-h prints this message
|
||||
|
||||
Default socket path is set to /tmp/tildebin.socket and default output
|
||||
file name is set to index.html. The user requests will be saved under /tmp/tildebin/.
|
||||
```
|
||||
In order to start the server, just run `tildebin`. While no arguments are strictly needed, it's recommended that you at least set the output directory and socket path. Using a template file and enabling html curation is also encouraged.
|
||||
|
||||
```bash
|
||||
./tildebin -o [output dir] -s [socket path] -tc [template file]
|
||||
```
|
||||
All of the processed user requests will be stored under `[output dir]/[username]`. `tildebin` is also signal-aware, so you can safely terminate it using Ctrl-C or `kill`.
|
||||
|
||||
|
||||
In order to manually send a request to the server, you can use `nc`.
|
||||
```bash
|
||||
# Assuming tildebin.sock is in /tmp...
|
||||
echo "my tildebin!" | nc -U /tmp/tildebin.sock
|
||||
|
||||
# You can also set a title for your tildebin. This will save your tildebin under [your username]/my first title
|
||||
echo ".name.my first title.ename..EOH.my tildebin with a title!" | nc -U /tmp/tildebin.sock
|
||||
```
|
||||
|
||||
If you'd like to use the integrated script, [tb.sh](./tb.sh), just set the environment variable `TILDEBIN_SOCK` in your shell
|
||||
```bash
|
||||
# Assuming tildebin.sock is in ~/...
|
||||
echo "my tildebin" | TILDEBIN_SOCK="~/tildebin.sock" tb.sh
|
||||
|
||||
# You can also set a title for your tildebin. This will save your tildebin under [your username]/my first title
|
||||
echo "my tildebin" | TILDEBIN_SOCK="~/tildebin.sock" tb.sh "my first title"
|
||||
```
|
7
tb.sh
7
tb.sh
|
@ -1,6 +1,11 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
SOCKET_PATH="/tmp/tildebin.sock"
|
||||
SOCKET_PATH=""
|
||||
if [ -z "$TILDEBIN_SOCK" ]; then
|
||||
SOCKET_PATH="/tmp/tildebin.sock"
|
||||
else
|
||||
SOCKET_PATH="$TILDEBIN_SOCK"
|
||||
fi
|
||||
|
||||
if [ -p /dev/stdin ]; then
|
||||
while IFS= read line; do
|
||||
|
|
|
@ -350,11 +350,11 @@ help( void )
|
|||
" -t template path \tsets template path\n"
|
||||
" -o output dir \tsets output directory\n"
|
||||
" -n output filename \tsets user's output filename\n"
|
||||
" -c \tenables html curation\n"
|
||||
" -c \tenables html curation (set to true if no template is provided)\n"
|
||||
" -h \tprints this message\n\n"
|
||||
|
||||
"Default socket path is set to /tmp/tildebin.socket and default output\n"
|
||||
"file name is set to index.html.\n"
|
||||
"file name is set to index.html. The user requests will be saved under /tmp/tildebin/.\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ main( int argc, char const **argv )
|
|||
// Setup global vars and defaults
|
||||
backlog = MAX_CLIENTS;
|
||||
output_dir = DEFAULT_OUTPUT_PATH;
|
||||
socket_path = DEFAULT_SOCKET_PATH;
|
||||
socket_path = DEFAULT_SOCKET_PATH;
|
||||
output_file_name = DEFAULT_OUTPUTFILE;
|
||||
output_fd = NULL;
|
||||
template_path = NULL;
|
||||
|
@ -458,6 +458,8 @@ main( int argc, char const **argv )
|
|||
|
||||
INFO("loaded template from file \"%s\"", template_path);
|
||||
}
|
||||
else
|
||||
curate_html = true;
|
||||
|
||||
// Create output directory if it doesn't exists
|
||||
create_directory(output_dir);
|
||||
|
|
Loading…
Reference in New Issue