# open-autosecure

### Unstable Instance

> **May not even function properly but you are free to help improvise it.**
> 
> Bug reports are private by nature: submit reports via [https://sten.wtf/open-autosecure/bugs](https://sten.wtf/open-autosecure/bugs).

Self-hosted Discord bot for Microsoft/Minecraft account securing. Python 3.10+ on
Windows, macOS, Linux, and other Unix.

## Install

```text
git clone <this-repo> open-autosecure
cd open-autosecure
python3 -m venv .venv
```

Activate the venv, then install deps:

| OS | Activate | Then |
| --- | --- | --- |
| Linux / macOS / BSD | `source .venv/bin/activate` | `pip install -r requirements.txt` |
| Windows (cmd) | `.venv\Scripts\activate.bat` | `pip install -r requirements.txt` |
| Windows (PowerShell) | `.venv\Scripts\Activate.ps1` | `pip install -r requirements.txt` |

You can skip activate and call the venv interpreter directly (`.venv/bin/python` or `.venv\Scripts\python.exe`).

## Run

Same commands on every OS (use the venv `python` / `python.exe`):

```text
python setup.py    # wizard: bot token, guild, role, IMAP, proxy
                   # re-run to edit proxy/mail or add another bot
python -m bot      # start the instance
```

Or the wrappers, which pick the venv interpreter if present:

```text
./start.sh                 # Linux / macOS / BSD
./start.sh setup

start.cmd                  # Windows
start.cmd setup
```

The SQLite file defaults to `db/open_autosecure.db` **next to this repo**, not the
current working directory, so Task Scheduler / launchd / systemd don't drop a
database in `C:\Windows\System32` or `/`. Override with `OAS_DB_PATH` (relative
paths are also rooted at the repo). See `.env.example`.

## Run at boot

| OS | Unit |
| --- | --- |
| Linux (systemd) | [`systemd/open-autosecure.service.example`](systemd/open-autosecure.service.example) |
| macOS (launchd) | [`launchd/com.open-autosecure.plist.example`](launchd/com.open-autosecure.plist.example) |
| Windows | [`windows/install-task.ps1`](windows/install-task.ps1) |

Copy the example, set the install path, then:

```text
# Linux
sudo cp systemd/open-autosecure.service.example /etc/systemd/system/open-autosecure.service
sudo systemctl daemon-reload
sudo systemctl enable --now open-autosecure

# macOS
cp launchd/com.open-autosecure.plist.example ~/Library/LaunchAgents/com.open-autosecure.plist
launchctl load ~/Library/LaunchAgents/com.open-autosecure.plist

# Windows (elevated PowerShell)
powershell -ExecutionPolicy Bypass -File windows\install-task.ps1
```

Anywhere else, point a supervisor at `python -m bot` with the repo as the working directory.

