# Update Guide

### Table of Contents

1. [Prerequisites](#prerequisites)
2. [Stop the `znnd` Service](#stop-the-znnd-service)
3. [Download the Latest `znn-controller`](#download-the-latest-znn-controller)
4. [Replace the Existing `znn-controller` File](#replace-the-existing-znn-controller-file)
5. [Deploy the Updated Controller](#deploy-the-updated-controller)
6. [Verify the Update](#verify-the-update)

***

### 1) Prerequisites

Before proceeding with the update, ensure you have the following:

* **Access Credentials**: SSH access to your server with sudo privileges.
* **Basic Knowledge**: Familiarity with command-line interfaces and server management.
* **Backup**: It's recommended to back up your current configuration and controller files before performing the update.

***

### 2) Stop the `znnd` Service

1. **Access Your Server via SSH**:<br>

   Open your terminal and connect to your server using SSH:<br>

   <pre class="language-bash"><code class="lang-bash"><strong>ssh username@your_server_ip
   </strong></code></pre>

   \
   \
   Replace `username` with your server's username (commonly `root`) and `your_server_ip` with your server's IP address.\ <br>
2. **Stop the `znnd` Service**:<br>

   Run the `znn-controller` executable and select the option to `Stop Service` the `znnd` service.<br>

   ```bash
   ./znn-controller
   ```

   * **Interactive Prompt**:<br>

     ```mathematica
     1) Deploy
     2) Status
     3) Start service
     4) Stop service
     5) Resync
     6) Help
     7) Quit
     Select an option from the ones listed above
     ```

   * **Action**:
     * Enter `4` and press `Enter` to stop the running the `znnd` service.<br>

   \
   **Note**: Ensure the service has completely stopped before proceeding to the next step. You can enter `2` and press `Enter` to verify the Status of the `znnd` service.

***

### 3) Download the Latest `znn-controller`

1. **Identify the Latest Release URL**:<br>

   Visit the [Zenon Network GitHub Repository](https://github.com/zenon-network/znn_controller_dart/releases) to find the latest version of the `znn-controller`. Copy the download URL for the x86/64 Linux release.\ <br>
2. **Download the Latest Controller**:<br>

   Replace `YOUR_LATEST_URL` with the actual URL of the latest `znn-controller` release.<br>

   ```bash
   wget -O znn_controller-linux-x86_64.zip YOUR_LATEST_URL
   ```

   \
   **Example**:<br>

   ```bash
   wget -O znn_controller-linux-x86_64.zip https://github.com/zenon-network/znn_controller_dart/releases/download/v0.0.5-beta/znn_controller-linux-x86_64.zip
   ```

***

### 4) Replace the Existing `znn-controller` File

* **Extract the Downloaded ZIP File**:<br>

  ```bash
  unzip -o znn_controller-linux-x86_64.zip
  ```

  * **`-o` Flag**: Overwrites existing files without prompting.\ <br>
* **Remove the ZIP File**:

  ```bash
  rm znn_controller-linux-x86_64.zip
  ```

***

### 5) Deploy the Updated Controller

* **Run the Updated `znn-controller`**:<br>

  ```bash
  ./znn-controller
  ```

* **Deployment Options**:<br>

  Upon execution, you will be presented with deployment options:<br>

  ```mathematica
  1) Deploy
  2) Status
  3) Start service
  4) Stop service
  5) Resync
  6) Help
  7) Quit
  Select an option from the ones listed above
  ```

* **Select Deploy Option**:
  * **Action**: Enter `1` and press `Enter` to deploy the updated controller.

* **Continue Using Existing Configuration**:<br>

  * **Prompt**:<br>

    ```mathematica
    Continue using the existing configuration? (Y/N):
    ```

  * **Action**: Enter `Y` and press `Enter` to confirm.

***

### 6) Verify the Update

* **Check the Status of the Controller**:<br>

  Run the `znn-controller` and select the status option to verify that the update was successful.<br>

  ```bash
  ./znn-controller
  ```

  * **Interactive Prompt**:<br>

    ```mathematica
    1) Deploy
    2) Status
    3) Start service
    4) Stop service
    5) Resync
    6) Help
    7) Quit
    Select an option from the ones listed above
    ```

  * **Action**: Enter `2` and press `Enter` to view the current status.
