Initial commit
This commit is contained in:
27
deploy/scripts/deploy_client.sh
Executable file
27
deploy/scripts/deploy_client.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="${1:-/home/bestmidi/chgrid}"
|
||||
PUBLISH_DIR="${2:-/home/bestmidi/public_html/chgrid}"
|
||||
BASE_PATH="${3:-/chgrid/}"
|
||||
CLIENT_DIR="$REPO_ROOT/client"
|
||||
|
||||
if [[ ! -d "$CLIENT_DIR" ]]; then
|
||||
echo "error: client directory not found: $CLIENT_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "error: rsync is required but not found in PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$CLIENT_DIR"
|
||||
npm install
|
||||
VITE_BASE_PATH="$BASE_PATH" npm run build
|
||||
|
||||
mkdir -p "$PUBLISH_DIR"
|
||||
rsync -a --delete dist/ "$PUBLISH_DIR/"
|
||||
|
||||
echo "client deploy complete: $PUBLISH_DIR"
|
||||
echo "client base path: $BASE_PATH"
|
||||
41
deploy/scripts/install_apache.sh
Executable file
41
deploy/scripts/install_apache.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="${1:-/home/bestmidi/chgrid}"
|
||||
INCLUDE_PATH="${2:-}"
|
||||
RESTART_CMD="${3:-/usr/local/cpanel/scripts/restartsrv_httpd}"
|
||||
SNIPPET_PATH="$REPO_ROOT/deploy/apache/chgrid-vhost-snippet.conf"
|
||||
|
||||
if [[ -z "$INCLUDE_PATH" ]]; then
|
||||
echo "usage: $0 <repo_root> <apache_include_path> [restart_cmd]" >&2
|
||||
echo "example: $0 /home/bestmidi/chgrid /etc/apache2/conf.d/userdata/ssl/2_4/bestmidi/example.com/chgrid.conf" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$SNIPPET_PATH" ]]; then
|
||||
echo "error: snippet not found: $SNIPPET_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo mkdir -p "$(dirname "$INCLUDE_PATH")"
|
||||
sudo cp "$SNIPPET_PATH" "$INCLUDE_PATH"
|
||||
|
||||
echo "installed apache include: $INCLUDE_PATH"
|
||||
|
||||
if [[ -x /usr/local/cpanel/scripts/rebuildhttpdconf ]]; then
|
||||
sudo /usr/local/cpanel/scripts/rebuildhttpdconf
|
||||
else
|
||||
echo "warning: /usr/local/cpanel/scripts/rebuildhttpdconf not found; skipping rebuild" >&2
|
||||
fi
|
||||
|
||||
if [[ -x "$RESTART_CMD" ]]; then
|
||||
sudo "$RESTART_CMD"
|
||||
elif [[ -x /scripts/restartsrv_httpd ]]; then
|
||||
sudo /scripts/restartsrv_httpd
|
||||
else
|
||||
echo "error: apache restart command not found" >&2
|
||||
echo "tried: $RESTART_CMD and /scripts/restartsrv_httpd" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "apache include applied and apache restarted"
|
||||
53
deploy/scripts/install_server.sh
Executable file
53
deploy/scripts/install_server.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="${1:-/home/bestmidi/chgrid}"
|
||||
SERVER_DIR="$REPO_ROOT/server"
|
||||
PYTHON_SPEC="${PYTHON_SPEC:-3.13}"
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "error: uv is required but not found in PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$SERVER_DIR" ]]; then
|
||||
echo "error: server directory not found: $SERVER_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$SERVER_DIR/pyproject.toml" ]]; then
|
||||
echo "error: missing $SERVER_DIR/pyproject.toml" >&2
|
||||
echo " verify repository files were copied to /home/bestmidi/chgrid/server" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$SERVER_DIR"
|
||||
|
||||
# Avoid interactive prompts: reuse existing venv; create only when missing.
|
||||
if [[ ! -d .venv ]]; then
|
||||
uv venv .venv --python "$PYTHON_SPEC"
|
||||
echo "created .venv with Python $PYTHON_SPEC"
|
||||
else
|
||||
echo "using existing .venv"
|
||||
fi
|
||||
|
||||
if [[ -x .venv/bin/python ]]; then
|
||||
VENV_PYTHON_VERSION="$(
|
||||
.venv/bin/python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")'
|
||||
)"
|
||||
if [[ "$VENV_PYTHON_VERSION" != "$PYTHON_SPEC" ]]; then
|
||||
echo "warning: .venv uses Python $VENV_PYTHON_VERSION (requested $PYTHON_SPEC)" >&2
|
||||
echo " remove .venv and rerun script to recreate with Python $PYTHON_SPEC" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
uv sync --no-dev --project "$SERVER_DIR"
|
||||
|
||||
if [[ ! -f config.toml ]]; then
|
||||
cp config.example.toml config.toml
|
||||
echo "created $SERVER_DIR/config.toml from template"
|
||||
fi
|
||||
|
||||
mkdir -p runtime
|
||||
|
||||
echo "server install complete"
|
||||
echo "next: edit $SERVER_DIR/config.toml (TLS, bind_ip, port)"
|
||||
18
deploy/scripts/install_service.sh
Executable file
18
deploy/scripts/install_service.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="${1:-/home/bestmidi/chgrid}"
|
||||
UNIT_NAME="${2:-chgrid-signaling.service}"
|
||||
SRC_UNIT="$REPO_ROOT/deploy/systemd/$UNIT_NAME"
|
||||
DST_UNIT="/etc/systemd/system/$UNIT_NAME"
|
||||
|
||||
if [[ ! -f "$SRC_UNIT" ]]; then
|
||||
echo "error: unit file not found: $SRC_UNIT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo cp "$SRC_UNIT" "$DST_UNIT"
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now "$UNIT_NAME"
|
||||
sudo systemctl restart "$UNIT_NAME"
|
||||
sudo systemctl status "$UNIT_NAME" --no-pager
|
||||
Reference in New Issue
Block a user