Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first working version

  • Loading branch information...
commit b963502e2cba368a69fe2fe6ca13d09de406622d 1 parent feb0a3e
Nuno Job authored
16 lib-installer/attach-forest.xqy
View
@@ -0,0 +1,16 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+let $config := admin:database-attach-forest(
+ admin:get-configuration(), xdmp:database($ai:name), xdmp:forest($ai:name))
+return ( admin:save-configuration($config),
+ <div class="message">
+ A Database and Forest called {$ai:name} attached together successfully
+ </div> )
17 lib-installer/create-database.xqy
View
@@ -0,0 +1,17 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+let $config := admin:database-create(admin:get-configuration(), $ai:name, xdmp:database("Security"), xdmp:database("Schemas"))
+return
+ (
+ admin:save-configuration($config)
+ ,
+ <div class="message">A Database called {$ai:name} created successfully</div>
+ )
17 lib-installer/create-forest.xqy
View
@@ -0,0 +1,17 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+let $config := admin:forest-create(admin:get-configuration(), $ai:name, xdmp:host(), ())
+return
+ (
+ admin:save-configuration($config)
+ ,
+ <div class="message">A Forest called {$ai:name} created successfully</div>
+ )
24 lib-installer/create-http-server.xqy
View
@@ -0,0 +1,24 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+declare variable $ai:port as xs:string external;
+declare variable $ai:nodb as xs:boolean external;
+
+(: Apps/usr :)
+let $config := admin:get-configuration()
+let $db := if ($ai:nodb) then "Documents" else $ai:name
+let $groupid := admin:group-get-id($config, "Default")
+let $new-config := admin:http-server-create($config, $groupid, $ai:name,
+ fn:concat("Apps/usr/",$ai:name), xs:unsignedLong($ai:port), 0, xdmp:database($db) )
+return
+ (
+ admin:save-configuration($new-config)
+ ,
+ <div class="message">An HTTP Server called {$ai:name} with root {$ai:name} on port {$ai:port} created successfully</div>
+ )
45 lib-installer/default.xqy
View
@@ -0,0 +1,45 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+xquery version "1.0-ml";
+
+let $doctype := '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
+let $html :=
+ <html>
+ <head>
+ <title>API Application Setup</title>
+ <script language="javascript" src="js/prototype.js" type="text/javascript">{" "}</script>
+ <script type="text/javascript" language="javascript">
+ //<![CDATA[
+ function install() {
+ var name = document.getElementById('name').value;
+ var port = document.getElementById('port').value;
+
+ var url = '/api-installer/api-setup-run.xqy?app=' + name + ':' + port;
+
+ new Ajax.Updater('results', '/api-installer/get-spinner.xqy', {asynchronous:true});
+ new Ajax.Updater('results', url, {asynchronous:true});
+ }
+ //]]>
+ </script>
+ </head>
+ <body>
+ <div style="font-weight:bold; font-size: 120%; text-align:center; padding: 20px;">API Search Install and Setup</div>
+ <div>
+ <span>Name: </span>
+ <input type="textbox" id="name" />
+ <span>Port: </span>
+ <input type="textbox" id="port" />
+ <input type="submit" value="Install" onClick="install()"/>
+ <div id="results" style="padding: 20px; border: 1px solid #DDD; width: 500px; font-style: italic; margin-top: 20px;">{"<Current Progress>"}</div>
+ </div>
+ </body>
+ </html>
+
+return
+ (
+ xdmp:set-response-content-type("text/html; charset=utf-8"),
+ $doctype,
+ $html
+ )
+
20 lib-installer/delete-database.xqy
View
@@ -0,0 +1,20 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+try {
+ let $config := admin:get-configuration()
+ let $config := admin:database-delete($config, xdmp:database($ai:name))
+ return admin:save-configuration($config)
+ } catch ($e) {
+ <div class="error-delete-database">
+ <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
20 lib-installer/delete-forest.xqy
View
@@ -0,0 +1,20 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+try {
+ let $config := admin:get-configuration()
+ let $config := admin:forest-delete($config, admin:forest-get-id($config, $ai:name), fn:true())
+ return admin:save-configuration($config)
+} catch ($e) {
+ <div class="error-delete-forest">
+ <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
25 lib-installer/delete-http-server.xqy
View
@@ -0,0 +1,25 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+try {
+ let $config := admin:get-configuration()
+ let $groupid := admin:group-get-id($config, "Default")
+ let $config := admin:appserver-delete($config, admin:appserver-get-id($config, $groupid, $ai:name) )
+ return
+ (
+ admin:save-configuration($config),
+ xdmp:sleep(15000)
+ )
+} catch ($e) {
+ <div class="error-delete-http-server">
+ <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
20 lib-installer/detach-forest.xqy
View
@@ -0,0 +1,20 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
+
+declare namespace ai="api-install";
+declare variable $ai:name as xs:string external;
+
+try {
+ let $config := admin:get-configuration()
+ let $config := admin:database-detach-forest($config, xdmp:database($ai:name), xdmp:forest($ai:name) )
+ return admin:save-configuration($config)
+ } catch ($e) {
+ <div class="error-detach-forest">
+ <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
8 lib-installer/get-spinner.xqy
View
@@ -0,0 +1,8 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+xquery version "1.0-ml";
+
+declare namespace htm="http://www.w3.org/1999/xhtml";
+
+<img src="/api-installer/images/spinner.gif"/>
10 lib-installer/hooks/install/incommit.xqy
View
@@ -0,0 +1,10 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+ (: dont remove (or change) this file
+ : this is the default trigger, user can pass another that will
+ : override this
+ :)
+ xquery version "1.0-ml";
+()
10 lib-installer/hooks/install/precommit.xqy
View
@@ -0,0 +1,10 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+ (: dont remove (or change) this file
+ : this is the default trigger, user can pass another that will
+ : override this
+ :)
+xquery version "1.0-ml";
+()
11 lib-installer/hooks/uninstall/incommit.xqy
View
@@ -0,0 +1,11 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+ (: dont remove (or change) this file
+ : this is the default trigger, user can pass another that will
+ : override this
+ :)
+
+xquery version "1.0-ml";
+()
11 lib-installer/hooks/uninstall/precommit.xqy
View
@@ -0,0 +1,11 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+ (: dont remove (or change) this file
+ : this is the default trigger, user can pass another that will
+ : override this
+ :)
+
+xquery version "1.0-ml";
+()
BIN  lib-installer/images/spinner.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 lib-installer/install.xqy
View
@@ -0,0 +1,33 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+xquery version "1.0-ml";
+declare namespace ai="api-install";
+
+try {
+let $app := xdmp:get-request-field("app")
+let $name := fn:substring-before($app, ":")
+let $port := fn:substring-after($app, ":")
+let $noappserver := xdmp:get-request-field("noappserver")
+let $nodb := xdmp:get-request-field("nodb")
+let $_ :=
+ xdmp:log(fn:concat("Installing ", $name, " on port ", $port,
+ ". NoAppServer set to ", $noappserver, ". NoDB set to ", $nodb, "."))
+let $args-name := (xs:QName("ai:name"), $name)
+let $args-port := ($args-name, xs:QName("ai:port"), $port)
+let $args-nodb := ($args-port, xs:QName("ai:nodb"), fn:boolean($nodb))
+return (
+ xdmp:invoke("hooks/install/precommit.xqy", $args-port),
+ if ($nodb) then () else xdmp:invoke("create-forest.xqy", $args-name),
+ if ($nodb) then () else xdmp:invoke("create-database.xqy", $args-name),
+ if ($nodb) then () else xdmp:invoke("attach-forest.xqy", $args-name),
+ if ($noappserver) then () else xdmp:invoke("create-http-server.xqy", $args-nodb),
+ xdmp:invoke("hooks/install/incommit.xqy", $args-port),
+ <div> Click
+ <a href="{fn:concat('http://localhost:', $port)}">here</a> to continue...
+ </div> )
+ } catch ($e) {
+ <div> <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
27 lib-installer/install.xqy~
View
@@ -0,0 +1,27 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+declare namespace ai="api-install";
+
+try {
+let $app := xdmp:get-request-field("app")
+let $name := fn:substring-before($app, ":")
+let $port := fn:substring-after($app, ":")
+let $noappserver := xdmp:get-request-field("noappserver")
+return (
+ xdmp:invoke("hooks/install/precommit.xqy", (xs:QName("ai:name"), $name, xs:QName("ai:port"), $port)),
+ xdmp:invoke("create-forest.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("create-database.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("attach-forest.xqy", (xs:QName("ai:name"), $name)),
+ if ($noappserver) then () else xdmp:invoke("create-http-server.xqy", (xs:QName("ai:name"), $name, xs:QName("ai:port"), $port)),
+ xdmp:invoke("hooks/install/incommit.xqy", (xs:QName("ai:name"), $name, xs:QName("ai:port"), $port)),
+ <div> Click
+ <a href="{fn:concat('http://localhost:', $port)}">here</a> to continue...
+ </div> )
+ } catch ($e) {
+ <div> <h3>Error</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
4,188 lib-installer/js/prototype.js
View
4,188 additions, 0 deletions not shown
24 lib-installer/uninstall.xqy
View
@@ -0,0 +1,24 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+declare namespace ai="api-install";
+
+try {
+ let $name := xdmp:get-request-field("app")
+ let $noappserver := xdmp:get-request-field("noappserver")
+ return (
+ xdmp:invoke("hooks/uninstall/precommit.xqy", (xs:QName("ai:name"), $name)),
+ if ($noappserver) then () else xdmp:invoke("delete-http-server.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("detach-forest.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("delete-database.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("delete-forest.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("hooks/uninstall/incommit.xqy", (xs:QName("ai:name"), $name)),
+ <div> Uninstall complete </div>)
+ } catch ($e) {
+ <div class="error-triggers">
+ <h3>Error in your supplied triggers</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
24 lib-installer/uninstall.xqy~
View
@@ -0,0 +1,24 @@
+(:
+ : Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+ :)
+
+xquery version "1.0-ml";
+declare namespace ai="api-install";
+
+try {
+ let $name := xdmp:get-request-field("app")
+ let $noappserver := xdmp:get-request-field("noappserver")
+ return (
+ xdmp:invoke("hooks/uninstall/precommit.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("delete-http-server.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("detach-forest.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("delete-database.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("delete-forest.xqy", (xs:QName("ai:name"), $name)),
+ xdmp:invoke("hooks/uninstall/incommit.xqy", (xs:QName("ai:name"), $name)),
+ <div> Uninstall complete </div>)
+ } catch ($e) {
+ <div class="error-triggers">
+ <h3>Error in your supplied triggers</h3>
+ <div class="error-stack-trace"> { $e } </div>
+ </div>
+ }
206 ml-install
View
@@ -0,0 +1,206 @@
+#!/bin/bash
+#
+# Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# The use of the Apache License does not indicate that this project is
+# affiliated with the Apache Software Foundation.
+. /lib/lsb/init-functions
+. /etc/sysconfig/MarkLogic
+usage="Usage: $0 [OPTION]...
+This script can be used to easen regular deployment tasks in Mark Logic Server.
+Includes hooks that you can use to extend the normal install
+
+Options:
+ -u Set the user
+ -p Set the password
+ -N Set the application name
+ -P Set the application port
+
+ -d The directory where the app to be installed currently resides
+ Will be ignored if you supply -i
+
+ -b Script (.xqy) to be run before the installer is invoked
+ -m Script (.xqy) to be run after database artifacts are created, but before
+ deployment of the appserver.
+ -a Script (.xqy) to be run after the installer is invoked.
+ Note: Only this script is actually deployed with the app,
+ so to do things like loading content you have to use this
+ trigger. Will be ignored if you supply -i, as that means no app
+ was deployed (you simply installed a database)
+
+ -i Create database artifacts, but NO Application Server.
+ -j Create an Application Server, but NO database artifacts
+
+ -D Turns debug on
+ -l Base path for the installer libraries, case they aren't in ./lib-installer"
+
+function debug_echo () {
+ if [ ! -z "$debug" ]; then
+ for line in "$@"
+ do
+ echo "$(date) - [MarkLogic] $line"
+ done
+ fi }
+
+function debug_exec () {
+ if [ ! -z "$debug" ]; then
+ debug_echo "$1"
+ inst=&$1
+ else
+ inst=&$1 > /dev/null 2>&1
+ fi }
+
+user=""
+pass=""
+appname=""
+appport=""
+appdir=""
+bxqy=""
+mxqy=""
+axqy=""
+debug=""
+appserver="1"
+db="1"
+
+scriptpath=`cd $(dirname $0);pwd`
+libname="lib-installer"
+libfolder="$scriptpath/$libname"
+
+while getopts "hu:p:N:P:b:m:a:d:l:Dij" opts
+do case "$opts" in
+ l) libfolder="$OPTARG";;
+ u) user="$OPTARG";;
+ p) pass="$OPTARG";;
+ P) appport="$OPTARG";;
+ N) appname="$OPTARG";;
+ b) bxqy="$OPTARG";;
+ m) mxqy="$OPTARG";;
+ a) axqy="$OPTARG";;
+ d) appdir="$OPTARG";;
+ D) debug="1";;
+ i) appserver="";;
+ j) db="";;
+ h) echo >&2 "$usage"
+ exit 1;;
+ ?) echo >&2 "$usage"
+ exit 1;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+debug_echo "From opts:" \
+" Lib Folder: $libfolder" \
+" Lib Name: $libname" \
+" Where is: $scriptpath" \
+" User: $user" \
+" Application Name: $appname" \
+" Application Port: $appport" \
+" Application Dir: $appdir" \
+" Before Commit: $bxqy" \
+" In Commit: $mxqy" \
+" After Commit: $axqy"
+
+if [ "$#" -ne 0 ]; then
+ echo "Wrong number of arguments"
+ echo $usage
+ exit 1
+fi
+
+if [ -z "$appname" ]; then
+ echo -n "[MarkLogic] Application Name: "
+ read appname > /dev/null 2>&1
+fi
+if [ -z "$appport" ]; then
+ echo -n "[MarkLogic] Application Port: "
+ read appport > /dev/null 2>&1
+fi
+
+params="app=$appname:$appport"
+if [ ! -z "$appserver" ]; then
+ if [ -z "$appdir" ]; then
+ echo -n "[MarkLogic] Directory to install: "
+ read appdir > /dev/null 2>&1
+ fi
+else
+ params=$params"&noappserver=yes"
+fi
+if [ -z "$db" ]; then
+ params=$params"&nodb=yes"
+fi
+
+debug_echo "Params => $params"
+
+if [ -z "$user" ]; then
+ echo -n "[MarkLogic] Username: "
+ read user > /dev/null 2>&1
+fi
+if [ -z "$pass" ]; then
+ echo -n "[MarkLogic] Password for $user: "
+ read -s pass > /dev/null 2>&1
+ echo
+fi
+
+instsysdir="$MARKLOGIC_INSTALL_DIR/Docs/$libname"
+instappdir="$MARKLOGIC_INSTALL_DIR/Apps/usr"
+
+debug_echo "Lib Folder: $libfolder" \
+"Lib Name: $libname" \
+"Where is: $scriptpath" \
+"User: $user" \
+"Application Name: $appname" \
+"Application Port: $appport" \
+"Application Dir: $appdir" \
+"Before Commit: $bxqy" \
+"In Commit: $mxqy" \
+"After Commit: $axqy"
+
+#sudo just to avoid sudo box appearing in the middle on flow
+sudo echo "Lazy Panda is now installing app $appname:$appport from '$appdir'"
+echo " . Registering the Installer with MarkLogic Server"
+debug_exec "sudo rm -rf $instsysdir"
+debug_exec "sudo cp -r $libfolder/ $instsysdir"
+if [ ! -z "$bxqy" ]; then
+ echo " . Installing Pre-commit triggers ($bxqy)"
+ debug_exec "sudo cp $bxqy $instsysdir/hooks/install/precommit.xqy"
+fi
+if [ ! -z "$mxqy" ]; then
+ echo " . Installing In-commit triggers ($mxqy)"
+ debug_exec "sudo cp $mxqy $instsysdir/hooks/install/incommit.xqy"
+fi
+echo " . Registering the application with MarkLogic Server"
+
+debug_exec "curl --anyauth http://$user:$pass@localhost:8000/$libname/install.xqy?$params"
+echo " . Taking a nap"
+sleep 5
+if [ ! -z "$appserver" ]; then
+ echo " . Deploying the application to '$instappdir/$appname'"
+ debug_exec "sudo rm -r $instappdir/$appname"
+ debug_exec "sudo mkdir $instappdir"
+ debug_exec "sudo cp -r $appdir/ $instappdir/$appname"
+ if [ ! -z "$axqy" ]; then
+ echo " . Installing Pos-commit triggers ($axqy)"
+ debug_exec "sudo cp $axqy $instappdir/$appname/_poscommit.xqy"
+ debug_exec "curl --anyauth http://$user:$pass@localhost:$appport/_poscommit.xqy?app=$appname"
+ sleep 5
+ echo " . Give me a break, sleeping"
+ debug_exec "sudo rm $instappdir/$appname/_poscommit.xqy"
+ fi
+fi
+echo " . Removing the installer from disk"
+debug_exec "sudo rm -rf $instsysdir"
+echo " . Installation Complete @ http://localhost:$appport"
+debug_exec "firefox http://localhost:$appport"
+echo "The End! Happy Panda!"
136 ml-uninstall
View
@@ -0,0 +1,136 @@
+#!/bin/bash
+#
+# Copyright 2010 Mark Logic Corporation. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# The use of the Apache License does not indicate that this project is
+# affiliated with the Apache Software Foundation.
+. /lib/lsb/init-functions
+. /etc/sysconfig/MarkLogic
+usage="Usage: $0 [OPTION]...
+This script is to be used to uninstall apps that were installed using
+ml-install
+
+Options:
+ -D Turns debug on
+ -u Set the user
+ -p Set the password
+ -N Set the application name
+ -b Script (.xqy) to be run before the uninstaller is invoked
+ -a Script (.xqy) to be run after the uninstaller is invoked."
+
+function debug_echo () {
+ if [ ! -z "$debug" ]; then
+ for line in "$@"
+ do
+ echo "$(date) - [MarkLogic] $line"
+ done
+ fi }
+
+function debug_exec () {
+ if [ ! -z "$debug" ]; then
+ debug_echo "$1"
+ inst=&$1
+ else
+ inst=&$1 > /dev/null 2>&1
+ fi }
+
+user=""
+pass=""
+appname=""
+bxqy=""
+axqy=""
+debug=""
+
+scriptpath=`cd $(dirname $0);pwd`
+libname="lib-installer"
+libfolder="$scriptpath/$libname"
+
+while getopts "hu:p:N:b:a:l:D" opts
+do case "$opts" in
+ l) libfolder="$OPTARG";;
+ u) user="$OPTARG";;
+ p) pass="$OPTARG";;
+ N) appname="$OPTARG";;
+ b) bxqy="$OPTARG";;
+ a) axqy="$OPTARG";;
+ D) debug="1";;
+ h) echo >&2 "$usage"
+ exit 1;;
+ ?) echo >&2 "$usage"
+ exit 1;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+if [ "$#" -ne 0 ]; then
+ echo "Wrong number of arguments"
+ echo $usage
+ exit 1
+fi
+
+if [ -z "$user" ]; then
+ echo -n "[MarkLogic] Username: "
+ read user > /dev/null 2>&1
+fi
+if [ -z "$pass" ]; then
+ echo -n "[MarkLogic] Password for $user: "
+ read -s pass > /dev/null 2>&1
+ echo
+fi
+if [ -z "$appname" ]; then
+ echo -n "[MarkLogic] Application Name: "
+ read appname > /dev/null 2>&1
+fi
+
+debug_echo "Lib Folder: $libfolder" \
+"Lib Name: $libname" \
+"Where is: $scriptpath" \
+"User: $user" \
+"Application Name: $appname" \
+"Before Commit: $bxqy" \
+"After Commit: $axqy"
+
+instsysdir="$MARKLOGIC_INSTALL_DIR/Docs/$libname"
+instappdir="$MARKLOGIC_INSTALL_DIR/Apps/usr"
+
+echo "Lazy Panda is now un-installing app $appname"
+echo " ( that makes him a sad panda )"
+echo " . Registering the Installer with MarkLogic Server"
+debug_exec "sudo rm -rf $instsysdir"
+debug_exec "sudo cp -r $libfolder/ $instsysdir"
+if [ ! -z "$bxqy" ]; then
+ echo " . Installing Pre-commit triggers ($bxqy)"
+ debug_exec "sudo cp $bxqy $instsysdir/hooks/uninstall/precommit.xqy"
+fi
+if [ ! -z "$axqy" ]; then
+ echo " . Installing Pos-commit triggers ($axqy)"
+ debug_exec "sudo cp $axqy $instsysdir/hooks/uninstall/poscommit.xqy"
+fi
+echo " . Un-registering the application with MarkLogic Server"
+debug_exec "curl --anyauth http://$user:$pass@localhost:8000/$libname/uninstall.xqy?app=$appname"
+# lazy way to avoi curl: (52) Empty reply from server
+# this is a known bug.. needs investigation
+# probably because server restarts after removing an appserver
+sleep 10
+debug_exec "curl --anyauth http://$user:$pass@localhost:8000/$libname/uninstall.xqy?app=$appname"
+echo " . Taking a nap"
+sleep 5
+echo " . Removing the app from disk"
+debug_exec "sudo rm -rf $instappdir/$appname"
+echo " . Removing the installer from disk"
+debug_exec "sudo rm -rf $instsysdir"
+echo " . Installation Complete"
+echo "The End! (panda says bye)"
Please sign in to comment.
Something went wrong with that request. Please try again.