summaryrefslogtreecommitdiff
path: root/publish
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2009-11-29 15:44:56 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2009-11-29 15:44:56 +0000
commit7aaf156cc9ed999466461e6b12c0f3aedfa850ff (patch)
treece42553d13ebd25a082db3996f889bb1ba1574a9 /publish
parent54bcf863f53b5404323b4618ae2730c474373da3 (diff)
History support from flo
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@424 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'publish')
-rwxr-xr-xpublish39
1 files changed, 35 insertions, 4 deletions
diff --git a/publish b/publish
index bb34c4a..08a7e0f 100755
--- a/publish
+++ b/publish
@@ -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