Aktualizacja XenForo za pomocą CLI

Witam,

w dzisiejszym wpisie skupię się na aktualizacji XenForo za pomocą CLI. Omawiana metoda wymagana będzie najpewniej podczas aktualizacji XenForo 2.x do 2.3.

!! Przed przystąpieniem do jakiegokolwiek procesu aktualizacji upewnij się, że masz wykonaną pełnoprawną kopię zapasową swojego forum !!

Czym jest CLI?​

CLI (command-line interface) to nic innego jak wiersz poleceń stosowany w systemach operacyjnych, gdzie do pewnych zastosowań nie przewidziano interfejsu graficznego. W praktyce oznacza to fakt, że administrator/użytkownik loguje się do serwera zdalnie, np. poprzez SSH i w bezpiecznym trybie wpisywania poleceń wydaje konkretne polecenia.

Aktualizacja XenForo za pomocą CLI​

Przez większość czasu niemal każda aktualizacja XenForo możliwa była do zainstalowania poprzez panel administratora za pomocą tzw. jednego kliknięcia. Administrator forum przechodził do ustawień i stamtąd decydował o procesie aktualizacji. Twórcy XenForo nadal będą stosować tę metodę aktualizowania, niemniej jednak bywają i takie aktualizacje (oraz przypadki), gdzie pobieranie i aktualizowanie forum poprzez panel administratora nie jest zalecane a czasem nawet niemożliwe do wykonania.

Najczęściej dotyka to dużych forów, gdzie użytkowników liczy się w dziesiątkach tysięcy, a postów - w setkach tysięcy, ale bywają też i takie sytuacje, gdzie proces aktualizacji obejmuje większe zmiany, również zachodzące w bazie danych. Wtedy aktualizacja dokonywana przez panel administratora (przeglądarkę www) nie jest polecana, a często wręcz odradzana.

Jak dokonać aktualizacji za pomocą CLI?​

Łącznie z serwerem po SSH​

Jeśli sytuacja wymaga od nas przeprowadzenia aktualizacji w ten sposób, potrzebujemy przede wszystkim programu do zdalnego łączenia się z serwerem, choć nie jest to tak do końca wymagane. W systemach operacyjnych typu Windows, Linux czy MacOS wystarczy uruchomić wiersz poleceń (Windows) lub terminal (pozostałe) i skorzystać z poniższej składni:

Kod:
ssh użytkownik@serwer

1699347016050.png

jeśli połączenie zostało zainicjonowane, zostaniesz poproszony o hasło. Uwaga, wpisywane hasło nie będzie widoczne na ekranie, dlatego będziesz mieć wrażenie, że nic się nie dzieje, choć jest ono tak naprawdę wprowadzane.

Jeśli połączenia z serwerem dokonujemy po raz pierwszy, wówczas zostaniemy poproszeni o potwierdzenie uwierzytelnienia. Co więcej, możemy również w tym celu wygenerować specjalne klucze potwierdzające naszą tożsamość, jednak nie będę tego opisywać na tę chwilę, gdyż nie jest to cel tego wątku.

Innym przykładem, często polecanym jest zastosowanie darmowego programu PuTTy. Wygląda on w ten sposób:

1699346984594.png

Podobnie, jak w przykładzie z wierszem poleceń, w polu Host Name (or IP address) wprowadzamy

Kod:
użytkownik@serwer

a następnie potwierdzamy przyciskiem Open.

Lokalizacja XenForo​

XenForo instalowany na vps zwykle znajduje się w katalogu var/www z kolei na hostingach współdzielonych w domains/nazwa_domeny/public_html . Po odnalezieniu naszego forum przechodzimy do jego katalogu. Wydając polecenie ls możemy wyświetlić zawartość tego katalogu, np.

1699347974507.png

Aktualizacja​

Aktualizację XenForo dokonujemy poprzez wcześniejsze przesłanie plików oznaczonych w panelu klienta jako update, czego możemy dokonać wcześniej korzystając np. z serwera (s)ftp. Gdy to już zrobiliśmy, możemy wprowadzić polecenie php cmd.php xf:upgrade i potwierdzić. Forum zostanie zaktualizowane.

XenForo wspiera wiele innych poleceń możliwych do wykorzystania, jednak te stosowane są głównie przez deweloperów XenForo. Ich listę można znaleźć poniżej.

Kod:
Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 f                                                                         or debug

