Skip to content
Snippets Groups Projects
Commit 8776f659 authored by Alvaro Graves's avatar Alvaro Graves
Browse files

Adding backup capability to lodspk.sh

parent 189cd752
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#
# https://github.com/alangrafu/lodspeakr/blob/master/utils/ldspk.sh
USAGE="Usage: $0 create|delete uri|type|service foo [html|rdf|ttl|nt|json]"
USAGEDEBUG="Usage: $0 debug on|off"
if [[ $# -eq 0 || "$1" == "--help" ]]; then
echo $USAGE
exit 1
echo $USAGE
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
operations=( create delete debug )
modules=( type service uri )
formats=( html rdf ttl nt json all )
debugOptions=( on off 0 1 )
operations=( create delete debug backup )
currentOperation=
currentModule=
currentFormat=
debugOperation=
if [[ ${operations[@]} =~ $1 ]]; then
currentOperation=$1
......@@ -27,17 +20,17 @@ else
exit 1
fi
if [[ $currentOperation = "debug" ]]
then
if [[ ${debugOptions[@]} =~ $2 ]]
then
debugOperation=$2
else
echo "Debug option not supported. Operation aborted" >&2
echo $USAGEDEBUG
exit 1
fi
else
## Backup
if [[ $currentOperation == "backup" ]]; then
$DIR/modules/backup.sh
fi
## Create/delete
if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then
modules=( type service uri )
formats=( html rdf ttl nt json all )
currentModule=
currentFormat=
if [[ ${modules[@]} =~ $2 ]]; then
currentModule=$2
else
......@@ -45,9 +38,9 @@ else
echo $USAGE
exit 1
fi
currentUnit=$3
if [[ ${formats[@]} =~ $4 ]]; then
currentFormat=$4
else
......@@ -59,15 +52,20 @@ else
exit 1
fi
fi
$DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat"
fi
if [[ $currentOperation == "create" ]]; then
$DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat"
fi
if [[ $currentOperation == "delete" ]]; then
$DIR/modules/delete-$currentModule.sh "$currentUnit" "$currentFormat"
fi
## Debug
if [[ $currentOperation == "debug" ]]; then
php $DIR/modules/debug.php "$debugOperation"
debugOptions=( on off 0 1 )
debugOperation=
if [[ ${debugOptions[@]} =~ $2 ]]
then
debugOperation=$2
else
echo "Debug option not supported. Operation aborted" >&2
echo $USAGEDEBUG
exit 1
fi
php $DIR/modules/debug.php "$debugOperation"
fi
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BACKUPDIR=$HOME/lodspeakr_backup
cd $DIR/../..
if [[ ! -d $BACKUPDIR ]]; then
echo "WARNING: No $BACKUPDIR dir. Creating it." >&2
mkdir $BACKUPDIR
fi
if [[ ! -d $BACKUPDIR ]]; then
echo "ERROR: Couldn't create $BACKUPDIR. Operation aborted" >&2
exit 1
fi
tmpFile=lodspeakr_backup_`date +%Y%m%d%H%M%S`.tar.gz
tar -czf $tmpFile settings.inc.php models views
mv $tmpFile $BACKUPDIR/
echo "New backup $tmpFile created"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}"
{%endfor%}version="XHTML+RDFa 1.0" xml:lang="en">
<head>
<title>Page about {{lodspk.this.value}}</title>
<link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="alternate" type="application/rdf+xml" title="RDF/XML Version" href="{{lodspk.this.value}}.rdf" />
<link rel="alternate" type="text/turtle" title="Turtle Version" href="{{lodspk.this.value}}.ttl" />
<link rel="alternate" type="text/plain" title="N-Triples Version" href="{{lodspk.this.value}}.nt" />
<link rel="alternate" type="application/json" title="RDFJSON Version" href="{{lodspk.this.value}}.json" />
</head>
<body about="{{lodspk.this.value}}">
<h1>Page about <a href='{{lodspk.this.value}}'>{{lodspk.this.curie}}</a></h1>
<div>
<h2>Information from {{lodspk.this.curie}}</h2>
<table>
{% for row in models.main %}
{% if row.s1%}
<tr>
<td><a href='{{row.s1.value}}'>{{row.s1.curie}}</a></td>
{% if row.p1.uri == 1 %}
<td><a rel='{{row.s1.curie}}' href='{{row.p1.value}}'>{{row.p1.curie}}</a></td>
{% else %}
<td><span property='{{row.s1.curie}}'>{{row.p1.value}}</span></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</table>
<br/><br/>
<h2>Information pointing to {{lodspk.this.curie}}</h2>
<table>
{% for row in models.main %}
{% if row.s2%}
<tr>
<td><a href='{{row.s2.value}}'>{{row.s2.curie}}</a></td>
<td><a rev='[{{row.p2.curie}}]' href='{{row.s2.value}}'>{{row.p2.curie}}</a></td>
</tr>
{%endif %}
{% endfor %}
</table>
</div>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment