openvibers/openvibe.codes Commits
OpenVibe Git: the OpenVibe theme; mirror script fixes (token cleanup, .wiki names) (#86)
Changes
@@@ -19,6 +19,7 @@ redirect URI.|---|---|| `install.sh` | Binary (sha256-checked), the `forgejo` user, the PostgreSQL role and the `ov_forgejo` database, `/etc/forgejo/app.ini` with secrets generated on the host, and the systemd unit. Idempotent; `FORGEJO_VERSION=x.y.z` upgrades the binary. || `app.ini.template` | The config; `@…@` values are filled in by `install.sh`. |++| `custom/` | The OpenVibe look: `theme-openvibe.css`, Forgejo's dark theme in the network's colours, which is the default theme. || `openvibe-forgejo.service` | The unit: `127.0.0.1:5060`, hardened, 1 GB of memory at most. || `setup-sso.sh` | The site admin (a random password in `/root/forgejo-admin.txt`) and the OpenVibe sign-in. The client secret is read from Network's database. || `mirror-github.sh [file]` | The `OpenVibers` organisation and one pull mirror per public repository: names from `gh`, or one per line in `file`. |@@@ -81,8 +81,9 @@ DISABLE_GRAVATAR = trueENABLE_FEDERATED_AVATAR = false[ui]--DEFAULT_THEME = forgejo-auto--THEMES = forgejo-auto,forgejo-light,forgejo-dark++; openvibe: Forgejo's dark theme in OpenVibe's colours (custom/public/assets/css/theme-openvibe.css).++DEFAULT_THEME = openvibe++THEMES = openvibe,forgejo-auto,forgejo-light,forgejo-dark[ui.meta]AUTHOR = OpenVibersnnew file mode 100644@@@ -0,0 +1,44 @@++/* OpenVibe Git: Forgejo's dark theme in OpenVibe's colours (the network's default "vibe" theme: deep navy, blue accent).++ Installed by deploy/forgejo/install.sh into /var/lib/forgejo/custom/public/assets/css/; app.ini makes it the default. */++@import url("./theme-forgejo-dark.css");++++:root {++ --is-dark-theme: true;++ --color-body: #0b1220;++ --color-box-body: #131c2e;++ --color-box-body-highlight: #182338;++ --color-box-header: #111a2b;++ --color-nav-bg: #0f1729;++ --color-nav-hover-bg: #182338;++ --color-header-wrapper: #0f1729;++ --color-footer: #0f1729;++ --color-menu: #131c2e;++ --color-card: #131c2e;++ --color-input-background: #0f1729;++ --color-input-border: #2c3d5c;++ --color-input-border-hover: #3b82f6;++ --color-secondary: #1f2d47;++ --color-secondary-dark-1: #2c3d5c;++ --color-secondary-dark-2: #3a4e72;++ --color-light-border: #1f2d47;++ --color-text: #e6edf7;++ --color-text-light: #b7c4d9;++ --color-text-light-1: #96a7c2;++ --color-text-light-2: #7d8ea9;++ --color-text-light-3: #66768f;++ --color-primary: #3b82f6;++ --color-primary-contrast: #ffffff;++ --color-primary-dark-1: #2f74e8;++ --color-primary-dark-2: #2563eb;++ --color-primary-dark-3: #1d4ed8;++ --color-primary-light-1: #5b97f7;++ --color-primary-light-2: #7aabf8;++ --color-primary-light-3: #9abffa;++ --color-primary-alpha-10: #3b82f61a;++ --color-primary-alpha-20: #3b82f633;++ --color-primary-alpha-30: #3b82f64d;++ --color-primary-alpha-40: #3b82f666;++ --color-primary-alpha-50: #3b82f680;++ --color-accent: #3b82f6;++ --color-active-line: #3b82f622;++}@@@ -50,6 +50,14 @@ if [ ! -f /etc/forgejo/app.ini ]; thenecho "config written to /etc/forgejo/app.ini (database ov_forgejo, role forgejo)"fi++# The OpenVibe look (custom/: the openvibe theme), refreshed on every run. app.ini names it; an install from before the++# theme gets the two [ui] lines updated in place.++cp -r "$KIT/custom/." /var/lib/forgejo/custom/++chown -R forgejo:forgejo /var/lib/forgejo/custom++if ! grep -q '^DEFAULT_THEME = openvibe' /etc/forgejo/app.ini; then++ sed -i -e 's/^DEFAULT_THEME = .*/DEFAULT_THEME = openvibe/' -e 's/^THEMES = .*/THEMES = openvibe,forgejo-auto,forgejo-light,forgejo-dark/' /etc/forgejo/app.ini++fi++# 5. The service.install -m 0644 "$KIT/openvibe-forgejo.service" /etc/systemd/system/openvibe-forgejo.servicesystemctl daemon-reload@@@ -12,14 +12,17 @@ API=http://127.0.0.1:5060/api/v1REPOS_FILE="${1:-}"name="mirror-$(date +%s)"token=$("${FJ[@]}" admin user generate-access-token --username openvibe-admin --token-name "$name" --scopes write:organization,write:repository --raw)--trap 'curl -fsS -o /dev/null -X DELETE -H "Authorization: token $token" "$API/users/openvibe-admin/tokens/$name" || true' EXIT++# A token cannot delete itself through the API (403): remove it from Forgejo's database when the script ends.++trap 'sudo -u postgres psql -d ov_forgejo -qtAc "DELETE FROM access_token WHERE name = '"'"'$name'"'"'" >/dev/null || true' EXITcall() { curl -fsS -H "Authorization: token $token" -H 'Content-Type: application/json' "$@"; }call -o /dev/null "$API/orgs/OpenVibers" 2>/dev/null || call -o /dev/null -X POST "$API/orgs" -d '{"username":"OpenVibers","full_name":"OpenVibers","website":"https://openvibe.network","visibility":"public","description":"The OpenVibe projects."}'if [ -n "$REPOS_FILE" ]; then list=$(cat "$REPOS_FILE"); else list=$(gh repo list OpenVibers --visibility public --limit 200 --json name -q '.[].name'); fimade=0; kept=0while read -r repo; do[ -n "$repo" ] || continue-- if call -o /dev/null "$API/repos/OpenVibers/$repo" 2>/dev/null; then kept=$((kept + 1)); continue; fi-- call -o /dev/null -X POST "$API/repos/migrate" -d "{\"clone_addr\":\"https://github.com/OpenVibers/$repo.git\",\"repo_owner\":\"OpenVibers\",\"repo_name\":\"$repo\",\"mirror\":true,\"mirror_interval\":\"1h\",\"service\":\"git\",\"description\":\"Mirror of github.com/OpenVibers/$repo\"}" && made=$((made + 1)) || echo "mirror of $repo failed" >&2++ # Forgejo reserves names ending in .wiki (a repository's wiki): OpenVibe.Wiki is mirrored as OpenVibe-Wiki.++ local_name="$repo"; case "$repo" in *.wiki|*.Wiki) local_name="${repo%.*}-${repo##*.}" ;; esac++ if call -o /dev/null "$API/repos/OpenVibers/$local_name" 2>/dev/null; then kept=$((kept + 1)); continue; fi++ call -o /dev/null -X POST "$API/repos/migrate" -d "{\"clone_addr\":\"https://github.com/OpenVibers/$repo.git\",\"repo_owner\":\"OpenVibers\",\"repo_name\":\"$local_name\",\"mirror\":true,\"mirror_interval\":\"1h\",\"service\":\"git\",\"description\":\"Mirror of github.com/OpenVibers/$repo\"}" && made=$((made + 1)) || echo "mirror of $repo failed" >&2done <<< "$list"echo "mirrors: $made created, $kept already there"
@@ -19,6 +19,7 @@ redirect URI.
@@ -19,6 +19,7 @@ redirect URI.
|---|---|
|---|---|
| `install.sh` | Binary (sha256-checked), the `forgejo` user, the PostgreSQL role and the `ov_forgejo` database, `/etc/forgejo/app.ini` with secrets generated on the host, and the systemd unit. Idempotent; `FORGEJO_VERSION=x.y.z` upgrades the binary. |
| `install.sh` | Binary (sha256-checked), the `forgejo` user, the PostgreSQL role and the `ov_forgejo` database, `/etc/forgejo/app.ini` with secrets generated on the host, and the systemd unit. Idempotent; `FORGEJO_VERSION=x.y.z` upgrades the binary. |
| `app.ini.template` | The config; `@…@` values are filled in by `install.sh`. |
| `app.ini.template` | The config; `@…@` values are filled in by `install.sh`. |
+| `custom/` | The OpenVibe look: `theme-openvibe.css`, Forgejo's dark theme in the network's colours, which is the default theme. |
| `openvibe-forgejo.service` | The unit: `127.0.0.1:5060`, hardened, 1 GB of memory at most. |
| `openvibe-forgejo.service` | The unit: `127.0.0.1:5060`, hardened, 1 GB of memory at most. |
| `setup-sso.sh` | The site admin (a random password in `/root/forgejo-admin.txt`) and the OpenVibe sign-in. The client secret is read from Network's database. |
| `setup-sso.sh` | The site admin (a random password in `/root/forgejo-admin.txt`) and the OpenVibe sign-in. The client secret is read from Network's database. |
| `mirror-github.sh [file]` | The `OpenVibers` organisation and one pull mirror per public repository: names from `gh`, or one per line in `file`. |
| `mirror-github.sh [file]` | The `OpenVibers` organisation and one pull mirror per public repository: names from `gh`, or one per line in `file`. |
@@ -81,8 +81,9 @@ DISABLE_GRAVATAR = true
@@ -81,8 +81,9 @@ DISABLE_GRAVATAR = true
ENABLE_FEDERATED_AVATAR = false
ENABLE_FEDERATED_AVATAR = false
[ui]
[ui]
-DEFAULT_THEME = forgejo-auto
-THEMES = forgejo-auto,forgejo-light,forgejo-dark
+; openvibe: Forgejo's dark theme in OpenVibe's colours (custom/public/assets/css/theme-openvibe.css).
+DEFAULT_THEME = openvibe
+THEMES = openvibe,forgejo-auto,forgejo-light,forgejo-dark
[ui.meta]
[ui.meta]
AUTHOR = OpenVibers
AUTHOR = OpenVibers
new file mode 100644
new file mode 100644
@@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
+/* OpenVibe Git: Forgejo's dark theme in OpenVibe's colours (the network's default "vibe" theme: deep navy, blue accent).
+ Installed by deploy/forgejo/install.sh into /var/lib/forgejo/custom/public/assets/css/; app.ini makes it the default. */
+@import url("./theme-forgejo-dark.css");
+
+:root {
+ --is-dark-theme: true;
+ --color-body: #0b1220;
+ --color-box-body: #131c2e;
+ --color-box-body-highlight: #182338;
+ --color-box-header: #111a2b;
+ --color-nav-bg: #0f1729;
+ --color-nav-hover-bg: #182338;
+ --color-header-wrapper: #0f1729;
+ --color-footer: #0f1729;
+ --color-menu: #131c2e;
+ --color-card: #131c2e;
+ --color-input-background: #0f1729;
+ --color-input-border: #2c3d5c;
+ --color-input-border-hover: #3b82f6;
+ --color-secondary: #1f2d47;
+ --color-secondary-dark-1: #2c3d5c;
+ --color-secondary-dark-2: #3a4e72;
+ --color-light-border: #1f2d47;
+ --color-text: #e6edf7;
+ --color-text-light: #b7c4d9;
+ --color-text-light-1: #96a7c2;
+ --color-text-light-2: #7d8ea9;
+ --color-text-light-3: #66768f;
+ --color-primary: #3b82f6;
+ --color-primary-contrast: #ffffff;
+ --color-primary-dark-1: #2f74e8;
+ --color-primary-dark-2: #2563eb;
+ --color-primary-dark-3: #1d4ed8;
+ --color-primary-light-1: #5b97f7;
+ --color-primary-light-2: #7aabf8;
+ --color-primary-light-3: #9abffa;
+ --color-primary-alpha-10: #3b82f61a;
+ --color-primary-alpha-20: #3b82f633;
+ --color-primary-alpha-30: #3b82f64d;
+ --color-primary-alpha-40: #3b82f666;
+ --color-primary-alpha-50: #3b82f680;
+ --color-accent: #3b82f6;
+ --color-active-line: #3b82f622;
+}
@@ -50,6 +50,14 @@ if [ ! -f /etc/forgejo/app.ini ]; then
@@ -50,6 +50,14 @@ if [ ! -f /etc/forgejo/app.ini ]; then
echo "config written to /etc/forgejo/app.ini (database ov_forgejo, role forgejo)"
echo "config written to /etc/forgejo/app.ini (database ov_forgejo, role forgejo)"
fi
fi
+# The OpenVibe look (custom/: the openvibe theme), refreshed on every run. app.ini names it; an install from before the
+# theme gets the two [ui] lines updated in place.
+cp -r "$KIT/custom/." /var/lib/forgejo/custom/
+chown -R forgejo:forgejo /var/lib/forgejo/custom
+if ! grep -q '^DEFAULT_THEME = openvibe' /etc/forgejo/app.ini; then
+ sed -i -e 's/^DEFAULT_THEME = .*/DEFAULT_THEME = openvibe/' -e 's/^THEMES = .*/THEMES = openvibe,forgejo-auto,forgejo-light,forgejo-dark/' /etc/forgejo/app.ini
+fi
+
# 5. The service.
# 5. The service.
install -m 0644 "$KIT/openvibe-forgejo.service" /etc/systemd/system/openvibe-forgejo.service
install -m 0644 "$KIT/openvibe-forgejo.service" /etc/systemd/system/openvibe-forgejo.service
systemctl daemon-reload
systemctl daemon-reload
@@ -12,14 +12,17 @@ API=http://127.0.0.1:5060/api/v1
@@ -12,14 +12,17 @@ API=http://127.0.0.1:5060/api/v1
REPOS_FILE="${1:-}"
REPOS_FILE="${1:-}"
name="mirror-$(date +%s)"
name="mirror-$(date +%s)"
token=$("${FJ[@]}" admin user generate-access-token --username openvibe-admin --token-name "$name" --scopes write:organization,write:repository --raw)
token=$("${FJ[@]}" admin user generate-access-token --username openvibe-admin --token-name "$name" --scopes write:organization,write:repository --raw)
-trap 'curl -fsS -o /dev/null -X DELETE -H "Authorization: token $token" "$API/users/openvibe-admin/tokens/$name" || true' EXIT
+# A token cannot delete itself through the API (403): remove it from Forgejo's database when the script ends.
+trap 'sudo -u postgres psql -d ov_forgejo -qtAc "DELETE FROM access_token WHERE name = '"'"'$name'"'"'" >/dev/null || true' EXIT
call() { curl -fsS -H "Authorization: token $token" -H 'Content-Type: application/json' "$@"; }
call() { curl -fsS -H "Authorization: token $token" -H 'Content-Type: application/json' "$@"; }
call -o /dev/null "$API/orgs/OpenVibers" 2>/dev/null || call -o /dev/null -X POST "$API/orgs" -d '{"username":"OpenVibers","full_name":"OpenVibers","website":"https://openvibe.network","visibility":"public","description":"The OpenVibe projects."}'
call -o /dev/null "$API/orgs/OpenVibers" 2>/dev/null || call -o /dev/null -X POST "$API/orgs" -d '{"username":"OpenVibers","full_name":"OpenVibers","website":"https://openvibe.network","visibility":"public","description":"The OpenVibe projects."}'
if [ -n "$REPOS_FILE" ]; then list=$(cat "$REPOS_FILE"); else list=$(gh repo list OpenVibers --visibility public --limit 200 --json name -q '.[].name'); fi
if [ -n "$REPOS_FILE" ]; then list=$(cat "$REPOS_FILE"); else list=$(gh repo list OpenVibers --visibility public --limit 200 --json name -q '.[].name'); fi
made=0; kept=0
made=0; kept=0
while read -r repo; do
while read -r repo; do
[ -n "$repo" ] || continue
[ -n "$repo" ] || continue
- if call -o /dev/null "$API/repos/OpenVibers/$repo" 2>/dev/null; then kept=$((kept + 1)); continue; fi
- call -o /dev/null -X POST "$API/repos/migrate" -d "{\"clone_addr\":\"https://github.com/OpenVibers/$repo.git\",\"repo_owner\":\"OpenVibers\",\"repo_name\":\"$repo\",\"mirror\":true,\"mirror_interval\":\"1h\",\"service\":\"git\",\"description\":\"Mirror of github.com/OpenVibers/$repo\"}" && made=$((made + 1)) || echo "mirror of $repo failed" >&2
+ # Forgejo reserves names ending in .wiki (a repository's wiki): OpenVibe.Wiki is mirrored as OpenVibe-Wiki.
+ local_name="$repo"; case "$repo" in *.wiki|*.Wiki) local_name="${repo%.*}-${repo##*.}" ;; esac
+ if call -o /dev/null "$API/repos/OpenVibers/$local_name" 2>/dev/null; then kept=$((kept + 1)); continue; fi
+ call -o /dev/null -X POST "$API/repos/migrate" -d "{\"clone_addr\":\"https://github.com/OpenVibers/$repo.git\",\"repo_owner\":\"OpenVibers\",\"repo_name\":\"$local_name\",\"mirror\":true,\"mirror_interval\":\"1h\",\"service\":\"git\",\"description\":\"Mirror of github.com/OpenVibers/$repo\"}" && made=$((made + 1)) || echo "mirror of $repo failed" >&2
done <<< "$list"
done <<< "$list"
echo "mirrors: $made created, $kept already there"
echo "mirrors: $made created, $kept already there"