|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Path configuration |
| 4 | +TOKEN_FILE="/path/to/hand_of_morpheus/.registration_token" |
| 5 | +LOG_FILE="/path/to/hand_of_morpheus/token_refresh.log" |
| 6 | + |
| 7 | +# Function to log with timestamp |
| 8 | +log() { |
| 9 | + echo "$(date --iso-8601=seconds) $1" >> "$LOG_FILE" |
| 10 | +} |
| 11 | + |
| 12 | +# Generate new token (32 random hex characters) |
| 13 | +NEW_TOKEN=$(openssl rand -hex 16) |
| 14 | + |
| 15 | +# Write new token to file |
| 16 | +echo "$NEW_TOKEN" > "$TOKEN_FILE" |
| 17 | +if [ $? -ne 0 ]; then |
| 18 | + log "ERROR: Failed to write new token to $TOKEN_FILE" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +log "Generated new registration token" |
| 23 | + |
| 24 | +# Recreate conduwuit container |
| 25 | +docker stop conduwuit |
| 26 | +docker rm conduwuit |
| 27 | + |
| 28 | +docker run -d \ |
| 29 | + -p 127.0.0.1:8448:6167 \ |
| 30 | + -v db:/var/lib/conduwuit/ \ |
| 31 | + -v /path/to/hand_of_morpheus/.registration_token:/registration_token:ro \ |
| 32 | + -e CONDUWUIT_SERVER_NAME="your.domain" \ |
| 33 | + -e CONDUWUIT_DATABASE_PATH="/var/lib/conduwuit/conduwuit.db" \ |
| 34 | + -e CONDUWUIT_DATABASE_BACKUP_PATH="/var/lib/conduwuit/backup" \ |
| 35 | + -e CONDUWUIT_ALLOW_REGISTRATION=true \ |
| 36 | + -e CONDUWUIT_REGISTRATION_TOKEN_FILE="/registration_token" \ |
| 37 | + -e CONDUWUIT_PORT=6167 \ |
| 38 | + -e CONDUWUIT_ADDRESS="0.0.0.0" \ |
| 39 | + -e CONDUWUIT_NEW_USER_DISPLAYNAME_SUFFIX="" \ |
| 40 | + -e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_OVER_FEDERATION=true \ |
| 41 | + -e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_WITHOUT_AUTH=true \ |
| 42 | + -e CONDUWUIT_ALLOW_FEDERATION=true \ |
| 43 | + -e CONDUWUIT_AUTO_JOIN_ROOMS='["#community:your.domain","#welcome:your.domain"]' \ |
| 44 | + --name conduwuit \ |
| 45 | + --restart unless-stopped \ |
| 46 | + ghcr.io/girlbossceo/conduwuit:v0.5.0-rc2-e5049cae4a3890dc5f61ead53281f23b36bf4c97 |
| 47 | + |
| 48 | +if [ $? -ne 0 ]; then |
| 49 | + log "ERROR: Failed to create new conduwuit container" |
| 50 | + exit 1 |
| 51 | +fi |
| 52 | + |
| 53 | +log "Successfully recreated conduwuit container with new token" |
0 commit comments