[isidorus-cvs] r646 - in trunk/src: rest_interface shell_scripts
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Tue Jul 19 12:52:36 UTC 2011
Author: lgiessmann
Date: Tue Jul 19 05:52:35 2011
New Revision: 646
Log:
trunk: added a handler that sends the backup xtm data via http to the requestor; added a corresponding bash script
Added:
trunk/src/shell_scripts/local-backup-isidorus.sh
- copied, changed from r638, trunk/src/shell_scripts/backup-isidorus.sh
trunk/src/shell_scripts/remote-backup-isidorus.sh (contents, props changed)
Deleted:
trunk/src/shell_scripts/backup-isidorus.sh
Modified:
trunk/src/rest_interface/admin-interface.lisp
trunk/src/rest_interface/rest-interface.lisp
Modified: trunk/src/rest_interface/admin-interface.lisp
==============================================================================
--- trunk/src/rest_interface/admin-interface.lisp Tue Jul 19 02:00:42 2011 (r645)
+++ trunk/src/rest_interface/admin-interface.lisp Tue Jul 19 05:52:35 2011 (r646)
@@ -11,15 +11,17 @@
;;TODO: add functions to export statement
-;the prefix to get a fragment by the psi -> localhost:8000/json/get/<fragment-psi>
-(defparameter *admin-backup* "/admin/backup")
-;the prefix to get a fragment by the psi -> localhost:8000/json/rdf/get/<fragment-psi>
+(defparameter *admin-local-backup* "/admin/local-backup")
+(defparameter *admin-remote-backup* "/admin/remote-backup")
(defparameter *admin-shutdown* "/admin/shutdown")
(defun set-up-admin-interface ()
(push
- (create-regex-dispatcher *admin-backup* #'admin-backup)
+ (create-regex-dispatcher *admin-local-backup* #'admin-local-backup)
+ hunchentoot:*dispatch-table*)
+ (push
+ (create-regex-dispatcher *admin-remote-backup* #'admin-remote-backup)
hunchentoot:*dispatch-table*)
(push
(create-regex-dispatcher *admin-shutdown* #'admin-shutdown)
@@ -51,14 +53,26 @@
-(defun admin-backup()
+(defun admin-local-backup()
(handler-case
(if (string= "127.0.0.1" (hunchentoot:remote-addr*))
(let ((destination-path
(hunchentoot:url-decode (hunchentoot:get-parameter "path"))))
- (xtm-exporter:export-as-xtm destination-path
- :tm-id "http://isidor.us/backup-tm"
- :revision 0))
+ (xtm-exporter:export-as-xtm destination-path :revision 0))
+ (setf (hunchentoot:return-code*) hunchentoot:+http-forbidden+))
+ (condition (err)
+ (progn
+ (setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+)
+ (setf (hunchentoot:content-type*) "text")
+ (format nil "Condition: \"~a\"" err)))))
+
+
+(defun admin-remote-backup()
+ (handler-case
+ (if (string= "127.0.0.1" (hunchentoot:remote-addr*))
+ (progn (hunchentoot:url-decode (hunchentoot:get-parameter "path"))
+ (setf (hunchentoot:content-type*) "application/xml")
+ (xtm-exporter:export-as-xtm-string :revision 0))
(setf (hunchentoot:return-code*) hunchentoot:+http-forbidden+))
(condition (err)
(progn
Modified: trunk/src/rest_interface/rest-interface.lisp
==============================================================================
--- trunk/src/rest_interface/rest-interface.lisp Tue Jul 19 02:00:42 2011 (r645)
+++ trunk/src/rest_interface/rest-interface.lisp Tue Jul 19 05:52:35 2011 (r646)
@@ -33,6 +33,9 @@
:start-admin-server
:shutdown-json-engine
:shutdown-atom-engine
+ :*admin-local-backup*
+ :*admin-remote-backup*
+ :*admin-shutdown*
:shutdown-admin-server
:*admin-host-name*
:*admin-port*
Copied and modified: trunk/src/shell_scripts/local-backup-isidorus.sh (from r638, trunk/src/shell_scripts/backup-isidorus.sh)
==============================================================================
--- trunk/src/shell_scripts/backup-isidorus.sh Mon Jul 18 05:08:51 2011 (r638, copy source)
+++ trunk/src/shell_scripts/local-backup-isidorus.sh Tue Jul 19 05:52:35 2011 (r646)
@@ -18,9 +18,9 @@
## value is a date string of the form dd.mm.yyyy:hh:mm:ss.xtm" and can be
## changed by using the switch -path <any-string>.
## A sample call would be
-## ./backup-isidorus.sh -host 12.34.56.78 -url /admin/shutdown -path=backup.xtm
+## ./local-backup-isidorus.sh -host 12.34.56.78 -url /admin/shutdown -path=backup.xtm
-url="/admin/backup";
+url="/admin/local-backup";
host="127.0.0.1:11008";
path=`date +"%d.%m.%y:%H:%M:%S"`".xtm"
Added: trunk/src/shell_scripts/remote-backup-isidorus.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/src/shell_scripts/remote-backup-isidorus.sh Tue Jul 19 05:52:35 2011 (r646)
@@ -0,0 +1,105 @@
+#!/bin/bash
+##+-----------------------------------------------------------------------------
+##+ Isidorus
+##+ (c) 2008-2010 Marc Kuester, Christoph Ludwig, Lukas Georgieff
+##+
+##+ Isidorus is freely distributable under the LLGPL license.
+##+ You can find a detailed description in trunk/docs/LLGPL-LICENSE.txt and
+##+ trunk/docs/LGPL-LICENSE.txt.
+##+-----------------------------------------------------------------------------
+
+
+## This script can be used to invoke hunchentoot's admin interface and backup
+## the server date. The default ip address is set to 127.0.0.1 and can be changed via
+## the switch -host <ip-address>. The default url that determines the server's
+## callback binding is set to /admin/backup, but this behavior can also be
+## changed by using the switch -url <url-fragment>. The path variable
+## contains the name of the stored xtm backup file that is created, the default
+## value is a date string of the form dd.mm.yyyy:hh:mm:ss.xtm" and can be
+## changed by using the switch -path <any-string>.
+## A sample call would be
+## ./remote-backup-isidorus.sh -host 12.34.56.78 -url /admin/shutdown -path=backup.xtm
+
+url="/admin/remote-backup";
+host="127.0.0.1:11008";
+path=`date +"%d.%m.%y:%H:%M:%S"`".xtm"
+
+if [ $# -eq 0 ]; then
+ :
+elif [ $# -eq 1 -a $1 = "?" ]; then
+ echo "you can pass the arguments -host <host-url>, -url </url-fragment> and -path <any-string>, if no arguments are passed the default values 127.0.0.1:11008, /admin/backup and <current-data>.xtm are used";
+ exit;
+elif [ $# -eq 2 ]; then
+ if [ $1 = "-host" ]; then
+ host=$2;
+ elif [ $1 = "-url" ]; then
+ url=$2;
+ elif [ $1 = "-path" ]; then
+ path=$2;
+ else
+ echo "only the arguments -host, -url and -path are supported, use ? for more information";
+ exit;
+ fi
+elif [ $# -eq 4 ]; then
+ if [ $1 = "-host" ]; then
+ host=$2;
+ elif [ $1 = "-url" ]; then
+ url=$2;
+ elif [ $1 = "-path" ]; then
+ path=$2;
+ else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+ fi
+
+ if [ $3 = "-host" ]; then
+ host=$4;
+ elif [ $3 = "-url" ]; then
+ url=$4;
+ elif [ $3 = "-path" ]; then
+ path=$4;
+ else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+ fi
+elif [ $# -eq 6 ]; then
+ if [ $1 = "-host" ]; then
+ host=$2;
+ elif [ $1 = "-url" ]; then
+ url=$2;
+ elif [ $1 = "-path" ]; then
+ path=$2;
+ else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+ fi
+
+ if [ $3 = "-host" ]; then
+ host=$4;
+ elif [ $3 = "-url" ]; then
+ url=$4;
+ elif [ $3 = "-path" ]; then
+ path=$4;
+ else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+ fi
+ if [ $5 = "-host" ]; then
+ host=$6;
+ elif [ $5 = "-url" ]; then
+ url=$6;
+ elif [ $5 = "-path" ]; then
+ path=$6;
+ else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+ fi
+else
+ echo "only the arguments -host, -url and path are supported, use ? for more information";
+ exit;
+fi
+
+
+
+
+curl $host$url -o $path
\ No newline at end of file
More information about the Isidorus-cvs
mailing list