Files
NetBox-Updater/README.md
T
2026-10-26 20:58:16 +01:00

82 lines
2.6 KiB
Markdown

# NetBox Updater
Automated upgrade script for self-hosted NetBox installations under
`/opt/netbox`.
| | |
|---|---|
| **Type** | Bash script |
| **Platform** | Linux server running NetBox |
| **Repository** | <https://git.mrblake.cc/MrBlake/NetBox-Updater> |
## Features
- Downloads and extracts the requested NetBox release
- Carries over `configuration.py`, `ldap_config.py`, `media/`, `scripts/`,
`reports/` and `gunicorn.py`
- Carries over or creates `local_requirements.txt` (plugins), adding
`django-auth-ldap` automatically when an LDAP configuration is detected
- Swaps directories (`netbox` → `netbox_old`, new release → `netbox`)
- Runs NetBox's `upgrade.sh`
## Requirements
- Root privileges (`sudo`)
- An existing installation under `/opt/netbox`
- `wget`, `tar` and `curl`
- Neither `/opt/netbox_old` nor `/opt/netbox-<version>` may exist; the script
aborts otherwise so nothing is overwritten
## Usage
Download and run in one step, passing the target version without a leading `v`:
```bash
curl -fsSL https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh | sudo bash -s -- 4.1.5
```
Or with `wget`:
```bash
wget -qO- https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh | sudo bash -s -- 4.1.5
```
Replace `4.1.5` with the desired target version (see
[NetBox releases](https://github.com/netbox-community/netbox/releases)).
To review the script before running it, download it first:
```bash
wget https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh
chmod +x upgrade.sh
sudo ./upgrade.sh 4.1.5
```
### Steps in detail
1. **Download**: fetches `vX.Y.Z.tar.gz` from GitHub and extracts it to
`/opt/netbox-X.Y.Z`.
2. **Copy**: transfers configuration, media, scripts, reports and, if present,
`gunicorn.py` from the existing installation.
3. **Plugins**: copies `local_requirements.txt` from `/opt/netbox`. If none
exists, a default list is created (editable in the script). If
`ldap_config.py` exists, `django-auth-ldap` is added automatically.
4. **Pause for review**: the script stops and asks you to check
`CSRF_TRUSTED_ORIGINS` in the new `configuration.py` (Enter to continue,
Ctrl+C to abort).
5. **Directory swap**: `/opt/netbox` → `/opt/netbox_old`,
`/opt/netbox-X.Y.Z` → `/opt/netbox`.
6. **Upgrade**: runs `/opt/netbox/upgrade.sh`.
7. **Clean-up**: deletes the downloaded tarball.
### After the upgrade
- Test NetBox: login, plugins and LDAP if used.
- If something is wrong, roll back: the previous installation is kept under
`/opt/netbox_old`.
- Once everything works, remove the old installation:
```bash
sudo rm -rf /opt/netbox_old
```