mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-20 09:55:58 +00:00
Compare commits
6 Commits
main
...
992cb55714
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
992cb55714 | ||
|
|
46782ea9a3 | ||
|
|
d03410c9ef | ||
|
|
aa2a6e4c02 | ||
|
|
ebdd77fb0a | ||
|
|
6c36aaeb8a |
@@ -5,6 +5,11 @@ if (!defined('PHPWG_ROOT_PATH'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bratonien_tools_nc_connector_create_local_api_first()
|
function bratonien_tools_nc_connector_create_local_api_first()
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Neue Verbindungen über die alte lokale PostgreSQL-/Storage-Struktur sind ab 0.9.6.2 gesperrt. Bestehende lokale Verbindungen bleiben für die schrittweise Migration weiterhin aktiv. Neue Verbindungen müssen über den WebDAV-Assistenten angelegt werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
function bratonien_tools_nc_connector_create_local_api_first_legacy()
|
||||||
{
|
{
|
||||||
$required = array(
|
$required = array(
|
||||||
'nc_name' => 'Name',
|
'nc_name' => 'Name',
|
||||||
|
|||||||
@@ -5,10 +5,89 @@ if (!defined('PHPWG_ROOT_PATH'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a disabled WebDAV-backed connector beside the existing local modes.
|
* Return the only existing local connector as migration fallback.
|
||||||
*
|
*
|
||||||
* This deliberately does not activate, migrate or modify any existing
|
* The 0.9.6.2 migration path is deliberately conservative: automatic pairing
|
||||||
* connection. It only persists the data required for the parallel WebDAV path.
|
* only happens when there is exactly one local connection. Its enabled/state
|
||||||
|
* flags are never changed here, so the proven local path keeps running while
|
||||||
|
* WebDAV is introduced beside it.
|
||||||
|
*/
|
||||||
|
function bratonien_tools_nc_connector_single_local_fallback()
|
||||||
|
{
|
||||||
|
bratonien_tools_nc_connector_ensure_table();
|
||||||
|
$table = bratonien_tools_nc_connector_table();
|
||||||
|
$result = pwg_query("SELECT id, enabled, takeover_state, config_json FROM `$table` WHERE adapter='local' ORDER BY id");
|
||||||
|
$rows = array();
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$rows[] = $row;
|
||||||
|
if (count($rows) > 1) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($rows) !== 1) return null;
|
||||||
|
|
||||||
|
$row = $rows[0];
|
||||||
|
$config = json_decode((string)$row['config_json'], true);
|
||||||
|
if (!is_array($config)) $config = array();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'id'=>(int)$row['id'],
|
||||||
|
'enabled'=>(bool)$row['enabled'],
|
||||||
|
'takeover_state'=>(string)$row['takeover_state'],
|
||||||
|
'config'=>$config,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link the new WebDAV connection with the single existing local connection.
|
||||||
|
*
|
||||||
|
* This is metadata only. The legacy connection is explicitly left untouched
|
||||||
|
* as an always-available fallback until a later, separately approved cutover.
|
||||||
|
*/
|
||||||
|
function bratonien_tools_nc_connector_pair_migration_fallback($webdav_id, array &$webdav_config, $now)
|
||||||
|
{
|
||||||
|
$legacy = bratonien_tools_nc_connector_single_local_fallback();
|
||||||
|
if (!$legacy) return null;
|
||||||
|
|
||||||
|
$legacy_id = (int)$legacy['id'];
|
||||||
|
if ($legacy_id < 1 || $legacy_id === (int)$webdav_id) return null;
|
||||||
|
|
||||||
|
$webdav_config['migration'] = array(
|
||||||
|
'role'=>'webdav-primary-candidate',
|
||||||
|
'legacy_fallback_connection_id'=>$legacy_id,
|
||||||
|
'fallback_policy'=>'keep-running',
|
||||||
|
'paired_at'=>(string)$now,
|
||||||
|
'cutover_state'=>'parallel',
|
||||||
|
);
|
||||||
|
|
||||||
|
$legacy_config = $legacy['config'];
|
||||||
|
$legacy_config['migration'] = array(
|
||||||
|
'role'=>'legacy-fallback',
|
||||||
|
'webdav_successor_connection_id'=>(int)$webdav_id,
|
||||||
|
'fallback_policy'=>'keep-running',
|
||||||
|
'paired_at'=>(string)$now,
|
||||||
|
'cutover_state'=>'parallel',
|
||||||
|
);
|
||||||
|
|
||||||
|
$legacy_json = json_encode($legacy_config, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
if (!is_string($legacy_json))
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Die bestehende Verbindung konnte nicht als Migrations-Fallback markiert werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = bratonien_tools_nc_connector_table();
|
||||||
|
pwg_query("UPDATE `$table` SET config_json='".pwg_db_real_escape_string($legacy_json)."', updated='".pwg_db_real_escape_string((string)$now)."' WHERE id=".$legacy_id." LIMIT 1");
|
||||||
|
|
||||||
|
return $legacy_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WebDAV-backed connector beside the existing local mode.
|
||||||
|
*
|
||||||
|
* Since 0.9.6.2, when exactly one local connection exists, the new WebDAV
|
||||||
|
* connection is automatically paired with it for migration. The local
|
||||||
|
* connection remains untouched and keeps running as fallback.
|
||||||
*/
|
*/
|
||||||
function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
||||||
{
|
{
|
||||||
@@ -116,18 +195,36 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
$id = (int)pwg_db_insert_id();
|
$id = (int)pwg_db_insert_id();
|
||||||
if ($id < 1) throw new RuntimeException('Die WebDAV-Testverbindung konnte nicht eindeutig angelegt werden.');
|
if ($id < 1) throw new RuntimeException('Die WebDAV-Testverbindung konnte nicht eindeutig angelegt werden.');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
$config['state_dir'] = '/var/lib/bratonien-tools/nc-connector/connection-'.$id;
|
$config['state_dir'] = '/var/lib/bratonien-tools/nc-connector/connection-'.$id;
|
||||||
$config['status_file'] = $config['state_dir'].'/connector-status.json';
|
$config['status_file'] = $config['state_dir'].'/connector-status.json';
|
||||||
|
$legacy_fallback_id = bratonien_tools_nc_connector_pair_migration_fallback($id, $config, $now);
|
||||||
|
|
||||||
$config_json = json_encode($config, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
$config_json = json_encode($config, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
if (!is_string($config_json))
|
if (!is_string($config_json))
|
||||||
{
|
{
|
||||||
pwg_query("DELETE FROM `$table` WHERE id=".$id." LIMIT 1");
|
|
||||||
throw new RuntimeException('Die WebDAV-Testverbindung konnte nach dem Anlegen nicht serialisiert werden.');
|
throw new RuntimeException('Die WebDAV-Testverbindung konnte nach dem Anlegen nicht serialisiert werden.');
|
||||||
}
|
}
|
||||||
pwg_query("UPDATE `$table` SET config_json='".pwg_db_real_escape_string($config_json)."' WHERE id=".$id." LIMIT 1");
|
pwg_query("UPDATE `$table` SET config_json='".pwg_db_real_escape_string($config_json)."' WHERE id=".$id." LIMIT 1");
|
||||||
|
}
|
||||||
|
catch (Throwable $e)
|
||||||
|
{
|
||||||
|
pwg_query("DELETE FROM `$table` WHERE id=".$id." LIMIT 1");
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($legacy_fallback_id !== null)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'connection_id'=>$id,
|
||||||
|
'legacy_fallback_connection_id'=>$legacy_fallback_id,
|
||||||
|
'message'=>'WebDAV-Verbindung wurde parallel angelegt. Die bestehende lokale Verbindung #'.$legacy_fallback_id.' bleibt unverändert als laufender Fallback erhalten.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'connection_id'=>$id,
|
'connection_id'=>$id,
|
||||||
'message'=>'Parallele WebDAV-Testverbindung wurde deaktiviert angelegt. Bestehende Verbindungen blieben unverändert.',
|
'message'=>'Parallele WebDAV-Verbindung wurde angelegt. Bestehende Verbindungen blieben unverändert.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,94 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
function initNcRouteStatus() {
|
||||||
|
var section = document.getElementById('nc-connector');
|
||||||
|
if (!section) return;
|
||||||
|
|
||||||
|
var statusCard = section.querySelector('.bratonien-grid .bratonien-card');
|
||||||
|
if (!statusCard) return;
|
||||||
|
|
||||||
|
var grid = statusCard.querySelector('.bratonien-form-grid');
|
||||||
|
if (!grid) return;
|
||||||
|
|
||||||
|
var routeLabel = document.createElement('span');
|
||||||
|
routeLabel.className = 'bratonien-label';
|
||||||
|
routeLabel.textContent = 'Aktiver Datenweg';
|
||||||
|
|
||||||
|
var routeValue = document.createElement('strong');
|
||||||
|
routeValue.setAttribute('data-nc-route-status', '');
|
||||||
|
routeValue.textContent = 'Noch kein Lauf erfasst';
|
||||||
|
|
||||||
|
var routeTimeLabel = document.createElement('span');
|
||||||
|
routeTimeLabel.className = 'bratonien-label';
|
||||||
|
routeTimeLabel.textContent = 'Datenweg zuletzt';
|
||||||
|
|
||||||
|
var routeTimeValue = document.createElement('strong');
|
||||||
|
routeTimeValue.setAttribute('data-nc-route-time', '');
|
||||||
|
routeTimeValue.textContent = 'Nicht verfügbar';
|
||||||
|
|
||||||
|
grid.appendChild(routeLabel);
|
||||||
|
grid.appendChild(routeValue);
|
||||||
|
grid.appendChild(routeTimeLabel);
|
||||||
|
grid.appendChild(routeTimeValue);
|
||||||
|
|
||||||
|
var detail = document.createElement('p');
|
||||||
|
detail.className = 'bratonien-base-note';
|
||||||
|
detail.setAttribute('data-nc-route-detail', '');
|
||||||
|
detail.textContent = 'Der Datenweg wird nach dem nächsten Connector-Lauf angezeigt.';
|
||||||
|
statusCard.appendChild(detail);
|
||||||
|
|
||||||
|
var basePath = window.location.pathname.replace(/admin\.php.*$/, '');
|
||||||
|
var statusUrl = basePath + '_data/bratonien-tools/nc-connector-status/route-status.json';
|
||||||
|
|
||||||
|
function formatTime(timestamp) {
|
||||||
|
if (!timestamp) return 'Nicht verfügbar';
|
||||||
|
var date = new Date(Number(timestamp) * 1000);
|
||||||
|
if (Number.isNaN(date.getTime())) return 'Nicht verfügbar';
|
||||||
|
return date.toLocaleString('de-DE');
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(data) {
|
||||||
|
var label = data && data.label ? String(data.label) : 'Unbekannt';
|
||||||
|
var route = data && data.route ? String(data.route) : '';
|
||||||
|
routeValue.textContent = label;
|
||||||
|
routeTimeValue.textContent = formatTime(data && data.timestamp);
|
||||||
|
|
||||||
|
if (route === 'webdav') {
|
||||||
|
routeValue.textContent = 'WEBDAV PRIMÄR';
|
||||||
|
detail.textContent = 'Portierung läuft über WebDAV. Legacy wurde in diesem Lauf nicht benutzt.';
|
||||||
|
} else if (route === 'legacy_fallback') {
|
||||||
|
routeValue.textContent = 'LEGACY-FALLBACK AKTIV';
|
||||||
|
detail.textContent = 'WebDAV war nicht erfolgreich. Dieser Lauf wurde über die alte Struktur abgefangen.';
|
||||||
|
} else if (route === 'failed') {
|
||||||
|
routeValue.textContent = 'FEHLER - KEIN ERFOLGREICHER DATENWEG';
|
||||||
|
detail.textContent = data && data.detail ? String(data.detail) : 'WebDAV und Fallback sind fehlgeschlagen.';
|
||||||
|
} else {
|
||||||
|
detail.textContent = data && data.detail ? String(data.detail) : 'Unbekannter Datenweg.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
fetch(statusUrl + '?t=' + Date.now(), {
|
||||||
|
cache: 'no-store',
|
||||||
|
credentials: 'same-origin'
|
||||||
|
})
|
||||||
|
.then(function (response) {
|
||||||
|
if (!response.ok) throw new Error('status unavailable');
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(render)
|
||||||
|
.catch(function () {
|
||||||
|
routeValue.textContent = 'Noch kein Lauf erfasst';
|
||||||
|
routeTimeValue.textContent = 'Nicht verfügbar';
|
||||||
|
detail.textContent = 'Nach dem nächsten Connector-Lauf wird hier WebDAV oder Legacy-Fallback angezeigt.';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
window.setInterval(refresh, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
function initBratonienTabs() {
|
function initBratonienTabs() {
|
||||||
var admin = document.querySelector('.bratonien-admin');
|
var admin = document.querySelector('.bratonien-admin');
|
||||||
if (!admin) return;
|
if (!admin) return;
|
||||||
@@ -113,9 +201,14 @@
|
|||||||
activate(initial, false);
|
activate(initial, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.readyState === 'loading') {
|
function init() {
|
||||||
document.addEventListener('DOMContentLoaded', initBratonienTabs);
|
|
||||||
} else {
|
|
||||||
initBratonienTabs();
|
initBratonienTabs();
|
||||||
|
initNcRouteStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Bratonien Tools
|
Plugin Name: Bratonien Tools
|
||||||
Version: 0.9.6.1
|
Version: 0.9.6.2
|
||||||
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
||||||
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
||||||
Author: Bratonien
|
Author: Bratonien
|
||||||
|
|||||||
@@ -5,20 +5,56 @@ CONFIG_DIR="/etc/bratonien-tools/nc-connector"
|
|||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
|
read_config_value() {
|
||||||
|
local key="$1"
|
||||||
|
local file="$2"
|
||||||
|
local value
|
||||||
|
value="$(sed -n "s/^${key}=//p" "$file" | tail -n 1)"
|
||||||
|
value="${value%\"}"
|
||||||
|
value="${value#\"}"
|
||||||
|
value="${value%\'}"
|
||||||
|
value="${value#\'}"
|
||||||
|
printf '%s' "$value"
|
||||||
|
}
|
||||||
|
|
||||||
|
write_route_status() {
|
||||||
|
local route="$1"
|
||||||
|
local label="$2"
|
||||||
|
local detail="$3"
|
||||||
|
local fallback_used="$4"
|
||||||
|
local success="$5"
|
||||||
|
|
||||||
|
[[ -n "${ROUTE_STATUS_FILE:-}" ]] || return 0
|
||||||
|
mkdir -p -- "$(dirname -- "$ROUTE_STATUS_FILE")"
|
||||||
|
|
||||||
|
php -r '
|
||||||
|
$payload = array(
|
||||||
|
"timestamp" => time(),
|
||||||
|
"route" => (string)$argv[2],
|
||||||
|
"label" => (string)$argv[3],
|
||||||
|
"detail" => (string)$argv[4],
|
||||||
|
"fallback_used" => $argv[5] === "1",
|
||||||
|
"success" => $argv[6] === "1"
|
||||||
|
);
|
||||||
|
$json = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
||||||
|
if (!is_string($json) || file_put_contents($argv[1], $json.PHP_EOL, LOCK_EX) === false) {
|
||||||
|
fwrite(STDERR, "Route-Status konnte nicht geschrieben werden.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
@chmod($argv[1], 0644);
|
||||||
|
' "$ROUTE_STATUS_FILE" "$route" "$label" "$detail" "$fallback_used" "$success"
|
||||||
|
}
|
||||||
|
|
||||||
if ! php "$SCRIPT_DIR/reconcile.php"; then
|
if ! php "$SCRIPT_DIR/reconcile.php"; then
|
||||||
echo "NC Connector: gespeicherte lokale Verbindungen konnten nicht mit der Runtime abgeglichen werden." >&2
|
echo "NC Connector: gespeicherte lokale Verbindungen konnten nicht mit der Runtime abgeglichen werden." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! php "$SCRIPT_DIR/reconcile-webdav.php"; then
|
if ! php "$SCRIPT_DIR/reconcile-webdav.php"; then
|
||||||
echo "NC Connector: WebDAV-Testverbindungen konnten nicht mit der parallelen Runtime abgeglichen werden." >&2
|
echo "NC Connector: WebDAV-Verbindungen konnten nicht mit der Runtime abgeglichen werden." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nach dem Reconcile kennt Piwigo alle noch aktiven WebDAV-Verbindungen. Jetzt
|
|
||||||
# werden Sites, Alben, Bilddatensaetze und Derivate geloeschter Verbindungen
|
|
||||||
# entfernt. Das erfasst auch Verbindungen, die bereits vor diesem Update
|
|
||||||
# geloescht wurden.
|
|
||||||
if ! php "$SCRIPT_DIR/cleanup-webdav-piwigo.php"; then
|
if ! php "$SCRIPT_DIR/cleanup-webdav-piwigo.php"; then
|
||||||
echo "NC Connector: Piwigo-Inhalte geloeschter WebDAV-Verbindungen konnten nicht bereinigt werden." >&2
|
echo "NC Connector: Piwigo-Inhalte geloeschter WebDAV-Verbindungen konnten nicht bereinigt werden." >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -37,21 +73,54 @@ if [[ ${#configs[@]} -eq 0 && ${#webdav_configs[@]} -eq 0 ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
result=0
|
route_piwigo_root=""
|
||||||
|
for candidate in "${webdav_configs[@]}" "${configs[@]}"; do
|
||||||
|
[[ -f "$candidate" ]] || continue
|
||||||
|
route_piwigo_root="$(read_config_value PIWIGO_ROOT "$candidate")"
|
||||||
|
[[ -n "$route_piwigo_root" ]] && break
|
||||||
|
done
|
||||||
|
[[ -n "$route_piwigo_root" ]] || route_piwigo_root="/var/www/piwigo"
|
||||||
|
ROUTE_STATUS_FILE="${route_piwigo_root%/}/_data/bratonien-tools/nc-connector-status/route-status.json"
|
||||||
|
|
||||||
|
webdav_success=0
|
||||||
|
webdav_failed=0
|
||||||
|
|
||||||
# WebDAV zuerst: Der parallele Shadow Tree muss bereits vollständig stehen,
|
|
||||||
# bevor der weiterhin produktive lokale Weg seine normale Piwigo-
|
|
||||||
# Dateisynchronisierung ausführt. So wird der neue Baum im selben Minutenlauf
|
|
||||||
# sichtbar, ohne dass der WebDAV-Zweig selbst eine zweite globale Piwigo-
|
|
||||||
# Synchronisierung startet.
|
|
||||||
for config in "${webdav_configs[@]}"; do
|
for config in "${webdav_configs[@]}"; do
|
||||||
name="$(basename "$config")"
|
name="$(basename "$config")"
|
||||||
echo "NC Connector WebDAV parallel: $name"
|
echo "NC Connector WebDAV primaer: $name"
|
||||||
if ! env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync-webdav.sh"; then
|
if env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync-webdav.sh"; then
|
||||||
result=1
|
webdav_success=1
|
||||||
|
else
|
||||||
|
webdav_failed=1
|
||||||
|
echo "NC Connector: WebDAV-Lauf fehlgeschlagen; Legacy-Fallback bleibt verfuegbar." >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$webdav_success" -eq 1 ]]; then
|
||||||
|
write_route_status \
|
||||||
|
"webdav" \
|
||||||
|
"WebDAV (primaer)" \
|
||||||
|
"WebDAV erfolgreich. Legacy-Fallback wurde in diesem Lauf nicht ausgefuehrt." \
|
||||||
|
"0" \
|
||||||
|
"1"
|
||||||
|
echo "NC Connector: WebDAV erfolgreich; Legacy-Verbindung wird in diesem Lauf nicht ausgefuehrt."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${#configs[@]} -eq 0 ]]; then
|
||||||
|
write_route_status \
|
||||||
|
"failed" \
|
||||||
|
"FEHLER - kein Datenweg" \
|
||||||
|
"WebDAV ist fehlgeschlagen und es ist keine Legacy-Fallback-Verbindung vorhanden." \
|
||||||
|
"0" \
|
||||||
|
"0"
|
||||||
|
echo "NC Connector: WebDAV ist fehlgeschlagen und es ist keine Legacy-Fallback-Verbindung vorhanden." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "NC Connector: kein erfolgreicher WebDAV-Lauf; Legacy-Fallback wird ausgefuehrt."
|
||||||
|
legacy_result=0
|
||||||
|
|
||||||
for config in "${configs[@]}"; do
|
for config in "${configs[@]}"; do
|
||||||
name="$(basename "$config")"
|
name="$(basename "$config")"
|
||||||
connection_id=""
|
connection_id=""
|
||||||
@@ -59,11 +128,7 @@ for config in "${configs[@]}"; do
|
|||||||
connection_id="${BASH_REMATCH[1]}"
|
connection_id="${BASH_REMATCH[1]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
piwigo_root="$(sed -n 's/^PIWIGO_ROOT=//p' "$config" | tail -n 1)"
|
piwigo_root="$(read_config_value PIWIGO_ROOT "$config")"
|
||||||
piwigo_root="${piwigo_root%\"}"
|
|
||||||
piwigo_root="${piwigo_root#\"}"
|
|
||||||
piwigo_root="${piwigo_root%\'}"
|
|
||||||
piwigo_root="${piwigo_root#\'}"
|
|
||||||
[[ -n "$piwigo_root" ]] || piwigo_root="/var/www/piwigo"
|
[[ -n "$piwigo_root" ]] || piwigo_root="/var/www/piwigo"
|
||||||
tombstone_dir="${piwigo_root%/}/_data/bratonien-tools/nc-connector-status"
|
tombstone_dir="${piwigo_root%/}/_data/bratonien-tools/nc-connector-status"
|
||||||
|
|
||||||
@@ -78,10 +143,31 @@ for config in "${configs[@]}"; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "NC Connector lokal: $name"
|
echo "NC Connector Legacy-Fallback: $name"
|
||||||
if ! env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync.sh"; then
|
if ! env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync.sh"; then
|
||||||
result=1
|
legacy_result=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
exit "$result"
|
if [[ "$legacy_result" -eq 0 ]]; then
|
||||||
|
write_route_status \
|
||||||
|
"legacy_fallback" \
|
||||||
|
"LEGACY-FALLBACK AKTIV" \
|
||||||
|
"WebDAV war nicht erfolgreich. Der alte lokale Datenweg wurde als Fallback ausgefuehrt." \
|
||||||
|
"1" \
|
||||||
|
"1"
|
||||||
|
echo "NC Connector: Legacy-Fallback erfolgreich."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
write_route_status \
|
||||||
|
"failed" \
|
||||||
|
"FEHLER - WebDAV und Fallback" \
|
||||||
|
"WebDAV und Legacy-Fallback sind fehlgeschlagen." \
|
||||||
|
"1" \
|
||||||
|
"0"
|
||||||
|
|
||||||
|
if [[ "$webdav_failed" -eq 1 ]]; then
|
||||||
|
echo "NC Connector: WebDAV und Legacy-Fallback sind fehlgeschlagen." >&2
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user