Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on:
push:
branches:
- main
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --frozen --dev

- name: Run tests
run: uv run pytest tests -q --tb=short
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "opencloud-compose"]
path = opencloud-compose
url = https://github.com/opencloud-eu/opencloud-compose.git
[submodule "easydeploy-lib"]
path = easydeploy-lib
url = https://github.com/nordwestt/easy-deploy-lib.git
branch = main
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ This replaces the official test installer (`curl -L https://opencloud.eu/install
**Requirements:** Linux VPS, Docker Compose v2, DNS pointing at the server, ports 80/443 open.

```bash
git clone https://github.com/your-org/opencloud-easy-deploy.git
git clone --recurse-submodules https://github.com/your-org/opencloud-easy-deploy.git
cd opencloud-easy-deploy
bash ensure-dependencies.sh # Docker, uv, submodule, Python deps
bash ensure-dependencies.sh # Docker, uv, submodules, Python deps
bash wizard.sh # interactive: writes deploy.yaml and deploys
```

If you already cloned without submodules:

```bash
git submodule update --init --recursive
```

Or manually:

```bash
Expand Down
5 changes: 4 additions & 1 deletion apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"
cd "${SCRIPT_DIR}"

ensure_dependencies="false"
python_args=()
Expand All @@ -22,4 +25,4 @@ if [[ "$ensure_dependencies" == "true" ]]; then
bash "${SCRIPT_DIR}/ensure-dependencies.sh"
fi

uv run python "${SCRIPT_DIR}/scripts/apply.py" "${python_args[@]}"
exec uv run python -m scripts.apply "${python_args[@]}"
3 changes: 2 additions & 1 deletion backup-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"
cd "${SCRIPT_DIR}"

if [[ -f "${SCRIPT_DIR}/deploy.yaml" ]] && docker inspect opencloud &>/dev/null 2>&1; then
warn "OpenCloud is running — for a consistent backup, run: bash stop.sh"
fi

exec uv run python "${SCRIPT_DIR}/scripts/bundle.py" create "$@"
exec uv run python -m scripts.bundle create "$@"
5 changes: 4 additions & 1 deletion backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec uv run python "${SCRIPT_DIR}/scripts/backup.py" run "$@"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"
cd "${SCRIPT_DIR}"
exec uv run python -m scripts.backup run "$@"
1 change: 1 addition & 0 deletions diagnose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"
cd "${SCRIPT_DIR}"

COMPOSE_ENV="${SCRIPT_DIR}/opencloud-compose/.env"
DEPLOY_YAML="${SCRIPT_DIR}/deploy.yaml"
Expand Down
1 change: 1 addition & 0 deletions easydeploy-lib
Submodule easydeploy-lib added at 9285f8
97 changes: 17 additions & 80 deletions ensure-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,44 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"

export PATH="${HOME}/.local/bin:${PATH}"

run_as_root() {
if [[ "${EUID}" -eq 0 ]]; then
"$@"
elif command -v sudo &>/dev/null; then
sudo "$@"
else
die "Need root privileges for: $* — re-run with sudo or as root"
fi
}

docker_usable() {
command -v docker &>/dev/null || return 1
docker info &>/dev/null 2>&1
}

compose_usable() {
docker compose version &>/dev/null 2>&1 || command -v docker-compose &>/dev/null
}
# shellcheck source=scripts/deps_config.sh
source "${SCRIPT_DIR}/scripts/deps_config.sh"

ensure_git() {
if command -v git &>/dev/null; then
success "git present ($(git --version | head -1))"
return
fi
info "Installing git…"
if command -v apt-get &>/dev/null; then
run_as_root apt-get update -qq
run_as_root apt-get install -y git
elif command -v dnf &>/dev/null; then
run_as_root dnf install -y git
elif command -v pacman &>/dev/null; then
run_as_root pacman -Sy --noconfirm git
local manager
manager="$(detect_supported_package_manager)" || die "git is required but no supported package manager was found"
install_missing_dependencies "$manager" git
if command -v git &>/dev/null; then
success "git installed"
else
die "git is required but not installed — install git and re-run"
fi
success "git installed"
}

ensure_submodule() {
ensure_submodules() {
if [[ ! -d "${SCRIPT_DIR}/.git" ]]; then
warn "Not a git checkout — skipping submodule update"
if [[ ! -f "${SCRIPT_DIR}/opencloud-compose/docker-compose.yml" ]]; then
die "opencloud-compose is missing — clone the repo with submodules or copy opencloud-compose manually"
fi
if [[ ! -f "${SCRIPT_DIR}/easydeploy-lib/lib/init.sh" ]]; then
die "easydeploy-lib is missing — clone the repo with submodules"
fi
return
fi

if [[ -f "${SCRIPT_DIR}/opencloud-compose/docker-compose.yml" ]]; then
info "Updating opencloud-compose submodule…"
else
info "Initializing opencloud-compose submodule…"
fi
info "Initializing git submodules (opencloud-compose, easydeploy-lib)…"
git -C "${SCRIPT_DIR}" submodule update --init --recursive
success "opencloud-compose submodule ready"
}

ensure_docker() {
if docker_usable; then
success "Docker present ($(docker --version | head -1))"
else
if command -v docker &>/dev/null; then
warn "Docker is installed but the daemon is not reachable — start docker and re-run"
die "Try: sudo systemctl enable --now docker"
fi
info "Installing Docker (get.docker.com)…"
curl -fsSL https://get.docker.com | run_as_root sh
if ! docker_usable; then
if [[ "${EUID}" -ne 0 ]] && ! groups | grep -q '\bdocker\b'; then
warn "Your user is not in the docker group — log out/in after:"
warn " sudo usermod -aG docker ${USER}"
warn "Or run docker commands with sudo until then."
fi
if ! docker_usable && [[ "${EUID}" -ne 0 ]]; then
warn "Verifying Docker with sudo…"
if sudo docker info &>/dev/null 2>&1; then
success "Docker installed (use sudo docker until group membership applies)"
else
die "Docker install finished but daemon is not running"
fi
else
die "Docker install finished but daemon is not running"
fi
else
success "Docker installed"
fi
fi

if compose_usable; then
if docker compose version &>/dev/null 2>&1; then
success "Docker Compose present ($(docker compose version --short 2>/dev/null || docker compose version | head -1))"
else
success "docker-compose present"
fi
else
die "Docker Compose v2 is required — reinstall Docker or install the compose plugin"
fi
success "Git submodules ready"
}

ensure_uv() {
export PATH="${HOME}/.local/bin:${PATH}"
if command -v uv &>/dev/null; then
success "uv present ($(uv --version))"
return
Expand All @@ -121,6 +57,7 @@ ensure_uv() {
}

ensure_python_deps() {
export PATH="${HOME}/.local/bin:${PATH}"
info "Syncing Python dependencies (uv sync --dev)…"
uv sync --dev --directory "${SCRIPT_DIR}"
success "Python dependencies ready"
Expand All @@ -132,8 +69,8 @@ main() {
echo

ensure_git
ensure_submodule
ensure_docker
ensure_submodules
ensure_dependencies_installed
ensure_uv
ensure_python_deps

Expand Down
3 changes: 2 additions & 1 deletion restore-borg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ info "Installing dependencies…"
bash "${SCRIPT_DIR}/ensure-dependencies.sh"

info "Restoring from Borg repository…"
uv run python "${SCRIPT_DIR}/scripts/backup.py" fresh-restore --latest "$@"
cd "${SCRIPT_DIR}"
uv run python -m scripts.backup fresh-restore --latest "$@"

info "Starting OpenCloud stack…"
bash "${SCRIPT_DIR}/apply.sh"
Expand Down
3 changes: 2 additions & 1 deletion restore-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ info "Installing dependencies…"
bash "${SCRIPT_DIR}/ensure-dependencies.sh"

info "Restoring files from ${BUNDLE}…"
uv run python "${SCRIPT_DIR}/scripts/bundle.py" restore "$BUNDLE" --skip-apply
cd "${SCRIPT_DIR}"
uv run python -m scripts.bundle restore "$BUNDLE" --skip-apply

info "Starting OpenCloud stack…"
bash "${SCRIPT_DIR}/apply.sh"
Expand Down
13 changes: 8 additions & 5 deletions restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/scripts/lib.sh"
cd "${SCRIPT_DIR}"

if [[ "${1:-}" == "--list" ]]; then
shift
exec uv run python "${SCRIPT_DIR}/scripts/backup.py" list "$@"
exec uv run python -m scripts.backup list "$@"
fi

if [[ "${1:-}" == "--latest" ]]; then
shift
exec uv run python "${SCRIPT_DIR}/scripts/backup.py" restore --latest "$@"
exec uv run python -m scripts.backup restore --latest "$@"
fi

if [[ "${1:-}" == "--archive" ]]; then
shift
archive="${1:-}"
[[ -n "$archive" ]] || { echo "Usage: restore.sh --archive NAME [--dry-run]" >&2; exit 1; }
shift
exec uv run python "${SCRIPT_DIR}/scripts/backup.py" restore --archive "$archive" "$@"
exec uv run python -m scripts.backup restore --archive "$archive" "$@"
fi

if [[ "${1:-}" == "--dry-run" ]]; then
shift
exec uv run python "${SCRIPT_DIR}/scripts/backup.py" restore --dry-run "$@"
exec uv run python -m scripts.backup restore --dry-run "$@"
fi

cat <<EOF
Expand All @@ -40,4 +43,4 @@ After restore:
bash apply.sh && bash start.sh
EOF

exec uv run python "${SCRIPT_DIR}/scripts/backup.py" restore "$@"
exec uv run python -m scripts.backup restore "$@"
6 changes: 6 additions & 0 deletions scripts/deps_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# scripts/deps_config.sh — OpenCloud Easy Deploy dependency list (easydeploy-lib hook)

easydeploy_required_deps() {
printf '%s\n' docker docker-compose git
}
Loading
Loading