Skip to content
Snippets Groups Projects
Commit 384b6f78 authored by alvaro's avatar alvaro
Browse files

Adding disable option in utils/lodspk.sh that disables uriModule as well as...

Adding disable option in utils/lodspk.sh that disables uriModule as well as typeModule using something different
parent a60f1696
No related branches found
No related tags found
No related merge requests found
......@@ -119,11 +119,13 @@ class TypeModule extends abstractModule{
*/
//Get the firstResults type available
$typesAndValues = array('rdfs:Resource' => -1);
foreach($t as $v){
$curie = Utils::uri2curie($v);
$typesAndValues[$curie] = 0;
if(isset($conf['type']['priorities'][$curie]) && $conf['type']['priorities'][$curie] >= 0){
$typesAndValues[$curie] = $conf['type']['priorities'][$curie];
if($conf['disableComponents'] != true){
foreach($t as $v){
$curie = Utils::uri2curie($v);
$typesAndValues[$curie] = 0;
if(isset($conf['type']['priorities'][$curie]) && $conf['type']['priorities'][$curie] >= 0){
$typesAndValues[$curie] = $conf['type']['priorities'][$curie];
}
}
}
arsort($typesAndValues);
......
......@@ -11,6 +11,9 @@ class UriModule extends abstractModule{
global $endpoints;
global $lodspk;
if($conf['disableComponents'] == true){
return FALSE;
}
require_once('classes/MetaDb.php');
$metaDb = new MetaDb($conf['metadata']['db']['location']);
......
#!/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]"
USAGE="Usage:\n"
USAGE=$USAGE" Create component:\t\t\t\t\t$0 create uri|type|service foo [html|rdf|ttl|nt|json]\n"
USAGE=$USAGE" Delete component:\t\t\t\t\t$0 delete uri|type|service foo [html|rdf|ttl|nt|json]\n"
USAGE=$USAGE" Turn debug:\t\t\t\t\t\t$0 debug on|off\n"
USAGE=$USAGE" Switch to standard view/models temporaly:\t\t$0 disable on|off\n"
USAGE=$USAGE" Backup current installation:\t\t\t\t$0 backup\n"
USAGE=$USAGE" Restore previous instllation:\t\t\t\t$0 restore\n"
USAGEDEBUG="Usage: $0 debug on|off"
if [[ $# -eq 0 || "$1" == "--help" ]]; then
echo $USAGE
echo -e $USAGE
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
operations=( create delete debug backup restore )
operations=( create delete debug backup restore disable )
currentOperation=
if [[ ${operations[@]} =~ $1 ]]; then
currentOperation=$1
else
echo "Operation \"$1\" not valid"
echo $USAGE
echo -e $USAGE
exit 1
fi
## Backup
if [[ $currentOperation == "backup" ]]; then
$DIR/modules/backup.sh
exit
fi
## Restore
if [[ $currentOperation == "restore" ]]; then
$DIR/modules/restore.sh
exit
fi
## Create/delete
......@@ -40,7 +48,7 @@ if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then
currentModule=$2
else
echo "Module \"$2\" not valid"
echo $USAGE
echo -e $USAGE
exit 1
fi
......@@ -51,7 +59,7 @@ if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then
currentFormat=$4
else
echo "Format \"$4\" not valid"
echo $USAGE
echo -e $USAGE
exit 1
fi
else
......@@ -71,8 +79,25 @@ if [[ $currentOperation == "debug" ]]; then
debugOperation=$2
else
echo "Debug option not supported. Operation aborted" >&2
echo $USAGEDEBUG
echo -e $USAGE
exit 1
fi
php $DIR/modules/debug.php "$debugOperation"
exit
fi
## Backup
if [[ $currentOperation == "disable" ]]; then
defaultOptions=( on off 0 1 )
defaultOperation=
if [[ ${defaultOptions[@]} =~ $2 ]]
then
defaultOperation=$2
else
echo "Disable option not supported. Operation aborted" >&2
echo -e $USAGE
exit 1
fi
php $DIR/modules/default.php "$defaultOperation"
exit
fi
<?
error_reporting(E_ERROR);
$s = 'settings.inc.php';
$c = file_get_contents($s);
$optionarray = Array('on' => 'true', '1' => 'true', 'off' => 'false', '0' =>'false');
$antiarray = Array('on' => 'false', '1' => 'false', 'off' => 'true', '0' =>'true');
$option = $optionarray[$argv[1]];
if($option == "" || $option == null){
echo "Option not recognized. Aborting\n";
exit(1);
}
if(preg_match('/disableComponents(.+)'.$optionarray[$argv[1]].'/', $c)){
echo "Default already turned ".$option."\n";
exit(0);
}
$newC = preg_replace('/disableComponents(.+)'.$antiarray[$argv[1]].'/', "disableComponents'] = ".$option, $c);
if($newC == $c){
echo "WARNING: Variable 'disableComponents' does not exist. Adding it.\n";
$newC = preg_replace("/\?>/", "\n\$conf['disableComponents'] = ".$option.";\n?>", $c);
}
if(file_put_contents($s, $newC) === FALSE){
echo "An error ocurred";
exit(1);
}else{
echo "Default mode turned ".$option."\n";
}
?>
......@@ -12,8 +12,12 @@ if [[ ! -d $BACKUPDIR ]]; then
exit 1
fi
LIST=( `ls $BACKUPDIR/$NAME-backup*` )
LIST=( `ls $BACKUPDIR/$NAME-backup* 2>/dev/null` )
CHOSEN=-1
if [ "${#LIST[@]}" -eq 0 ];then
echo "No backups available";
exit
fi
while [[ "$CHOSEN" -lt 0 || "$CHOSEN" -ge "${#LIST[@]}" ]] ;do
j=0
echo
......
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