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
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ secrets
.gitignore
LICENSE
README.md
install-util.sh
install.sh
CHANGELOG
docker-compose.yml.example
docker-compose.example.yml
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Bug report
description: Create a report to help us improve
title: "[BUG]: "
labels: ['Type: Bug', 'Status: Needs Triage']
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an open or closed issue already exists for the feature you are requesting. If a request exists and is closed note that it may only be fixed in an unstable branch.
options:
- label: I have searched the existing open and closed issues
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: |
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem.
validations:
required: false
- type: input
attributes:
label: OS
description: e.g. Linux
validations:
required: false
- type: input
attributes:
label: Version
description: e.g. 22
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here.
validations:
required: false
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Feature Request
description: Suggest an idea for this project
title: "[FEAT]: "
labels: ['Type: Feature', 'Status: Needs Triage']
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an open or closed issue already exists for the feature you are requesting. If a request exists and is closed note that it may only be fixed in an unstable branch.
options:
- label: I have searched the existing open and closed issues
required: true
- type: textarea
attributes:
label: Is your feature request related to a problem? Please describe
description: A clear and concise description of what the problem is.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Mockups? Anything that will give us more context about the feature you are encountering!

Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: true
17 changes: 17 additions & 0 deletions .github/workflows/integration-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Integration Test Dev Branch with Server

on:
push:
branches:
- dev
pull_request:

jobs:
integration-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: MediaGarrd/MediaGarrd-Stack-Testing@main
with:
server-branch: dev
client-branch: ${{ github.head_ref || github.ref_name }}
16 changes: 16 additions & 0 deletions .github/workflows/integration-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Integration Test Main Branch with Server

on:
push:
branches:
- main

jobs:
integration-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: MediaGarrd/MediaGarrd-Stack-Testing@main
with:
server-branch: main
client-branch: main
55 changes: 55 additions & 0 deletions .github/workflows/issue_handling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Handle duplicate status label

on:
issues:
types: [labeled, unlabeled]

jobs:
correct-status-labels:
runs-on: ubuntu-latest
steps:
- name: Ensure one Status label per issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.MEDIAGARRD_CLIENT_ACTIONS_TOKEN }}
script: |
const issueNumber = context.payload.issue.number;
const statusLabelsToCheck = [
"Status: Needs Triage",
"Status: Approved",
"Status: Waiting on Child Issues",
"Status: Waiting on Server Update"
];

const existingLabels = context.payload.issue.labels.map(label => label.name);
const existingStatusLabels = existingLabels.filter(label => statusLabelsToCheck.includes(label));
const addedLabel = context.payload.action === "labeled" ? context.payload.label.name : null;

let keep = null;
if (statusLabelsToCheck.includes(addedLabel)) {
keep = addedLabel;
} else if (existingStatusLabels.length == 1) {
keep = existingStatusLabels[0];
}

for (const label of existingStatusLabels.filter(label => label !== keep)) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
name: label
});
console.log(`Removed label "${label}" from issue #${issueNumber}`);
}

if (keep) {
console.log(`Status label: "${keep}" is set correctly`);
} else {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ["Status: Needs Triage"]
});
}

46 changes: 46 additions & 0 deletions .github/workflows/pr_handling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Require approved issue

on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
require-approved-issue:
if: github.head_ref != 'dev'
runs-on: ubuntu-latest
permissions:
issues: read
pull-requests: read
steps:
- name: Ensure every linked issue is approved
uses: actions/github-script@v7
with:
script: |
const { repository } = await github.graphql(`
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
closingIssuesReferences(first: 25) {
nodes { number labels(first: 25) { nodes { name } } }
}
}
}
}`, {
owner: context.repo.owner,
repo: context.repo.repo,
number: context.payload.pull_request.number
});

const issues = repository.pullRequest.closingIssuesReferences.nodes;
if (issues.length === 0) {
core.setFailed("Link the approved issue this pull request resolves, e.g. \"Closes #12\" in the description");
return;
}

