Skip to content

Commit

Permalink
Plugin can now upgrade October v1 sites
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed May 28, 2021
1 parent e328265 commit ae5a84b
Show file tree
Hide file tree
Showing 23 changed files with 260 additions and 30 deletions.
11 changes: 11 additions & 0 deletions beacon/scripts/clear_cache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Ouptut
$result = [
'status' => 'ok',
];

// Remove cache files
@unlink(__DIR__ . '/../storage/framework/classes.php');
@unlink(__DIR__ . '/../storage/framework/packages.php');
@unlink(__DIR__ . '/../storage/framework/services.php');

return $result;
12 changes: 11 additions & 1 deletion beacon/templates/app/bootstrap/beacon.stub
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function processHealthCheck()
outputResponse([
'appWritable' => isAppWritable(),
'appInstalled' => isAppInstalled(),
'storageWritable' => isStorageWritable()
'storageWritable' => isStorageWritable(),
'envFound' => isEnvFound(),
'phpVersion' => PHP_VERSION
]);
}

Expand Down Expand Up @@ -449,6 +451,14 @@ function isAppInstalled(): bool
return file_exists(__DIR__.'/../vendor/october/rain/src/Support/helpers.php');
}

/**
* isEnvFound checks if an environment variable file is found
*/
function isEnvFound(): bool
{
return file_exists(__DIR__.'/../.env');
}

/**
* isAppWritable checks if the root directory is writable
*/
Expand Down
50 changes: 50 additions & 0 deletions controllers/Servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Servers extends SettingsController
'privkey' => '/plugins/rainlab/deploy/models/server/fields_privkey.yaml',
'env_config' => '/plugins/rainlab/deploy/models/server/fields_env_config.yaml',
'shell_script' => '/plugins/rainlab/deploy/models/server/fields_shell_script.yaml',
'upgrade_legacy' => '/plugins/rainlab/deploy/models/server/fields_upgrade_legacy.yaml',
];

/**
Expand Down Expand Up @@ -111,6 +112,10 @@ public function manage($recordId = null)
$context = 'manage_download';
break;

case $model::STATUS_LEGACY:
$context = 'manage_legacy';
break;

default:
$context = 'manage';
break;
Expand Down Expand Up @@ -323,6 +328,12 @@ public function manage_onSaveDeployToServer($serverId)
];
}

$deployActions[] = [
'label' => 'Clearing Cache',
'action' => 'transmitScript',
'script' => 'clear_cache'
];

$deployActions[] = [
'label' => 'Migrating Database',
'action' => 'transmitArtisan',
Expand Down Expand Up @@ -463,6 +474,45 @@ public function manage_onSaveInstallToServer($serverId)
return $this->deployerWidget->executeSteps($serverId, $deployActions);
}


/**
* manage_onLoadUpgradeLegacy upgrades a legacy version
*/
public function manage_onLoadUpgradeLegacy()
{
$widget = $this->formWidgetInstances['upgrade_legacy'];

$this->vars['actionTitle'] = 'Upgrade Config';
$this->vars['actionHandler'] = 'onRunUpgradeLegacy';
$this->vars['submitText'] = 'Run';
$this->vars['closeText'] = 'Close';
$this->vars['widget'] = $widget;

return $this->makePartial('action_form');
}

/**
* manage_onRunUpgradeLegacy deploys selected objects to the server
*/
public function manage_onRunUpgradeLegacy($serverId)
{
// Create deployment chain
$deployActions = [];

$deployActions[] = [
'label' => 'Upgrading Legacy Site',
'action' => 'transmitArtisan',
'artisan' => 'october:env'
];

$deployActions[] = [
'label' => 'Finishing Up',
'action' => 'final'
];

return $this->deployerWidget->executeSteps($serverId, $deployActions);
}

/**
* buildArchiveDeployStep builds a single archive step used for deployment
*/
Expand Down
21 changes: 21 additions & 0 deletions controllers/servers/_action_convert_legacy.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

