# Update and Uninstall

- Link: https://ubient.dscloud.biz/docs/ubient-software/rtmn/update-and-uninstall/
- Published: 2026-10-13T01:36:59+09:00
- Author: Ubient

## Rotate the Token for a Single Instance

For the default single-instance installation, use `rotate-token`.

    ```ubient-docs-code
    Bashsudo bash -c '
    read -r -s -p "New Telegram bot token: " RTMN_TELEGRAM_TOKEN
    echo
    export RTMN_TELEGRAM_TOKEN
    exec /usr/local/bin/rtmn rotate-token
    '
    ```

This command validates the new token, rewrites the environment file atomically, 
and restarts the service. If restart fails, it rolls back to the previous token.

## Rotate the Token for an Account-Isolated Instance

For account-isolated installations, edit only that instance’s environment file and
restart only that service.

    ```ubient-docs-code
    Bashsudoedit "/etc/rtmn/env-$INSTANCE"
    sudo systemctl restart "rtmn-$INSTANCE.service"
    sudo systemctl status "rtmn-$INSTANCE.service" --no-pager
    ```

The default `rtmn rotate-token` command targets the default single-instance layout.
Do not use it for account-isolated services unless the binary version explicitly
supports selecting the service name and environment file.

## Update an Account-Isolated Binary

Stop only the target instance, replace that account’s binary, then start the service
again.

    ```ubient-docs-code
    Bashsudo systemctl stop "rtmn-$INSTANCE.service"
    sudo install -o "$ACCOUNT" -g "$GROUP" -m 0755 "$BINARY_SOURCE" "/home/$ACCOUNT/.rtmn-$INSTANCE/rtmn-$INSTANCE"
    sudo systemctl start "rtmn-$INSTANCE.service"
    sudo systemctl status "rtmn-$INSTANCE.service" --no-pager
    ```

## Uninstall a Single Instance

    ```ubient-docs-code
    Bashsudo /usr/local/bin/rtmn uninstall
    sudo /usr/local/bin/rtmn uninstall -purge
    ```

`uninstall` removes only the service. `uninstall -purge` also removes the environment
file, logs, and installed binary.

## Uninstall an Account-Isolated Instance

Remove one instance without touching other account-specific services.

    ```ubient-docs-code
    Bashsudo systemctl disable --now "rtmn-$INSTANCE.service"
    sudo rm -f "/etc/systemd/system/rtmn-$INSTANCE.service"
    sudo systemctl daemon-reload
    ```

Only after confirming the instance is no longer needed, optionally clean up its 
files:

    ```ubient-docs-code
    Bashsudo rm -f "/etc/rtmn/env-$INSTANCE"
    sudo rm -rf "/var/log/rtmn/$INSTANCE"
    sudo rm -rf "/home/$ACCOUNT/.rtmn-$INSTANCE"
    ```

Do not delete shared accounts, unrelated environment files, or other `rtmn-*` services.
