From a335f0bad53136bded77d1e070c10080b843c2be Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 31 Mar 2014 07:54:43 +0000 Subject: Implement re-publish git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@668 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- publish | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/publish b/publish index 3186df6..9f8c4e7 100755 --- a/publish +++ b/publish @@ -1,7 +1,7 @@ #!/bin/bash # Copyright (c) 2009 Florian Reitmeir -# Copyright (c) 2009,2011,2012 Peter Palfrader +# Copyright (c) 2009,2011,2012,2013,2014 Peter Palfrader # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -81,6 +81,7 @@ OPTIONS: -r Add --relative option to rsync so that path names of the given files are preserved at the remote host. -t days time to live in days + -R re-publish (re-use last directory token) -T tag directory name on the server (use this to re-publish under that name) -x Publish the contents of the xclipboard. -u Unpublish directory (only useful together with -T) @@ -97,7 +98,7 @@ get_random() { history_append() { time=$(date --utc --rfc-3339='seconds') - echo $time $1 >>"$history_file" + echo $time $1 $2 >>"$history_file" history_tmp=$( tempfile ) cat "$history_file" | tail --lines="$history_lines" >"$history_tmp" @@ -108,6 +109,10 @@ history_show() { cat "$history_file" } +history_get_last_token() { + tail -n1 "$history_file" | awk '{print $3}' +} + setup_tmpdir() { if [ -z "$tmpdir" ]; then tmpdir=`mktemp -d` @@ -124,8 +129,9 @@ add_default_cs=0 relative="" d_server="" unpublish=0 +d_server_http_base="" -while getopts "rhnq8HSxs:t:T:u" OPTION +while getopts "rRhnq8HSxs:t:T:u" OPTION do case $OPTION in h) @@ -162,6 +168,9 @@ do r) relative="--relative" ;; + R) + d_server_http_base=$(history_get_last_token) + ;; t) ttl="$OPTARG" ;; @@ -240,7 +249,7 @@ d_date=$(date +"$date_format") d_random=$(get_random) d_server="${d_server:-$d_date$d_random}" -d_server_http_base=$( echo -n "$d_server" | uri_encode ) +d_server_http_base="${d_server_http_base:-$( echo -n "$d_server" | uri_encode )}" base_uri="$base_http/$d_server_http_base/" main_uri="$base_uri" @@ -309,7 +318,7 @@ while [ "$#" -gt 0 ]; do uri="$base_uri""$( echo -n $file | uri_encode )" fi echo "$uri" - history_append "$uri" + history_append "$d_server_http_base" "$uri" fi rsync_pre_invoke -- cgit v1.2.3