diff options
Diffstat (limited to 'publish')
-rwxr-xr-x | publish | 39 |
1 files changed, 35 insertions, 4 deletions
@@ -30,6 +30,9 @@ base_http=http://www.example.com/pub base_rsync=marvin.example.com:/var/www/www.example.com/htdocs/pub +history_file=false +history_lines=1000 + [ -e ~/.publish.cfg ] && . ~/.publish.cfg usage() @@ -50,12 +53,25 @@ uri_encode() { } get_random() { - head -c 8 /dev/urandom | base64 | tr '/+' '-_' | tr -d '=' + head -c 8 /dev/urandom | base64 | tr '/+' 'xx' | tr -d '=' +} + +history_append() { + time=$(date --utc --rfc-3339='seconds') + echo $time $1 >>"$history_file" + + history_tmp=$( tempfile ) + cat "$history_file" | tail --lines="$history_lines" >"$history_tmp" + mv "$history_tmp" "$history_file" +} + +history_show() { + cat "$history_file" } NODO="" -while getopts "hn" OPTION +while getopts "hns" OPTION do case $OPTION in h) @@ -65,6 +81,15 @@ do n) NODO="echo" ;; + s) + if [ -r "$history_file" ]; then + history_show + exit 0 + else + echo "history file: '$history_file' not found" + exit 3 + fi + ;; *) usage >&2 exit 1 @@ -92,6 +117,14 @@ else echo "$base_http/$d_server_http_base/" fi +for file in "$@"; do + uri="$base_http/$d_server_http_base/$( echo -n "$file" | uri_encode )" + echo "$uri" + if [ -w "$history_file" ]; then + history_append "$uri" + fi +done + while [ "$#" -gt 0 ]; do file="$1" shift @@ -103,6 +136,4 @@ while [ "$#" -gt 0 ]; do fi $NODO rsync $rsync_args "$file$trail" $base_rsync"/$d_server/" - - echo "$base_http/$d_server_http_base/$( echo -n "$file" | uri_encode )" done |