diff --git a/.bin/cam b/.bin/cam index 2fb8049..5fb04d2 100755 --- a/.bin/cam +++ b/.bin/cam @@ -9,20 +9,21 @@ for arg in $@ do # set values based of arguments found case $arg in - s|start) shift; _start=1 ;; - k|kill|stop) shift; _stop=1 ;; - l|list) shift; _list=1 ;; - 30) shift; _fps="-framerate 30" ;; - 60) shift; _fps="-framerate 60" ;; - raw) shift; _format="-input_format yuyv422" ;; - fullhd) shift; _res="-video_size 1920x1080" ;; - hd) shift; _res="-video_size 1280x720" ;; - sd) shift; _res="-video_size 640x360" ;; - max) shift; _res="max" ;; - [0-9]*x[0-9]*) shift; _res="-video_size $arg" ;; - [0-9]) shift; _dev="$arg" ;; - *) shift; _unknown="$_unknown $arg" ;; + s|start) _start=1 ;; + k|kill|stop) _stop=1 ;; + l|list) _list=1 ;; + 30) _fps="-framerate 30" ;; + 60) _fps="-framerate 60" ;; + raw) _format="-input_format yuyv422" ;; + fullhd) _res="-video_size 1920x1080" ;; + hd) _res="-video_size 1280x720" ;; + sd) _res="-video_size 640x360" ;; + max) _res="max" ;; + [0-9]*x[0-9]*) _res="-video_size $arg" ;; + [0-9]) _dev="$arg" ;; + *) _unknown="$_unknown $arg" ;; esac + shift; done if [ ! -z "$_unknown" ] diff --git a/.bin/osmc b/.bin/osmc index 427ca18..6628425 100755 --- a/.bin/osmc +++ b/.bin/osmc @@ -1,6 +1,6 @@ #!/bin/sh -case $1 in +case "$1" in put|push) shift; rsync -rv --progress --append-verify $@ osmc:/media/USBDisk/ ;; df) shift; ssh osmc "df -h /media/USBDisk/" ;; ls) shift; ssh osmc "cd /media/USBDisk/ && ls $@ | grep -v lost+found" ;; diff --git a/.bin/upload b/.bin/upload index 2645125..7eddd18 100755 --- a/.bin/upload +++ b/.bin/upload @@ -1,21 +1,57 @@ #!/bin/sh -e -if [ x"$1" == x"rm" ] +for arg in "$@" +do + case "$arg" in + sh) _ext=".sh" ;; + ksh) _ext=".ksh" ;; + txt) _ext=".txt" ;; + log) _ext=".log" ;; + rm) _rm=1 ;; + ls) _ls=1 ;; + mv) _mv=1 ;; + *) break; ;; + esac + shift; +done + +if [ ! -z "$_rm" ] then - shift - for file in $@ + for file in "$@" do - ssh sdk@codevoid.de "cd /home/www/htdocs/ptrace/paste/ && rm -v $(basename "$file")" || true + ssh sdk@codevoid.de \ + "cd /home/www/htdocs/ptrace/paste/ \ + && rm -v $(basename "$file")" \ + || true done -elif [ x"$1" == x"ls" ] + exit 0 +fi + +if [ ! -z "$_ls" ] then - shift - ssh sdk@codevoid.de "cd /home/www/htdocs/ptrace/paste/ && ls -1 | xargs -n1 -I{} echo https://ptrace.org/{}" -else - for file in $@ + ssh sdk@codevoid.de \ + "cd /home/www/htdocs/ptrace/paste/ \ + && ls -1tr \ + | xargs -n1 -I{} echo \"https://ptrace.org/{} ({})\"" + exit 0 +fi + +if [ ! -z "$_mv" ] +then + ssh sdk@codevoid.de \ + "cd /home/www/htdocs/ptrace/paste/ \ + && mv -v \"$1\" \"$2\"" + exit 0 +fi + +if [ ! -z "$@" ] +then + for file in "$@" do - chmod o+rw,g+r "$file" - scp "$file" sdk@codevoid.de:/home/www/htdocs/ptrace/paste/ + # make sure the file is least owner rw and group r + # the sticky bit in the destiation folder will assign user+group + chmod u+rw,g+r "$file" + scp "$file" "sdk@codevoid.de:/home/www/htdocs/ptrace/paste/${file}${_ext}" echo "https://ptrace.org/$(basename "$file")" \ | sed 's/ /%20/g' \ | xclip -f -r