<div class="deploy-action">
<div class="row">
<div class="col-md-8">
<h5><?= __("Upgrade Configuration Files") ?></h5>
<p><?= __("Runs the artisan command to create an environment file") ?></p>
</div>
<div class="col-md-4">
<div class="deploy-action-button">
<button
class="btn btn-primary"
data-control="popup"
data-size="huge"
data-request-data="server_id: '<?= $formModel->id ?>'"
data-handler="onLoadUpgradeLegacy">
<?= __("Upgrade Config") ?>
</button>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion controllers/servers/_action_update_config.htm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h5><?= __("Update Environment Variables") ?></h5>
data-size="huge"
data-request-data="server_id: '<?= $formModel->id ?>'"
data-handler="onLoadEnvConfig">
<?= __("Update Config") ?>
<?= __("Update Environment") ?>
</button>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions controllers/servers/_manage_scoreboard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ <h4><?= __("Beacon Status") ?></h4>
<?php if ($formModel->status_code === $formModel::STATUS_READY): ?>
<p class="oc-icon-cloud-upload"><?= __("Ready") ?></p>
<?php endif ?>
<?php if ($formModel->status_code === $formModel::STATUS_LEGACY): ?>
<p class="oc-icon-life-ring"><?= __("Legacy") ?></p>
<?php endif ?>
<?php if ($formModel->status_code === $formModel::STATUS_UNREACHABLE): ?>
<p class="oc-icon-chain-broken"><?= __("Unreachable") ?></p>
<?php endif ?>
Expand Down
3 changes: 3 additions & 0 deletions controllers/servers/config_form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ manage_download:

manage_install:
form: $/rainlab/deploy/models/server/fields_manage_install.yaml

manage_legacy:
form: $/rainlab/deploy/models/server/fields_manage_legacy.yaml
11 changes: 9 additions & 2 deletions lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "افتح وحدة التحكم",
"Update Environment Variables": "تحديث متغيرات البيئة",
"Modify the configuration values on the server": "قم بتعديل قيم التكوين على الخادم",
"Update Config": "تحديث التكوين",
"Update Environment": "تحديث التكوين",
"View Deployment Key": "عرض مفتاح النشر",
"Display the private key used to deploy to this server": "اعرض المفتاح الخاص المستخدم للنشر على هذا الخادم",
"Show Key": "اظهر المفتاح",
"Current Version": "النسخة الحالية",
"Active": "نشيط",
"Legacy": "ميراث",
"Ready": "مستعد",
"Unreachable": "لا يمكن الوصول إليه",
"Beacon Status": "حالة منارة",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "ترحيل قاعدة البيانات",
"Building :type Archive": "المبنى: نوع الأرشيف",
"Checking Database Config": "التحقق من تكوين قاعدة البيانات",
"Setting Build Number": "تحديد رقم البنية"
"Setting Build Number": "تحديد رقم البنية",
"A Legacy Version of October CMS is Detected": "تم اكتشاف إصدار قديم من October CMS",
"Upgrade Configuration Files": "تحويل ملفات التكوين",
"Runs the artisan command to create an environment file": "يقوم بتشغيل الأمر الحرفي لإنشاء ملف بيئة",
"Upgrade Config": "تحويل التكوين",
"Upgrading Legacy Site": "ترقية الموقع القديم",
"Clearing Cache": "مسح ذاكرة التخزين المؤقت"
}
11 changes: 9 additions & 2 deletions lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Otevřete konzolu",
"Update Environment Variables": "Aktualizujte proměnné prostředí",
"Modify the configuration values on the server": "Upravte konfigurační hodnoty na serveru",
"Update Config": "Aktualizovat konfiguraci",
"Update Environment": "Aktualizovat konfiguraci",
"View Deployment Key": "Zobrazit klíč nasazení",
"Display the private key used to deploy to this server": "Zobrazit soukromý klíč použitý k nasazení na tento server",
"Show Key": "Zobrazit klíč",
"Current Version": "Současná verze",
"Active": "Aktivní",
"Legacy": "Dědictví",
"Ready": "Připraven",
"Unreachable": "Nedostupný",
"Beacon Status": "Stav majáku",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Migrace databáze",
"Building :type Archive": "Budova :type Archiv",
"Checking Database Config": "Kontrola konfigurace databáze",
"Setting Build Number": "Nastavení čísla sestavení"
"Setting Build Number": "Nastavení čísla sestavení",
"A Legacy Version of October CMS is Detected": "Byla zjištěna starší verze říjnového CMS",
"Upgrade Configuration Files": "Převést konfigurační soubory",
"Runs the artisan command to create an environment file": "Spustí příkaz řemeslník a vytvoří soubor prostředí",
"Upgrade Config": "Převést konfiguraci",
"Upgrading Legacy Site": "Aktualizace starších stránek",
"Clearing Cache": "Vymazání mezipaměti"
}
11 changes: 9 additions & 2 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Konsole öffnen",
"Update Environment Variables": "Umgebungsvariablen aktualisieren",
"Modify the configuration values on the server": "Ändern Sie die Konfigurationswerte auf dem Server",
"Update Config": "Konfiguration aktualisieren",
"Update Environment": "Konfiguration aktualisieren",
"View Deployment Key": "Bereitstellungsschlüssel anzeigen",
"Display the private key used to deploy to this server": "Zeigen Sie den privaten Schlüssel an, der für die Bereitstellung auf diesem Server verwendet wird",
"Show Key": "Schlüssel anzeigen",
"Current Version": "Aktuelle Version",
"Active": "Aktiv",
"Legacy": "Erbe",
"Ready": "Bereit",
"Unreachable": "Nicht erreichbar",
"Beacon Status": "Beacon Status",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Datenbank migrieren",
"Building :type Archive": "Gebäude :type Archiv",
"Checking Database Config": "Überprüfen der Datenbankkonfiguration",
"Setting Build Number": "Build-Nummer einstellen"
"Setting Build Number": "Build-Nummer einstellen",
"A Legacy Version of October CMS is Detected": "Eine Legacy-Version des Oktober-CMS wird erkannt",
"Upgrade Configuration Files": "Konfigurationsdateien konvertieren",
"Runs the artisan command to create an environment file": "Führt den Befehl artisan aus, um eine Umgebungsdatei zu erstellen",
"Upgrade Config": "Konvertieren Sie Konfig",
"Upgrading Legacy Site": "Aktualisieren der Legacy-Site",
"Clearing Cache": "Cache leeren"
}
11 changes: 9 additions & 2 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Consola abierta",
"Update Environment Variables": "Actualizar variables de entorno",
"Modify the configuration values on the server": "Modificar los valores de configuración en el servidor.",
"Update Config": "Actualizar configuración",
"Update Environment": "Actualizar configuración",
"View Deployment Key": "Ver clave de implementación",
"Display the private key used to deploy to this server": "Muestra la clave privada utilizada para implementar en este servidor",
"Show Key": "Mostrar clave",
"Current Version": "Versión actual",
"Active": "Activo",
"Legacy": "Legado",
"Ready": "Listo",
"Unreachable": "Inalcanzable",
"Beacon Status": "Estado de la baliza",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Migración de la base de datos",
"Building :type Archive": "Edificio type: Archivo",
"Checking Database Config": "Comprobación de la configuración de la base de datos",
"Setting Build Number": "Configuración del número de compilación"
"Setting Build Number": "Configuración del número de compilación",
"A Legacy Version of October CMS is Detected": "Se detecta una versión heredada del CMS de octubre",
"Upgrade Configuration Files": "Convertir archivos de configuración",
"Runs the artisan command to create an environment file": "Ejecuta el comando artisan para crear un archivo de entorno.",
"Upgrade Config": "Convertir configuración",
"Upgrading Legacy Site": "Actualización del sitio heredado",
"Clearing Cache": "Borrar caché"
}
11 changes: 9 additions & 2 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Ouvrez la console",
"Update Environment Variables": "Mettre à jour les variables d'environnement",
"Modify the configuration values on the server": "Modifier les valeurs de configuration sur le serveur",
"Update Config": "Mettre à jour la configuration",
"Update Environment": "Mettre à jour la configuration",
"View Deployment Key": "Afficher la clé de déploiement",
"Display the private key used to deploy to this server": "Afficher la clé privée utilisée pour déployer sur ce serveur",
"Show Key": "Afficher la touche",
"Current Version": "Version actuelle",
"Active": "actif",
"Legacy": "Héritage",
"Ready": "Prêt",
"Unreachable": "Inaccessible",
"Beacon Status": "État de la balise",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Migration de la base de données",
"Building :type Archive": "Bâtiment archive de :type",
"Checking Database Config": "Vérification de la configuration de la base de données",
"Setting Build Number": "Définition du numéro de build"
"Setting Build Number": "Définition du numéro de build",
"A Legacy Version of October CMS is Detected": "Une ancienne version du CMS d'octobre est détectée",
"Upgrade Configuration Files": "Convertir les fichiers de configuration",
"Runs the artisan command to create an environment file": "Exécute la commande artisan pour créer un fichier d'environnement",
"Upgrade Config": "Convertir la configuration",
"Upgrading Legacy Site": "Mise à niveau du site hérité",
"Clearing Cache": "Effacer le cache"
}
11 changes: 9 additions & 2 deletions lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Console aperta",
"Update Environment Variables": "Aggiorna variabili d'ambiente",
"Modify the configuration values on the server": "Modificare i valori di configurazione sul server",
"Update Config": "Aggiorna config",
"Update Environment": "Aggiorna config",
"View Deployment Key": "Visualizza chiave di distribuzione",
"Display the private key used to deploy to this server": "Visualizza la chiave privata utilizzata per la distribuzione su questo server",
"Show Key": "Mostra chiave",
"Current Version": "Versione corrente",
"Active": "Attivo",
"Legacy": "Legacy",
"Ready": "Pronto",
"Unreachable": "Irraggiungibile",
"Beacon Status": "Stato beacon",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Database in migrazione",
"Building :type Archive": "Edificio :type Archivio",
"Checking Database Config": "Controllo della configurazione del database",
"Setting Build Number": "Impostazione del numero di build"
"Setting Build Number": "Impostazione del numero di build",
"A Legacy Version of October CMS is Detected": "È stata rilevata una versione precedente di October CMS",
"Upgrade Configuration Files": "Converti file di configurazione",
"Runs the artisan command to create an environment file": "Esegue il comando artisan per creare un file di ambiente",
"Upgrade Config": "Converti configurazione",
"Upgrading Legacy Site": "Aggiornamento del sito precedente",
"Clearing Cache": "Cancellazione della cache"
}
11 changes: 9 additions & 2 deletions lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Open de console",
"Update Environment Variables": "Werk omgevingsvariabelen bij",
"Modify the configuration values on the server": "Wijzig de configuratiewaarden op de server",
"Update Config": "Update Config",
"Update Environment": "Update Environment",
"View Deployment Key": "Bekijk implementatiesleutel",
"Display the private key used to deploy to this server": "Geef de persoonlijke sleutel weer die wordt gebruikt om op deze server te implementeren",
"Show Key": "Toon sleutel",
"Current Version": "Huidige versie",
"Active": "Actief",
"Legacy": "Legacy",
"Ready": "Klaar",
"Unreachable": "Onbereikbaar",
"Beacon Status": "Bakenstatus",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Database migreren",
"Building :type Archive": "Gebouw :type Archief",
"Checking Database Config": "Databaseconfiguratie controleren",
"Setting Build Number": "Build-nummer instellen"
"Setting Build Number": "Build-nummer instellen",
"A Legacy Version of October CMS is Detected": "Er is een oudere versie van October CMS gedetecteerd",
"Upgrade Configuration Files": "Converteer configuratiebestanden",
"Runs the artisan command to create an environment file": "Voert de artisan-opdracht uit om een omgevingsbestand te maken",
"Upgrade Config": "Converteer Config",
"Upgrading Legacy Site": "Verouderde site upgraden",
"Clearing Cache": "Cache wissen"
}
11 changes: 9 additions & 2 deletions lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
"Open Console": "Открыть консоль",
"Update Environment Variables": "Обновить переменные среды",
"Modify the configuration values on the server": "Измените значения конфигурации на сервере",
"Update Config": "Обновить конфигурацию",
"Update Environment": "Обновить конфигурацию",
"View Deployment Key": "Просмотреть ключ развертывания",
"Display the private key used to deploy to this server": "Показать закрытый ключ, используемый для развертывания на этом сервере",
"Show Key": "Показать ключ",
"Current Version": "Текущая версия",
"Active": "Активный",
"Legacy": "Наследие",
"Ready": "Готов",
"Unreachable": "Недоступен",
"Beacon Status": "Статус маяка",
Expand Down Expand Up @@ -73,5 +74,11 @@
"Migrating Database": "Перенос базы данных",
"Building :type Archive": "type: тип Архив",
"Checking Database Config": "Проверка конфигурации базы данных",
"Setting Build Number": "Установка номера сборки"
"Setting Build Number": "Установка номера сборки",
"A Legacy Version of October CMS is Detected": "Обнаружена устаревшая версия October CMS",
"Upgrade Configuration Files": "Конвертировать файлы конфигурации",
"Runs the artisan command to create an environment file": "Запускает команду artisan для создания файла среды",
"Upgrade Config": "Конвертировать конфигурацию",
"Upgrading Legacy Site": "Обновление устаревшего сайта",
"Clearing Cache": "Очистка кеша"
}
Loading

0 comments on commit ae5a84b

Please sign in to comment.