SHA256
Обновить HEADER, теги CORE и конфигурацию основного сервера
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Подготавливает отдельный production-инстанс на общем VPS без запуска Java.
|
||||
REMOTE_HOST="${REMOTE_HOST:-player@t2.shineup.me}"
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
ssh "$REMOTE_HOST" 'python3 -' <<'PY'
|
||||
from pathlib import Path
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
import os, shutil, subprocess
|
||||
|
||||
base = Path('/home/player/SHiNE/main')
|
||||
server = base / 'server'
|
||||
ui = base / 'UI'
|
||||
for path in (base, server, ui, server / 'data', server / 'logs'):
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
base.chmod(0o711) # Caddy должен проходить к UI, не читая закрытые файлы.
|
||||
secret = {}
|
||||
for line in (base / 'postgres.env').read_text().splitlines():
|
||||
if '=' in line:
|
||||
k, v = line.split('=', 1)
|
||||
secret[k] = v
|
||||
source = Path('/home/player/t2/server/application.properties')
|
||||
entries = []
|
||||
values = {}
|
||||
for line in source.read_text().splitlines():
|
||||
if '=' in line and not line.lstrip().startswith('#'):
|
||||
k, v = line.split('=', 1)
|
||||
k = k.strip()
|
||||
entries.append(k)
|
||||
values[k] = v.strip()
|
||||
key = parse_qs(urlparse(values['solana.rpcUrl']).query)['api-key'][0]
|
||||
values.update({
|
||||
'server.port': '7105',
|
||||
'db.url': 'jdbc:postgresql://127.0.0.1:5432/shine_main_db',
|
||||
'db.user': 'shine_main',
|
||||
'db.password': secret['DB_PASSWORD'],
|
||||
'db.path': 'data/shine.sqlite',
|
||||
'solana.cluster': 'mainnet-beta',
|
||||
'solana.rpcUrl': 'https://mainnet.helius-rpc.com/?api-key=' + key,
|
||||
'server.info.url': 'https://shineup.me',
|
||||
'server.info.description': 'Основной сервер SHiNE',
|
||||
'server.info.origin': 'mainnet-beta',
|
||||
'server.ui.indexPath': str(ui / 'index.html'),
|
||||
'solana.users.sync.rpcUrl': 'https://mainnet.helius-rpc.com/?api-key=' + key,
|
||||
'solana.users.sync.wsUrl': 'wss://mainnet.helius-rpc.com/?api-key=' + key,
|
||||
'solana.users.sync.databaseUrl': 'jdbc:postgresql://127.0.0.1:5432/shine_main_db',
|
||||
'solana.users.sync.dbUser': 'shine_main',
|
||||
'solana.users.sync.dbPassword': secret['DB_PASSWORD'],
|
||||
'server.SHiNE.login': 'shineupme@shine',
|
||||
'test.freeAvatar.enabled': 'false',
|
||||
'archive.publish.enabled': 'false',
|
||||
'arweave.blocks.publish.enabled': 'false',
|
||||
'freeRegistration.enabled': 'false',
|
||||
'freeRegistration.email.allowTestCode': 'false',
|
||||
'freeRegistration.email.allowReuse': 'false',
|
||||
})
|
||||
for k in list(values):
|
||||
if k.startswith(('test.freeAvatar.wallet', 'archive.arweave.wallet', 'archive.solana.rootKey',
|
||||
'archive.solana.clientKey', 'arweave.blocks.publish.wallet',
|
||||
'arweave.blocks.publish.turbo.wallet', 'arweave.blocks.publish.turbo.paidBy',
|
||||
'freeRegistration.registrarSeed', 'call.ice.turn')):
|
||||
values[k] = ''
|
||||
target = server / 'application.properties'
|
||||
if target.exists():
|
||||
raise SystemExit('Existing production application.properties; refusing to overwrite')
|
||||
target.write_text('\n'.join(k + '=' + values[k] for k in entries) + '\n')
|
||||
target.chmod(0o600)
|
||||
for name in ('shine-server.jar', 'allowed-email-domains.txt'):
|
||||
shutil.copy2(source.parent / name, server / name)
|
||||
print('Production server files prepared; Java service not started')
|
||||
PY
|
||||
|
||||
ssh "$REMOTE_HOST" 'sudo -n tee /etc/systemd/system/shine-main.service >/dev/null' <<'EOF'
|
||||
[Unit]
|
||||
Description=SHiNE Server (shineup.me)
|
||||
After=network.target docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=player
|
||||
Group=player
|
||||
WorkingDirectory=/home/player/SHiNE/main/server
|
||||
ExecStart=/usr/bin/java -Dserver.port=7105 -jar /home/player/SHiNE/main/server/shine-server.jar
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
ssh "$REMOTE_HOST" 'sudo -n systemctl daemon-reload; sudo -n systemctl disable shine-main.service >/dev/null 2>&1 || true'
|
||||
Reference in New Issue
Block a user