Available commands:
  help                                        Displays help for a command
  list                                        Lists commands
 known-bots
  known-bots:clear-cache                      Clears the cache of newly dectected bots
 xf
  xf:addon-disable                            [xf-addon:disable] Disables the specified add-on. If no add-on ID is                                                                          provided, all enabled add-ons will be disabled.
  xf:addon-enable                             [xf-addon:enable] Enable the specified add-on. If no add-on ID is pr                                                                         ovided, all disabled add-ons will be enabled.
  xf:addon-install                            [xf-addon:install] Installs the specified add-on
  xf:addon-rebuild                            [xf-addon:rebuild] Rebuilds the specified add-on data.
  xf:addon-uninstall                          [xf-addon:uninstall] Uninstalls the specified add-on
  xf:addon-upgrade                            [xf-addon:upgrade] Upgrades the specified add-on
  xf:convert-utf8mb4                          Converts XenForo tables to utf8mb4
  xf:file-check                               Performs a file health check
  xf:import                                   Executes an import configured via the control panel
  xf:import-finalize                          Finalize an import configured via the control panel
  xf:install                                  Installs XenForo
  xf:rebuild-master-data                      Rebuilds the core XF master data.
  xf:run-jobs                                 Runs any outstanding jobs.
  xf:style-archive-export                     Exports the specified style to an archive.
  xf:style-archive-import                     Imports a style from a specified style archive path. By default impo                                                                         rted as new style with no parent.
  xf:upgrade                                  Upgrades XenForo
 xf-addon
  xf-addon:build-release                      Performs an export of the current XML data and saves a ZIP file to _                                                                         releases
  xf-addon:bump-version                       Bumps the version of the specified add-on
  xf-addon:create                             Creates an XF add-on and writes out the basic addon.json file.
  xf-addon:export                             Exports the XML files for an add-on
  xf-addon:install-step                       Runs a specific step from the specified add-on Setup class.
  xf-addon:sync-json                          Syncs the contents of the add-on JSON file to the database, updating                                                                          the title, version and JSON hash as necessary
  xf-addon:uninstall-step                     Runs a specific step from the specified add-on Setup class.
  xf-addon:upgrade-step                       Runs a specific step from the specified add-on Setup class.
  xf-addon:validate-json                      Validates the contents of the add-on JSON file to ensure all of the                                                                          required values exist and are of the correct type.
 xf-designer
  xf-designer:archive-export                  Exports specified designer mode style to an archive for easier distr                                                                         ibution. Exported to designer mode path in the _archive directory.
  xf-designer:archive-import                  Overwrites specified designer mode style from a specified style arch                                                                         ive path.
  xf-designer:disable                         Disables designer mode on the specified style
  xf-designer:enable                          Enables designer mode on the specified style
  xf-designer:export                          Exports modified templates from the database to the file system for                                                                          the specified designer mode.
  xf-designer:export-style-properties         Exports style properties for the specified designer mode ID.
  xf-designer:export-templates                Exports templates for the specified designer mode ID.
  xf-designer:import                          Imports designer files from the file system for the specified design                                                                         er mode.
  xf-designer:import-style-properties         Imports style properties from specified designer mode files
  xf-designer:import-templates                Imports templates from specified designer mode files
  xf-designer:rebuild-metadata                Rebuilds metadata hashes based on file system content
  xf-designer:revert-template                 Reverts the specified template.
  xf-designer:sync-templates                  Syncs the contents of the template files to the DB for the specified                                                                          designer mode, applying version number updates
  xf-designer:touch-template                  Marks the specified template as modified in the specified style and                                                                          exports it.
 xf-dev
  xf-dev:class-lint                           Checks that all classes can be loaded without conflicts
  xf-dev:class-use-function                   Parses functions used within each class and adds them to a use funct                                                                         ion declaration.
  xf-dev:compare-schema                       Compares database schemas for consequential differences
  xf-dev:entity-class-properties              Applies class properties to type hint columns, getters and relations
  xf-dev:export                               Exports all data to development files
  xf-dev:export-activity-summary-definitions  Exports activity summary definitions to development files
  xf-dev:export-admin-navigation              Exports Admin navigation to development files
  xf-dev:export-admin-permissions             Exports Admin permissions to development files
  xf-dev:export-advertising-positions         Exports advertising positions to development files
  xf-dev:export-api-scopes                    Exports API scopes to development files
  xf-dev:export-bb-code-media-sites           Exports bb code media sites to development files
  xf-dev:export-bb-codes                      Exports bb codes to development files
  xf-dev:export-class-extensions              Exports class extensions to development files
  xf-dev:export-code-event-listeners          Exports code event listeners to development files
  xf-dev:export-code-events                   Exports code events to development files
  xf-dev:export-content-types                 Exports content types to development files
  xf-dev:export-cron-entries                  Exports cron entries to development files
  xf-dev:export-help-pages                    Exports help pages to development files
  xf-dev:export-member-stats                  Exports member stats to development files
  xf-dev:export-navigation                    Exports Navigation to development files
  xf-dev:export-options                       Exports options to development files
  xf-dev:export-permissions                   Exports Permissions to development files
  xf-dev:export-phrases                       Exports phrases to development files
  xf-dev:export-routes                        Exports Routes to development files
  xf-dev:export-style-properties              Exports style properties to development files
  xf-dev:export-template-modifications        Exports template modifications to development files
  xf-dev:export-templates                     Exports templates to development files
  xf-dev:export-widget-definitions            Exports widget definitions to development files
  xf-dev:export-widget-positions              Exports widget positions to development files
  xf-dev:generate-api-docs                    Generates the REST API documentation
  xf-dev:generate-entity-dw                   Generates an entity from a legacy DataWriter
  xf-dev:generate-phpstorm-meta               Generates a .phpstorm.meta.php file for dynamic return type hinting
  xf-dev:generate-schema-entity               Generates schema code from an entity
  xf-dev:import                               Imports all data from development files
  xf-dev:import-activity-summary-definitions  Imports activity summary definitions from development files
  xf-dev:import-admin-navigation              Imports admin navigation from development files
  xf-dev:import-admin-permissions             Imports admin permissions from development files
  xf-dev:import-advertising-positions         Imports advertising positions from development files
  xf-dev:import-api-scopes                    Imports API scopes from development files
  xf-dev:import-bb-code-media-sites           Imports bb code media sites from development files
  xf-dev:import-bb-codes                      Imports bb codes from development files
  xf-dev:import-class-extensions              Imports class extensions from development files
  xf-dev:import-code-event-listeners          Imports code event listeners from development files
  xf-dev:import-code-events                   Imports code events from development files
  xf-dev:import-content-types                 Imports content types from development files
  xf-dev:import-cron-entries                  Imports cron entries from development files
  xf-dev:import-help-pages                    Imports help pages from development files
  xf-dev:import-member-stats                  Imports member stats from development files
  xf-dev:import-navigation                    Imports navigation from development files
  xf-dev:import-options                       Imports options from development files
  xf-dev:import-permissions                   Imports permissions from development files
  xf-dev:import-phrases                       Imports phrases from development files
  xf-dev:import-routes                        Imports routes from development files
  xf-dev:import-style-properties              Imports style properties from development files
  xf-dev:import-template-modifications        Imports template modifications from development files
  xf-dev:import-templates                     Imports templates from development files
  xf-dev:import-widget-definitions            Imports widget definitions from development files
  xf-dev:import-widget-positions              Imports widget positions from development files
  xf-dev:metadata-clean                       Cleans up the metadata JSON files and removes missing entries
  xf-dev:metadata-fix                         Internal use only: Compare metadata files across branches in order t                                                                         o automatically fix conflicts.
  xf-dev:rebuild-caches                       Rebuilds various caches
  xf-dev:rebuild-metadata                     Rebuilds metadata hashes based on file system content
  xf-dev:recompile                            Recompiles all template/phrase data
  xf-dev:recompile-phrases                    Recompiles phrases
  xf-dev:recompile-style-properties           Recompiles style properties
  xf-dev:recompile-templates                  Recompiles parsed templates
  xf-dev:sync-templates                       Syncs the contents of the template files to the DB, applying version                                                                          number updates
  xf-dev:touch-template                       Updates the version number of the specified template
  xf-dev:update-version                       Updates the XF version to the same version as in the XF files.
  xf-dev:upgrade-step                         Runs a specific upgrade step from a specified upgrade class.
 xf-rebuild
  xf-rebuild:forums                           Rebuilds forum counters.
  xf-rebuild:search                           Rebuilds the search index.
  xf-rebuild:sitemap                          Rebuilds XML sitemap.
  xf-rebuild:stats                            Rebuilds daily statistics.
  xf-rebuild:threads                          Rebuilds thread counters.
  xf-rebuild:users                            Rebuilds user counters and caches.
 
Ostatnia edycja:
Powrót
Góra