const unapproved = issues.filter(issue => !issue.labels.nodes.some(label => label.name === "Status: Approved"));
if (unapproved.length > 0) {
core.setFailed(`Linked issues without "Status: Approved": ${unapproved.map(issue => `#${issue.number}`).join(", ")}`);
return;
}

console.log(`All linked issues are approved: ${issues.map(issue => `#${issue.number}`).join(", ")}`);
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.gradle
.settings/
build
gradle/
**/.settings/
**/.project
**/.classpath
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# CHANGELOG

## 10-26-26
- Finished renaming the codebase to MediaGarrd
- Added issue templates, issue label and pull request workflows, and integration test workflows
- Added a `Makefile` with a `test` target
- Removed `install.sh`: `docker-compose.example.yml` now works as-is, the container keeps its downloads and state on the mounted volumes by default, and everything else is set from the web page
- `MEDIAGARRD_SERVER_PORT` now defaults to `38471` to match the server, and `MEDIAGARRD_SERVER_IP` is optional and accepts `<ip>:<port>`
- The client connects to `MEDIAGARRD_SERVER_IP` on its own at startup and keeps trying every 30 seconds until a server is selected, so scheduled pickups work without opening the web page
- Added a Server Config view, opened from the toggle in the top bar, that changes the connected server's backup location, interval, and retention count and adds, edits, and removes its services
- Split the web page into an HTML page, a stylesheet, and JavaScript modules
- Every API endpoint now returns errors as `{"error": "..."}`, passing on the server's own message and status code when the server rejects a request
- Fixed the server schedule being sent as a number of seconds instead of an ISO-8601 duration
- The Gradle wrapper is now committed so the project builds without a local Gradle install
- Network discovery finishes in a couple of seconds instead of minutes: it checks for an open port before making an HTTP request, probes many hosts at once, skips Docker and VPN interfaces, and only counts servers that answer with a MediaGarrd health response
- Connecting by IP accepts `host:port`, stops right away when the host is unreachable, and scans every port of a reachable host in about a second
- Fixed the connection badge being overwritten by the periodic health check while a scan or connection attempt is running
- The badge and status panel show when the selected server is not responding, the backup list says why it could not be loaded, and everything reloads on its own when the server comes back
- The backup list reloads when a backup run started elsewhere finishes, and the Dashboard shows saved server settings as soon as you switch back to it
- "Scan Local Network" reports how many servers the scan actually found
- Requests to the server now time out instead of hanging when it is unreachable, and health checks pause while the page is hidden
- Starting a download of a backup that is already downloading reuses the running download instead of writing the same file twice
- Unknown backups and download tasks return 404, invalid pickup intervals and server URLs return 400, and finished download tasks are forgotten after 10 minutes
- Backup file names from the server can no longer write outside the download directory
- The client state file is written atomically so a crash cannot leave it half written
- Removed unused code and dependencies
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM gradle:9.4.0-jdk21 AS build
WORKDIR /workspace
COPY . .
RUN gradle :bootJar --no-daemon
RUN --mount=type=cache,target=/home/gradle/.gradle gradle :bootJar --no-daemon --stacktrace --info --warning-mode all

FROM eclipse-temurin:21-jre
WORKDIR /app
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: test

test:
./gradlew test --warning-mode all

35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,46 @@

This is the official client for [MediaGarrd](https://github.com/MediaGarrd/MediaGarrd).

## Requirements
- Docker with Compose v2 (`docker compose ...`)
- A running [MediaGarrd Server](https://github.com/MediaGarrd/Server) that has finished its first-time setup

## Installation
```bash
git clone --depth 1 https://github.com/MediaGarrd/Client.git
cd Client
./install.sh # Drops .env, client.env, and docker-compose.yml
cp docker-compose.example.yml docker-compose.yml
docker compose up --build -d
```

Then open `http://<client-host>:8081`.

The defaults in `docker-compose.yml` work as-is. To change them before the first start:
- **Port:** change both `CLIENT_PORT` and the `ports` mapping (default `8081`).
- **Where downloaded backups are stored on the host:** change the left side of the `./data/client/downloads` volume.
- **Where the client keeps its state on the host:** change the left side of the `./data/client/state` volume. This holds the selected server, known servers, and pickup interval, so keep it on persistent storage.
- **Server port to look for:** `MEDIAGARRD_SERVER_PORT` (default `38471`, the server's default). Discovery and "Connect by IP" try this port first.
- **Connect to a server automatically:** add `MEDIAGARRD_SERVER_IP=<server-ip>` (or `<server-ip>:<port>`) to `environment`. Until a server is selected, the client connects to this address as soon as it answers. Without it, pick a server in the web page.

`CLIENT_PICKUP_INTERVAL` (ISO-8601, default `PT12H`) only sets the initial value. Once the interval has been saved in the web page, the stored value is used.

## Usage
- **Dashboard** connects to a MediaGarrd server by IP, from the list of known servers, or by scanning the local network. It shows the server's status, runs a backup, downloads backups, and sets how often the client downloads the latest backup on its own.
- **Server Config** changes the connected server's backup location, backup interval, and number of backups to keep, and adds, edits, and removes the services it backs up. The server must have finished its first-time setup (the `/config` page on the server) before it accepts changes from the client.

Every setting is stored in the `./data/client/state` volume and survives restarts and container rebuilds.

### Finding servers
"Scan Local Network" checks every address of the networks the client is attached to, on `MEDIAGARRD_SERVER_PORT`, `38471`, `8080`, and `80`, and lists every MediaGarrd server that answers. "Connect by IP" also accepts `<ip>:<port>`, and scans every port of the host when the server is not on one of those ports.

With the default Docker networking the client only sees the container network, so a scan finds servers running on the same host but not on other machines. Use "Connect by IP" or `MEDIAGARRD_SERVER_IP` for those, or add `network_mode: host` to the service (and remove its `ports` mapping) so the scan covers your LAN.

## Updating
```bash
git pull
docker compose up --build -d
```
Downloaded backups and the client state live in the mounted `./data/client` volumes and are kept.

## License
[GPLv3](./LICENSE)
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

Expand Down
9 changes: 3 additions & 6 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ services:
mediagarrd-client:
build:
context: .
dockerfile: ./Dockerfile
dockerfile: Dockerfile
container_name: mediagarrd-client
environment:
- CLIENT_PORT=8081
- CLIENT_PICKUP_INTERVAL=PT1H
- CLIENT_DOWNLOAD_DIRECTORY=/var/lib/mediagarrd/downloads
- CLIENT_STATE_FILE=/var/lib/mediagarrd/client/state.json
- CLIENT_PICKUP_INTERVAL=PT12H
- MEDIAGARRD_SERVER_PORT=38471
- MEDIAGARRD_SERVER_IP=192.168.50.55
ports:
- "8081:8081"
volumes:
- "./data/client/downloads:/var/lib/mediagarrd/downloads"
- "./data/client:/var/lib/mediagarrd/client"
- "./data/client/state:/var/lib/mediagarrd/client"
restart: unless-stopped
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.configuration-cache=true

Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading