### Installation and Updates

# Installation and Updates #

## Deploy from Pre-compiled Files #

Download the binary file for your platform from the Release page.

Create a `config.toml` file in the extracted directory, refer to the Configuration Guide to edit the configuration file.

Run:

    chmod +x saveany-bot
    ./saveany-bot

### Process Monitoring #

systemd (Regular Linux)
Create a file `/etc/systemd/system/saveany-bot.service` and write the following content:

    [Unit]
    Description=SaveAnyBot
    After=systemd-user-sessions.service

    [Service]
    Type=simple
    WorkingDirectory=/yourpath/
    ExecStart=/yourpath/saveany-bot
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

Enable startup on boot and start the service:

    systemctl enable --now saveany-bot

procd (OpenWrt)

#### Add Boot Autostart Service

Create a file `/etc/init.d/saveanybot`, refer to wrt_init and modify as needed:

    #!/bin/sh /etc/rc.common

    #This is the OpenWRT init.d script for SaveAnyBot

    START=99
    STOP=10
    description=&#34;SaveAnyBot&#34;

    WORKING_DIR=&#34;/mnt/mmc1-1/SaveAnyBot&#34;
    EXEC_PATH=&#34;$WORKING_DIR/saveany-bot&#34;
    start() {
        echo &#34;Starting SaveAnyBot...&#34;
        cd $WORKING_DIR
        $EXEC_PATH &amp;
    }
    stop() {
        echo &#34;Stopping SaveAnyBot...&#34;
        killall saveany-bot
    }
    reload() {
        stop
        start
    }

Set permissions:

    chmod +x /etc/init.d/saveanybot

Then copy the file to `/etc/rc.d` and rename it to `S99saveanybot`, also set permissions:

    chmod +x /etc/rc.d/S99saveanybot

#### Add Shortcut Commands

Create a file `/usr/bin/sabot`, refer to wrt_bin and modify as needed. Note that the file encoding here only supports ANSI 936. Then set permissions:

    chmod +x /usr/bin/sabot

Usage: `sudo sabot start|stop|restart|status|enable|disable`

## Deploy Using Docker #

### Docker Compose #

Download the docker-compose.yml file, create a new `config.toml` file in the same directory, refer to config.example.toml to edit the configuration file.

Start:

    docker compose up -d

### Docker #

    docker run -d --name saveany-bot \
        -v /path/to/config.toml:/app/config.toml \
        -v /path/to/downloads:/app/downloads \
        ghcr.io/krau/saveany-bot:latest

## Updates #

Use `upgrade` or `up` to upgrade to the latest version

    ./saveany-bot upgrade

If you deployed with Docker, use the following commands to update:

    docker pull ghcr.io/krau/saveany-bot:latest
    docker restart saveany-bot