|
| 1 | +# Installation Guide |
| 2 | + |
| 3 | +## Automated Installation |
| 4 | + |
| 5 | +```bash |
| 6 | +sudo ./install.sh |
| 7 | +``` |
| 8 | + |
| 9 | +This will: |
| 10 | + |
| 11 | +- Install system dependencies |
| 12 | +- Clone repository to `/opt/relaysms/relaysms-gateway-server` |
| 13 | +- Setup Python virtualenv |
| 14 | +- Compile gRPC protos |
| 15 | +- Install and enable systemd services |
| 16 | + |
| 17 | +## Manual Installation |
| 18 | + |
| 19 | +### Install Dependencies |
| 20 | + |
| 21 | +```bash |
| 22 | +sudo apt update |
| 23 | +sudo apt install -y python3 python3-pip python3-venv python3-dev \ |
| 24 | + libmariadb-dev git curl make |
| 25 | +``` |
| 26 | + |
| 27 | +### Clone Repository |
| 28 | + |
| 29 | +```bash |
| 30 | +sudo git clone https://github.com/smswithoutborders/RelaySMS-Gateway-Server.git \ |
| 31 | + /opt/relaysms/relaysms-gateway-server |
| 32 | +cd /opt/relaysms/relaysms-gateway-server |
| 33 | +``` |
| 34 | + |
| 35 | +### Setup Python Environment |
| 36 | + |
| 37 | +```bash |
| 38 | +python3 -m venv venv |
| 39 | +venv/bin/pip install --upgrade pip |
| 40 | +venv/bin/pip install -r requirements.txt |
| 41 | +``` |
| 42 | + |
| 43 | +### Build Application |
| 44 | + |
| 45 | +```bash |
| 46 | +source venv/bin/activate |
| 47 | +make grpc-compile |
| 48 | +``` |
| 49 | + |
| 50 | +This will: |
| 51 | + |
| 52 | +- Download publisher and bridge proto files |
| 53 | +- Compile gRPC protos |
| 54 | + |
| 55 | +### Configure Environment |
| 56 | + |
| 57 | +```bash |
| 58 | +cp template.env .env |
| 59 | +vim .env |
| 60 | +``` |
| 61 | + |
| 62 | +Edit the `.env` file to configure: |
| 63 | + |
| 64 | +- Database settings (MySQL or SQLite) |
| 65 | +- Publisher gRPC connection settings |
| 66 | +- Bridge gRPC connection settings |
| 67 | +- Server ports and hosts |
| 68 | +- IMAP settings for email monitoring |
| 69 | +- FTP server settings |
| 70 | + |
| 71 | +### Initialize Runtime |
| 72 | + |
| 73 | +```bash |
| 74 | +mkdir -p data/ftp_file_store |
| 75 | +set -a && source .env && set +a |
| 76 | +# Database will be created automatically on first run |
| 77 | +``` |
| 78 | + |
| 79 | +### Install Services |
| 80 | + |
| 81 | +```bash |
| 82 | +sudo cp relaysms-gateway-server.target relaysms-gateway-server-*.service /etc/systemd/system/ |
| 83 | +sudo systemctl daemon-reload |
| 84 | +sudo systemctl enable relaysms-gateway-server.target |
| 85 | +sudo systemctl start relaysms-gateway-server.target |
| 86 | +``` |
| 87 | + |
| 88 | +## Service Management |
| 89 | + |
| 90 | +```bash |
| 91 | +./manage.sh start # Start all services |
| 92 | +./manage.sh stop # Stop all services |
| 93 | +./manage.sh restart # Restart all services |
| 94 | +./manage.sh status # Check status |
| 95 | +./manage.sh logs # View logs |
| 96 | +./manage.sh enable # Enable on boot |
| 97 | +./manage.sh disable # Disable on boot |
| 98 | +./manage.sh update # Update installation |
| 99 | +./manage.sh uninstall # Remove installation |
| 100 | +``` |
| 101 | + |
| 102 | +## Configuration |
| 103 | + |
| 104 | +Edit `/opt/relaysms/relaysms-gateway-server/.env`: |
| 105 | + |
| 106 | +### Server |
| 107 | + |
| 108 | +Configure REST API server hosts and ports: |
| 109 | + |
| 110 | +```bash |
| 111 | +# REST API |
| 112 | +HOST=127.0.0.1 |
| 113 | +PORT=5000 |
| 114 | +SSL_PORT=5001 |
| 115 | + |
| 116 | +# SSL Configuration (optional) |
| 117 | +SSL_CERTIFICATE=/path/to/certificate.crt |
| 118 | +SSL_KEY=/path/to/private.key |
| 119 | +SSL_PEM=/path/to/certificate.pem |
| 120 | +SSL_SERVER_NAME=localhost |
| 121 | +``` |
| 122 | + |
| 123 | +### Publisher Connection |
| 124 | + |
| 125 | +Configure connection to RelaySMS Publisher: |
| 126 | + |
| 127 | +```bash |
| 128 | +PUBLISHER_GRPC_HOST=127.0.0.1 |
| 129 | +PUBLISHER_GRPC_PORT=6000 |
| 130 | +``` |
| 131 | + |
| 132 | +### Bridge Connection |
| 133 | + |
| 134 | +Configure connection to RelaySMS Bridge: |
| 135 | + |
| 136 | +```bash |
| 137 | +BRIDGE_GRPC_HOST=127.0.0.1 |
| 138 | +BRIDGE_GRPC_PORT=10000 |
| 139 | +``` |
| 140 | + |
| 141 | +### Database |
| 142 | + |
| 143 | +Choose between MySQL and SQLite: |
| 144 | + |
| 145 | +**SQLite (Default):** |
| 146 | + |
| 147 | +```bash |
| 148 | +SQLITE_DATABASE_PATH=gateway_server.db |
| 149 | +# Leave MySQL settings empty |
| 150 | +``` |
| 151 | + |
| 152 | +**MySQL:** |
| 153 | + |
| 154 | +```bash |
| 155 | +MYSQL_HOST=127.0.0.1 |
| 156 | +MYSQL_USER=your_user |
| 157 | +MYSQL_PASSWORD=your_password |
| 158 | +MYSQL_DATABASE=relaysms_gateway_server |
| 159 | +# Leave SQLITE_DATABASE_PATH empty |
| 160 | +``` |
| 161 | + |
| 162 | +### IMAP Configuration |
| 163 | + |
| 164 | +Configure IMAP settings for email monitoring: |
| 165 | + |
| 166 | +```bash |
| 167 | +IMAP_SERVER=imap.example.com |
| 168 | +IMAP_PORT=993 |
| 169 | +IMAP_USERNAME=your_email@example.com |
| 170 | +IMAP_PASSWORD=your_password |
| 171 | +MAIL_FOLDER=INBOX |
| 172 | +``` |
| 173 | + |
| 174 | +### FTP Configuration |
| 175 | + |
| 176 | +Configure FTP server settings: |
| 177 | + |
| 178 | +```bash |
| 179 | +FTP_USERNAME=your_ftp_user |
| 180 | +FTP_PASSWORD=your_ftp_password |
| 181 | +FTP_IP_ADDRESS=localhost |
| 182 | +FTP_PORT=2222 |
| 183 | +FTP_PASSIVE_PORTS=60000-65000 |
| 184 | +FTP_READ_LIMIT=51200 |
| 185 | +FTP_WRITE_LIMIT=51200 |
| 186 | +FTP_MAX_CON=256 |
| 187 | +FTP_MAX_CON_PER_IP=5 |
| 188 | +FTP_DIRECTORY=data/ftp_file_store |
| 189 | +``` |
| 190 | + |
| 191 | +### Security |
| 192 | + |
| 193 | +Configure security settings: |
| 194 | + |
| 195 | +```bash |
| 196 | +SMTP_ALLOWED_EMAIL_ADDRESSES=allowed1@example.com,allowed2@example.com |
| 197 | +DISABLE_BRIDGE_PAYLOADS_OVER_HTTP=false |
| 198 | +``` |
| 199 | + |
| 200 | +### CORS |
| 201 | + |
| 202 | +Configure allowed CORS origins: |
| 203 | + |
| 204 | +```bash |
| 205 | +ORIGINS=["http://localhost:3000","https://example.com"] |
| 206 | +``` |
| 207 | + |
| 208 | +## Services |
| 209 | + |
| 210 | +- `relaysms-gateway-server-rest.service` - REST API (default port 5000, SSL port 5001) |
| 211 | +- `relaysms-gateway-server-imap.service` - IMAP Listener for email monitoring |
| 212 | +- `relaysms-gateway-server-ftp.service` - FTP Server for file transfers |
| 213 | +- `relaysms-gateway-server.target` - Service group |
| 214 | + |
| 215 | +## File Locations |
| 216 | + |
| 217 | +- Installation: `/opt/relaysms/relaysms-gateway-server/` |
| 218 | +- Configuration: `/opt/relaysms/relaysms-gateway-server/.env` |
| 219 | +- Database: `/opt/relaysms/relaysms-gateway-server/gateway_server.db` |
| 220 | +- FTP Storage: `/opt/relaysms/relaysms-gateway-server/data/ftp_file_store/` |
| 221 | +- Service files: `/etc/systemd/system/relaysms-gateway-server*` |
| 222 | + |
| 223 | +## External Dependencies |
| 224 | + |
| 225 | +### RelaySMS Publisher (Required) |
| 226 | + |
| 227 | +The Gateway Server requires a running instance of RelaySMS Publisher for publishing content to online platforms. |
| 228 | + |
| 229 | +**Installation:** |
| 230 | + |
| 231 | +See [RelaySMS Publisher Installation Guide](https://github.com/smswithoutborders/RelaySMS-Publisher/blob/main/INSTALL.md) |
| 232 | + |
| 233 | +Quick install: |
| 234 | + |
| 235 | +```bash |
| 236 | +curl -fsSL https://raw.githubusercontent.com/smswithoutborders/RelaySMS-Publisher/main/install.sh | sudo bash |
| 237 | +``` |
| 238 | + |
| 239 | +**Configuration:** |
| 240 | + |
| 241 | +Ensure the Publisher gRPC server is accessible and update the `PUBLISHER_GRPC_HOST` and `PUBLISHER_GRPC_PORT` variables in the Gateway Server's `.env` file accordingly. |
| 242 | + |
| 243 | +### RelaySMS Bridge (Required) |
| 244 | + |
| 245 | +The Gateway Server requires a running instance of RelaySMS Bridge for publishing content to email bridges. |
| 246 | + |
| 247 | +**Installation:** |
| 248 | + |
| 249 | +See [RelaySMS Bridge Installation Guide](https://github.com/smswithoutborders/RelaySMS-Bridge-Server/blob/main/INSTALL.md) |
| 250 | + |
| 251 | +**Configuration:** |
| 252 | + |
| 253 | +Ensure the Bridge gRPC server is accessible and update the `BRIDGE_GRPC_HOST` and `BRIDGE_GRPC_PORT` variables in the Gateway Server's `.env` file accordingly. |
| 254 | + |
| 255 | +### IMAP Email Server (Optional) |
| 256 | + |
| 257 | +If you want to use the IMAP listener feature, you'll need access to an email account with IMAP enabled. |
| 258 | + |
| 259 | +**Gmail Setup:** |
| 260 | + |
| 261 | +1. Enable IMAP in Gmail settings |
| 262 | +2. Create an App Password: |
| 263 | + - Visit: <https://myaccount.google.com/apppasswords> |
| 264 | + - Sign in with your Google account |
| 265 | + - Select "Mail" as the app and "Other" as the device |
| 266 | + - Generate an app password |
| 267 | +3. Use the generated app password as `IMAP_PASSWORD` in `.env` |
| 268 | + |
| 269 | +**Other Email Providers:** |
| 270 | + |
| 271 | +Consult your email provider's documentation for IMAP server details and authentication requirements. |
0 commit comments