vodkas

Simple file sharing server
Log | Files | Refs

commit ca6146845665b489358319cff10862dba536b063
parent 41781b202c43f285c8d199f63d8371f2e3f25632
Author: Vetle Haflan <vetle@haflan.dev>
Date:   Tue,  3 Mar 2020 22:20:11 +0100

Start making vv.sh (simple bash client)

Diffstat:
Mvodkas.go | 1+
Avv.sh | 36++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/vodkas.go b/vodkas.go @@ -26,6 +26,7 @@ const FormNameText = "text" const FormNameNumShots = "numdls" var KeyTakenMessage = []byte("The requested key is taken. Try another.\n") +// TODO: Might want to update this with info about vv.sh instead? var InfoMessage = []byte(`Usage: - POUR: curl vetle.vodka[/<requested-shot-key>] -d <data> - SHOT: curl vetle.vodka/<shot-key> diff --git a/vv.sh b/vv.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +HOST=100.115.92.201:8080 +CMD="$1" + +function help () { + echo "$0 commands:" + echo " s: share a file" + echo " vv s <filename> [shotKey]" + echo " f: fetch a file" + echo " vv f <shotKey>" +} + +function argrequired () { + if [ -z $2 ]; then + echo "Argument '$1' is missing" + exit 1 + fi +} + +if [ "$CMD" == "s" ]; then + argrequired filename $2 + shotKey=$3 + curl -F file=@$2 $HOST/$shotKey +elif [ "$CMD" == "f" ]; then + argrequired shotKey $2 + curl $HOST/$2 +elif [ "$CMD" == "l" ]; then +# Link, pretty much a simple URL shortener + argrequired shotKey $2 + argrequired link $3 + contents="<html><meta http-equiv='refresh' content='0; url=$3'></html>" + curl --form-string text="$contents" $HOST/$2 +else + help +fi