diff --git a/scripts/share b/scripts/share index c05444b..1da2e87 100755 --- a/scripts/share +++ b/scripts/share @@ -1,42 +1,11 @@ #!/bin/sh -TEMP_DIR="$HOME/Public/share" -PORT=8000 +NULL_PTR="https://0x0.st" -help() { - printf "\033[2mUsage:\033[0m share [DIRECTORY/FILE]\n" - exit 0 -} +LOC="$1" +FILE="$LOC" +[ -d "$FILE" ] && + FILE="${FILE%%/}.zip" && + zip -r "$FILE" "$LOC" -error() { - printf "\033[31mError:\033[0m %s\n" "$1" - exit 1 -} - -# If no location is given, print help and exit -LOC="$1" ; [ -n "$LOC" ] || help - -# Look for ifconfig -[ -e "/sbin/ifconfig" ] && CMD="/sbin/ifconfig" -[ -e "$(which ifconfig)" ] && CMD="ifconfig" -[ -n "$CMD" ] || error "ifconfig not found" - -# Use ifconfig to get ip address -ADDR="$($CMD | grep 'broadcast' | sed 's/\s*inet\s*//g;s/\s*netmask.*//g')" - -# If location is directory, define DIR as location, -# otherwise, define DIR as TEMP_DIR -[ -d "$LOC" ] && DIR="$LOC" || DIR="$TEMP_DIR" - -# If file is inside TEMP_DIR, print error -[ "$DIR" = "$TEMP_DIR" ] && - readlink -f "$LOC" | grep -q "$TEMP_DIR" && - error "File can't be inside $TEMP_DIR directory" - -# If using TEMP_DIR, create dir and move -# files inside dir -[ "$DIR" = "$TEMP_DIR" ] && - rm -rf "$DIR" && - mkdir -p "$TEMP_DIR" && - cp -f "$LOC" "$DIR/" - -python -m http.server -b "$ADDR" "$PORT" -d "$DIR" +curl -F"file=@$FILE" "$NULL_PTR" +[ -d "$FILE" ] && rm -rf "$FILE" diff --git a/scripts/share-local b/scripts/share-local new file mode 100755 index 0000000..c05444b --- /dev/null +++ b/scripts/share-local @@ -0,0 +1,42 @@ +#!/bin/sh +TEMP_DIR="$HOME/Public/share" +PORT=8000 + +help() { + printf "\033[2mUsage:\033[0m share [DIRECTORY/FILE]\n" + exit 0 +} + +error() { + printf "\033[31mError:\033[0m %s\n" "$1" + exit 1 +} + +# If no location is given, print help and exit +LOC="$1" ; [ -n "$LOC" ] || help + +# Look for ifconfig +[ -e "/sbin/ifconfig" ] && CMD="/sbin/ifconfig" +[ -e "$(which ifconfig)" ] && CMD="ifconfig" +[ -n "$CMD" ] || error "ifconfig not found" + +# Use ifconfig to get ip address +ADDR="$($CMD | grep 'broadcast' | sed 's/\s*inet\s*//g;s/\s*netmask.*//g')" + +# If location is directory, define DIR as location, +# otherwise, define DIR as TEMP_DIR +[ -d "$LOC" ] && DIR="$LOC" || DIR="$TEMP_DIR" + +# If file is inside TEMP_DIR, print error +[ "$DIR" = "$TEMP_DIR" ] && + readlink -f "$LOC" | grep -q "$TEMP_DIR" && + error "File can't be inside $TEMP_DIR directory" + +# If using TEMP_DIR, create dir and move +# files inside dir +[ "$DIR" = "$TEMP_DIR" ] && + rm -rf "$DIR" && + mkdir -p "$TEMP_DIR" && + cp -f "$LOC" "$DIR/" + +python -m http.server -b "$ADDR" "$PORT" -d "$DIR" diff --git a/scripts/sshare b/scripts/sshare new file mode 100755 index 0000000..3cb1c88 --- /dev/null +++ b/scripts/sshare @@ -0,0 +1,10 @@ +#!/bin/sh +NULL_PTR="https://0x0.st" + +LOC="$1" +FILE="${LOC%%/}.zip" +zip -r "$FILE" "$LOC" +zipcloak "$FILE" + +curl -F"file=@$FILE" "$NULL_PTR" +rm -rf "$FILE"