Runway 1.0.0

This commit is contained in:
Runway committed 2026-10-21 11:34:34 -06:00
commit dcf819146b
1372 files changed
+188168

No files matched your search

+131
View File
@@ -0,0 +1,131 @@
# Generates runway-app/src/main/resources/kernel-settings.yml and the op.ks.* console messages (EN/ES).
# Run from anywhere: python3 scripts/dev/gen-kernel-settings.py. Edit the tables here, never the outputs.
import json, os
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
G = [ # id, labelEN, helpEN, labelES, helpES
("server.csp","Content-Security-Policy","The browser security policy every page is sent with. It limits where scripts, styles, images and frames may come from. Applies after a restart.","Política de seguridad de contenido (CSP)","La política de seguridad que el navegador recibe con cada página. Limita de dónde pueden venir scripts, estilos, imágenes y marcos. Se aplica tras reiniciar."),
("server.limits","Request limits","How large a request may be. Applies after a restart.","Límites de solicitudes","Qué tan grande puede ser una solicitud. Se aplica tras reiniciar."),
("server.storage","Site storage","How much each site may keep in its static files and documents. A site's own limit, set on Sites, wins over this default. Applies after a restart.","Almacenamiento de los sitios","Cuánto puede guardar cada sitio en sus archivos estáticos y documentos. El límite propio de un sitio, fijado en Sitios, prevalece sobre este valor. Se aplica tras reiniciar."),
("server.cache","HTTP caching","The Cache-Control header pages and files are sent with. A page's own cache setting in the page editor wins over these. Applies after a restart.","Caché HTTP","El encabezado Cache-Control con el que se envían páginas y archivos. El ajuste de caché de una página en el editor prevalece. Se aplica tras reiniciar."),
("server.compression","Response compression (tuning)","Fine-tuning for the compression switches above. Applies after a restart.","Compresión de respuestas (ajuste fino)","Ajuste fino de los interruptores de compresión de arriba. Se aplica tras reiniciar."),
("server.monitoring","Monitoring","The health probe each site answers at /__health, the metrics endpoint, and the site reload endpoint. Applies after a restart.","Monitoreo","La sonda de salud que cada sitio responde en /__health, el endpoint de métricas y el endpoint de recarga de sitios. Se aplica tras reiniciar."),
("server.logs","Site logs","The access and audit log each site keeps (its Logs and Insights screens). Applies after a restart.","Registros de los sitios","El registro de accesos y auditoría de cada sitio (sus pantallas Registros e Información). Se aplica tras reiniciar."),
("server.console","Console languages","The languages this console's language switcher offers. Applies after a restart.","Idiomas de la consola","Los idiomas que ofrece el selector de idioma de esta consola. Se aplica tras reiniciar."),
("server.sessions","Sessions","How long a signed-in console session lasts without activity. Applies after a restart.","Sesiones","Cuánto dura sin actividad una sesión iniciada en la consola. Se aplica tras reiniciar."),
("server.proxy","Reverse proxy","Whether to trust X-Forwarded-* headers, and from which addresses. Only from your own proxy: otherwise visitors could fake their address. Applies after a restart.","Proxy inverso","Si se confía en los encabezados X-Forwarded-* y desde qué direcciones. Solo de su propio proxy: si no, un visitante podría falsear su dirección. Se aplica tras reiniciar."),
("server.capacity","Capacity","Threads and concurrency limits. The defaults suit most servers; raise them only for measured load. Applies after a restart.","Capacidad","Hilos y límites de concurrencia. Los valores por omisión sirven para la mayoría de los servidores; súbalos solo ante una carga medida. Se aplica tras reiniciar."),
("server.protection","Protection logging","What the request protection writes to the log when it refuses a request. Applies after a restart.","Registro de la protección","Qué escribe en el registro la protección de solicitudes cuando rechaza una. Se aplica tras reiniciar."),
("backups.policy","Backup policy","Automatic backups of every site, and how many stored backups are kept. Applies after a restart.","Política de copias de seguridad","Copias automáticas de todos los sitios, y cuántas copias guardadas se conservan. Se aplica tras reiniciar."),
("bandwidth.metering","Metering and quota","Per-site traffic counting, its history, and the monthly cap. Applies after a restart.","Medición y cuota","El conteo de tráfico por sitio, su historial y el tope mensual. Se aplica tras reiniciar."),
("activity.retention","Activity log","How long the console's activity log is kept. Applies after a restart.","Registro de actividad","Cuánto tiempo se conserva el registro de actividad de la consola. Se aplica tras reiniciar."),
("plugins.limits","Plugin limits","Size limits for installing plugins and for the files plugins keep per site. Applies after a restart.","Límites de complementos","Límites de tamaño al instalar complementos y para los archivos que los complementos guardan por sitio. Se aplica tras reiniciar."),
]
# key, type, default, range, group, advanced, showWhen, labelEN, helpEN, labelES, helpES
S = [
("runway.csp.mode","enum","report","report,enforce,off","server.csp",False,None,"Mode","report sends the policy as report-only (violations are logged, nothing is blocked); enforce blocks what the policy does not allow; off sends no policy.","Modo","report envía la política solo para informar (las violaciones se registran, nada se bloquea); enforce bloquea lo que la política no permite; off no envía política."),
("runway.csp.strict-dynamic","boolean","true",None,"server.csp",False,None,"Use strict-dynamic (master switch)","A script the page loaded with its nonce may load further scripts. On: console pages use it, and public pages too while the switch below is on. Off rolls every page, console and public, back to the host lists below.","Usar strict-dynamic (interruptor general)","Un script cargado con el nonce de la página puede cargar otros. Activado: lo usan las páginas de la consola, y también las públicas mientras el interruptor de abajo esté activado. Desactivado, todas las páginas, de la consola y públicas, vuelven a las listas de hosts de abajo."),
("runway.csp.public-strict-dynamic","boolean","true",None,"server.csp",False,"runway.csp.strict-dynamic","Use strict-dynamic on public pages","Public pages get a nonce and strict-dynamic too. Needs the switch above.","Usar strict-dynamic en páginas públicas","Las páginas públicas también reciben nonce y strict-dynamic. Necesita el interruptor de arriba."),
("runway.csp.extra-hosts","list","",None,"server.csp",False,None,"Extra allowed hosts (all sites)","Every site's pages may load from these hosts, e.g. https://www.youtube.com. They are added to scripts, styles, images, fonts, connections and frames. For a host only one site needs, use Settings → Embed hosts instead.","Hosts permitidos adicionales (todos los sitios)","Las páginas de todos los sitios pueden cargar desde estos hosts, p. ej. https://www.youtube.com. Se añaden a scripts, estilos, imágenes, fuentes, conexiones y marcos. Para un host que solo necesita un sitio, use Configuración → Hosts para incrustar."),
("runway.csp.upgrade-insecure-requests","boolean","false",None,"server.csp",False,None,"Upgrade insecure requests","The browser fetches http:// resources over https:// instead.","Actualizar solicitudes inseguras","El navegador pide los recursos http:// por https://."),
("runway.csp.report-uri","string","/__csp-report",None,"server.csp",True,None,"Report URI","Where browsers send violation reports. The default is Runway's own collector, which writes them to the log. A blank field restores this default; to send no reports at all, set runway.csp.report-uri: \"\" in external/application.yml.","URI de informes","A dónde envían los navegadores los informes de violaciones. Por omisión, el colector de Runway, que los escribe en el registro. En blanco vuelve al valor por omisión; para no enviar informes, ponga runway.csp.report-uri: \"\" en external/application.yml."),
("runway.csp.default-src","string","'self'",None,"server.csp",True,None,"default-src","The source list for anything without its own directive. A blank field restores 'self'; to leave the directive out, set the key to \"\" in external/application.yml.","default-src","La lista de orígenes para todo lo que no tiene su propia directiva. En blanco vuelve a 'self'; para omitir la directiva, ponga la clave en \"\" en external/application.yml."),
("runway.csp.script-src","string","'self'",None,"server.csp",True,None,"script-src","Script sources. The page's nonce (and strict-dynamic, when on) is always added.","script-src","Orígenes de scripts. Siempre se añade el nonce de la página (y strict-dynamic, si está activo)."),
("runway.csp.style-src","string","'self' 'unsafe-inline'",None,"server.csp",True,None,"style-src","Style sources.","style-src","Orígenes de estilos."),
("runway.csp.img-src","string","'self' data:",None,"server.csp",True,None,"img-src","Image sources.","img-src","Orígenes de imágenes."),
("runway.csp.font-src","string","'self'",None,"server.csp",True,None,"font-src","Font sources.","font-src","Orígenes de fuentes."),
("runway.csp.connect-src","string","'self'",None,"server.csp",True,None,"connect-src","Where scripts may connect (fetch, XHR, WebSocket).","connect-src","A dónde pueden conectarse los scripts (fetch, XHR, WebSocket)."),
("runway.csp.base-uri","string","'self'",None,"server.csp",True,None,"base-uri","Allowed values of a page's <base> element.","base-uri","Valores permitidos del elemento <base> de una página."),
("runway.csp.form-action","string","'self'",None,"server.csp",True,None,"form-action","Where forms may submit.","form-action","A dónde pueden enviarse los formularios."),
("runway.csp.frame-ancestors","string","'self'",None,"server.csp",True,None,"frame-ancestors","Which sites may show these pages in a frame. 'none' forbids all.","frame-ancestors","Qué sitios pueden mostrar estas páginas en un marco. 'none' lo prohíbe."),
("runway.endpoints.max-form-bytes","int","262144","1024..104857600","server.limits",False,None,"Largest request before sign-in (bytes)","The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).","Solicitud máxima sin sesión (bytes)","Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB)."),
("runway.endpoints.max-body-bytes","int","10485760","1024..1073741824","server.limits",False,None,"Largest request to a plugin (bytes)","The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).","Solicitud máxima a un complemento (bytes)","Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB)."),
("spring.servlet.multipart.max-file-size","string","256MB",None,"server.limits",False,None,"Largest uploaded file","For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB.","Archivo subido máximo","Para subidas como una copia a restaurar. Un tamaño como 256MB o 1GB. Por omisión 256MB."),
("spring.servlet.multipart.max-request-size","string","256MB",None,"server.limits",False,None,"Largest upload request","All the files of one upload together. A size like 256MB. Default 256MB.","Solicitud de subida máxima","Todos los archivos de una subida juntos. Un tamaño como 256MB. Por omisión 256MB."),
("runway.static-files.default-max-bytes","int","0","0..9223372036854775807","server.storage",False,None,"Storage per site (bytes)","The most a site's static files and documents may take on disk. An upload that would go over it is refused; nothing already stored is deleted or hidden, and a site over it can still delete. 0: no limit. Default 0.","Almacenamiento por sitio (bytes)","Lo máximo que pueden ocupar en disco los archivos estáticos y los documentos de un sitio. Una subida que lo superaría se rechaza; no se borra ni se oculta nada de lo ya guardado, y un sitio que lo supera puede seguir borrando. 0: sin límite. Por omisión 0."),
("runway.http-cache.public-pages","string","public, max-age=300, stale-while-revalidate=60",None,"server.cache",False,None,"Public pages","Default: browsers and caches keep a page 5 minutes and may serve it 1 more minute while refreshing.","Páginas públicas","Por omisión: navegadores y cachés guardan una página 5 minutos y pueden servirla 1 minuto más mientras la renuevan."),
("runway.http-cache.assets","string","public, max-age=86400",None,"server.cache",False,None,"Site files","Files under a site's /static/ (except the immutable kinds below). Default: one day.","Archivos del sitio","Archivos bajo /static/ de un sitio (salvo los tipos inmutables de abajo). Por omisión: un día."),
("runway.http-cache.plugin-assets","string","public, max-age=3600",None,"server.cache",False,None,"Plugin files","Files plugins serve under /__plugin/ (their styles and scripts). Default: one hour, then checked against the file's content.","Archivos de complementos","Archivos que los complementos sirven bajo /__plugin/ (sus estilos y scripts). Por omisión: una hora; después se comprueba contra el contenido del archivo."),
("runway.http-cache.immutable-extensions","list","woff2,woff,ttf,otf,eot",None,"server.cache",False,None,"Immutable file types","Extensions served as never changing (fonts by default). Give such files a new name when they change.","Tipos de archivo inmutables","Extensiones que se sirven como si nunca cambiaran (fuentes, por omisión). Cambie el nombre de esos archivos cuando cambien."),
("runway.http-cache.immutable-assets","string","public, max-age=31536000, immutable",None,"server.cache",True,None,"Immutable files","The header for the types above. Default: one year, immutable.","Archivos inmutables","El encabezado de los tipos de arriba. Por omisión: un año, inmutable."),
("runway.compression.gzip.min-size","int","1024","0..10485760","server.compression",False,None,"Smallest body to gzip (bytes)","Default 1024.","Cuerpo mínimo para gzip (bytes)","Por omisión 1024."),
("runway.compression.brotli.min-size","int","1024","0..10485760","server.compression",False,None,"Smallest body to Brotli-encode (bytes)","Default 1024.","Cuerpo mínimo para Brotli (bytes)","Por omisión 1024."),
("runway.compression.brotli.quality","int","5","0..11","server.compression",False,None,"Brotli quality","0 is fastest, 11 smallest; 4 to 6 suit compressing on the fly. Default 5.","Calidad de Brotli","0 es lo más rápido, 11 lo más pequeño; de 4 a 6 sirve para comprimir al vuelo. Por omisión 5."),
("runway.compression.max-buffer-bytes","int","4194304","65536..268435456","server.compression",True,None,"Largest body to compress (bytes)","Larger responses are sent uncompressed. Default 4194304 (4 MiB).","Cuerpo máximo a comprimir (bytes)","Las respuestas más grandes se envían sin comprimir. Por omisión 4194304 (4 MiB)."),
("runway.compression.mime-types","list","text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml,image/svg+xml",None,"server.compression",True,None,"Compressed content types","The whole list: what you enter replaces it.","Tipos de contenido comprimidos","La lista completa: lo que escriba la reemplaza."),
("runway.health.enabled","boolean","true",None,"server.monitoring",False,None,"Answer the health probe (/__health)","Off: /__health is not served.","Responder la sonda de salud (/__health)","Desactivado: /__health no se sirve."),
("runway.health.content-check","boolean","true",None,"server.monitoring",False,"runway.health.enabled","Check the site's content too","The probe also checks that the home page and the master template are there.","Revisar también el contenido","La sonda también comprueba que existan la página de inicio y la plantilla maestra."),
("runway.health.content-check-ttl-seconds","int","10","1..3600","server.monitoring",True,"runway.health.enabled","Content check result kept for (seconds)","Default 10.","Resultado de la revisión guardado (segundos)","Por omisión 10."),
("runway.health.token","secret",None,None,"server.monitoring",False,"runway.health.enabled","Health detail token","A probe that sends it as a Bearer token gets the detailed body. Never set: only the public answer. A blank field keeps the stored token; type a new one to replace it.","Token de detalle de salud","Una sonda que lo envía como token Bearer recibe el detalle. Sin token: solo la respuesta pública. En blanco se conserva el token guardado; escriba uno nuevo para reemplazarlo."),
("runway.metrics.scrape-token","secret",None,None,"server.monitoring",False,None,"Metrics scrape token","Lets a monitoring system read /actuator/prometheus with this Bearer token. Never set: only signed-in operators can. A blank field keeps the stored token; type a new one to replace it.","Token para métricas","Permite que un sistema de monitoreo lea /actuator/prometheus con este token Bearer. Sin token: solo operadores con sesión. En blanco se conserva el token guardado; escriba uno nuevo para reemplazarlo."),
("runway.reload.enabled","boolean","true",None,"server.monitoring",False,None,"Site reload endpoint","Lets a deployment script make a site re-read its files. Inactive until the token is set.","Endpoint de recarga de sitios","Permite que un script de despliegue haga que un sitio relea sus archivos. Inactivo hasta fijar el token."),
("runway.reload.token","secret",None,None,"server.monitoring",False,"runway.reload.enabled","Reload token","The Bearer token the reload endpoint requires. A blank field keeps the stored token; type a new one to replace it.","Token de recarga","El token Bearer que exige el endpoint de recarga. En blanco se conserva el token guardado; escriba uno nuevo para reemplazarlo."),
("runway.logs.enabled","boolean","true",None,"server.logs",False,None,"Keep site logs","Off: no site records new access or audit lines; the Logs screen keeps the lines already written, Insights shows nothing.","Guardar registros de los sitios","Desactivado: ningún sitio registra nuevos accesos ni auditoría; la pantalla Registros conserva las líneas ya escritas, Información no muestra nada."),
("runway.logs.max-retention-days","int","90","1..3650","server.logs",False,"runway.logs.enabled","Longest a site may keep its logs (days)","Each site chooses its own retention up to this. Default 90.","Máximo que un sitio guarda sus registros (días)","Cada sitio elige su retención hasta este valor. Por omisión 90."),
("runway.logs.access-log-user-agent","boolean","false",None,"server.logs",False,"runway.logs.enabled","Record the browser (User-Agent)","Adds the User-Agent to each access line.","Registrar el navegador (User-Agent)","Añade el User-Agent a cada línea de acceso."),
("runway.logs.queue-capacity","int","8192","16..1048576","server.logs",True,"runway.logs.enabled","Log queue size (lines)","Lines waiting to be written; beyond it lines are dropped and counted. Default 8192.","Tamaño de la cola de registro (líneas)","Líneas en espera de escribirse; más allá se descartan y se cuentan. Por omisión 8192."),
("runway.operator.ui-languages","list","en,es",None,"server.console",False,None,"Languages offered","Language codes in display order. Each needs a console translation: en and es ship, others go in external/i18n/.","Idiomas ofrecidos","Códigos de idioma en orden de aparición. Cada uno necesita una traducción de la consola: en y es vienen incluidos, otros van en external/i18n/."),
("runway.operator.default-language","string","en",None,"server.console",False,None,"Default language","Used when the browser asks for none of the languages offered.","Idioma por omisión","Se usa cuando el navegador no pide ninguno de los idiomas ofrecidos."),
("server.servlet.session.timeout","string","30m",None,"server.sessions",False,None,"Idle session timeout","A duration such as 30m, 2h or 1d. Default 30m.","Caducidad por inactividad","Una duración como 30m, 2h o 1d. Por omisión 30m."),
("runway.proxy.forwarded-headers","boolean","true",None,"server.proxy",False,None,"Read X-Forwarded-* headers","From the trusted addresses below only.","Leer encabezados X-Forwarded-*","Solo de las direcciones de confianza de abajo."),
("runway.proxy.trusted-cidrs","list","127.0.0.1/32,::1/128",None,"server.proxy",False,"runway.proxy.forwarded-headers","Trusted proxy addresses","The exact address of your reverse proxy, e.g. 10.0.0.5/32. A /0 (0.0.0.0/0, ::/0), or ranges that add up to every address (0.0.0.0/1 with 128.0.0.0/1), would trust every client to fake its address, so it is refused.","Direcciones de proxy de confianza","La dirección exacta de su proxy inverso, p. ej. 10.0.0.5/32. Un /0 (0.0.0.0/0, ::/0), o rangos que juntos cubren todas las direcciones (0.0.0.0/1 con 128.0.0.0/1), dejaría que cualquier cliente falsee su dirección, así que se rechaza."),
("server.jetty.threads.max","int","200","8..10000","server.capacity",False,None,"Most request threads","Default 200.","Hilos de solicitud máximos","Por omisión 200."),
("server.jetty.threads.min","int","8","1..1000","server.capacity",True,None,"Fewest request threads","Default 8; never above the most.","Hilos de solicitud mínimos","Por omisión 8; nunca más que el máximo."),
("runway.i18n.cache-seconds","int","5","0..3600","server.capacity",True,None,"Message file re-check (seconds)","How often a site's message files are checked for changes made outside the console (Messages screen saves apply at once). 0: on every use. Default 5.","Revisión de archivos de mensajes (segundos)","Cada cuánto se revisa si los archivos de mensajes de un sitio cambiaron fuera de la consola (lo guardado en Mensajes se aplica de inmediato). 0: en cada uso. Por omisión 5."),
("spring.task.scheduling.pool.size","int","4","1..64","server.capacity",True,None,"Scheduler threads","Threads for backups and plugin jobs. Default 4.","Hilos del programador","Hilos para copias y tareas de complementos. Por omisión 4."),
("runway.security.max-concurrent-hashes","int","8","1..256","server.capacity",True,None,"Password checks at once","Each takes about 19 MiB (32 MiB with the High profile). Beyond it, sign-ins wait. Default 8.","Comprobaciones de contraseña simultáneas","Cada una usa unos 19 MiB (32 MiB con el perfil Alto). Más allá, los inicios de sesión esperan. Por omisión 8."),
("runway.security.acquire-timeout-millis","int","2000","100..60000","server.capacity",True,None,"Longest wait for a password check (ms)","Then the sign-in answers \"busy\". Default 2000.","Espera máxima por una comprobación (ms)","Después el inicio de sesión responde \"ocupado\". Por omisión 2000."),
("runway.protect.log-rejections","boolean","true",None,"server.protection",False,None,"Log refused requests","One line per refused request (403 or 429). The count in the metrics is kept either way.","Registrar solicitudes rechazadas","Una línea por solicitud rechazada (403 o 429). El conteo en las métricas se mantiene igual."),
("runway.protect.log-rejection-window-seconds","int","60","1..86400","server.protection",False,"runway.protect.log-rejections","Repeat lines suppressed for (seconds)","For the same address and reason; the next line says how many were suppressed. Default 60.","Repeticiones suprimidas durante (segundos)","Para la misma dirección y motivo; la siguiente línea dice cuántas se suprimieron. Por omisión 60."),
("runway.backups.schedule.enabled","boolean","false",None,"backups.policy",False,None,"Back up every site automatically","On the schedule below.","Hacer copia de todos los sitios automáticamente","Según el horario de abajo."),
("runway.backups.schedule.cron","string","0 30 2 * * *",None,"backups.policy",False,"runway.backups.schedule.enabled","Schedule","Six fields: second minute hour day month weekday. Default 0 30 2 * * * (02:30 every day).","Horario","Seis campos: segundo minuto hora día mes día-de-la-semana. Por omisión 0 30 2 * * * (02:30 cada día)."),
("runway.backups.retention.max-count","int","30","0..100000","backups.policy",False,None,"Stored backups kept per site","The newest this many are kept; 0 keeps all. Default 30.","Copias guardadas por sitio","Se conservan las más recientes; 0 las conserva todas. Por omisión 30."),
("runway.backups.retention.max-age-days","int","0","0..36500","backups.policy",False,None,"Delete stored backups older than (days)","0: no age limit. Default 0.","Borrar copias guardadas de más de (días)","0: sin límite de antigüedad. Por omisión 0."),
("runway.backups.max-entry-bytes","int","268435456","1048576..17179869184","backups.policy",True,None,"Largest file inside a backup to restore (bytes)","A guard against archives that expand without limit. Default 268435456 (256 MiB).","Archivo máximo dentro de una copia a restaurar (bytes)","Protege contra archivos que se expanden sin límite. Por omisión 268435456 (256 MiB)."),
("runway.bandwidth.enabled","boolean","true",None,"bandwidth.metering",False,None,"Count each site's traffic","Off: nothing new is counted and no cap is enforced; the Bandwidth screens keep the history already recorded.","Contar el tráfico de cada sitio","Desactivado: no se cuenta nada nuevo y no se aplica ningún tope; las pantallas de Ancho de banda conservan el historial ya registrado."),
("runway.bandwidth.quota.default-monthly-bytes","int","0","0..9223372036854775807","bandwidth.metering",False,"runway.bandwidth.enabled","Monthly cap per site (bytes)","Outbound bytes in the last 30 days; above it the site's public pages answer 503 (its console keeps working). 0: no cap. A site's own cap is set on Sites.","Tope mensual por sitio (bytes)","Bytes salientes de los últimos 30 días; por encima, las páginas públicas del sitio responden 503 (su consola sigue funcionando). 0: sin tope. El tope propio de un sitio se fija en Sitios."),
("runway.bandwidth.retention-days","int","90","1..3650","bandwidth.metering",False,"runway.bandwidth.enabled","Keep traffic history (days)","Default 90.","Conservar el historial de tráfico (días)","Por omisión 90."),
("runway.bandwidth.snapshot-seconds","int","60","1..3600","bandwidth.metering",True,"runway.bandwidth.enabled","Counting interval (seconds)","Also how often the cap is checked. Default 60.","Intervalo de conteo (segundos)","También cada cuánto se revisa el tope. Por omisión 60."),
("runway.app-activity.retention-days","int","90","1..3650","activity.retention",False,None,"Keep the activity log (days)","Default 90. Switching the log off is set on the server only, so it cannot be done by the people it records.","Conservar el registro de actividad (días)","Por omisión 90. Apagar el registro solo se fija en el servidor, para que no puedan hacerlo las personas a quienes registra."),
("runway.plugins.max-entry-bytes","int","134217728","1048576..4294967296","plugins.limits",False,None,"Largest file inside a plugin to install (bytes)","Default 134217728 (128 MiB).","Archivo máximo dentro de un complemento a instalar (bytes)","Por omisión 134217728 (128 MiB)."),
("runway.plugins.site-files.max-write-bytes","int","16777216","1024..1073741824","plugins.limits",False,None,"Largest file a plugin keeps per site (bytes)","Default 16777216 (16 MiB).","Archivo máximo que un complemento guarda por sitio (bytes)","Por omisión 16777216 (16 MiB)."),
]
def q(v):
return json.dumps(v)
lines=["# The kernel's own console-managed settings (Settings → Server settings, and the policy cards on Backups,",
"# Bandwidth, Activity → Logs and Plugins). Rendered by the same settings form as a plugin's settings. Each key is a",
"# full property name; values the console saves go to `settings:` in external/platform.yml, which is loaded BELOW the",
"# host's external/application.yml, so a key set on the host wins and the form shows it locked.",
"# A group id is <screen>.<name>: the screen it is shown on. GENERATED by scripts/dev/gen-kernel-settings.py:",
"# change the generator and the messages with it.",
"id: kernel","name: Runway","version: 1.0.0","settingGroups:"]
for g in G:
gid=g[0]; k='op.ks.g.'+gid
lines.append(f" - {{ id: {gid}, label: {k}, help: {k}.help }}")
lines.append("settings:")
for (key,t,d,r,g,adv,sw,le,he,ls,hs) in S:
parts=[f"key: {key}",f"type: {t}"]
if d is not None: parts.append(f"default: {q(d)}")
if r: parts.append(f"range: {q(r)}")
parts += [f"label: op.ks.{key}", f"help: op.ks.{key}.help", f"group: {g}"]
if adv: parts.append("advanced: true")
if sw: parts.append(f"showWhen: {sw}")
lines.append(" - { "+", ".join(parts)+" }")
open(ROOT + '/runway-app/src/main/resources/kernel-settings.yml','w').write("\n".join(lines)+"\n")
def esc(s): # no-argument messages are printed verbatim: no MessageFormat escaping
return s
en=["","# Kernel settings (kernel-settings.yml, generated with it)"]
es=["","# Ajustes del núcleo (kernel-settings.yml, generados con él)"]
for g in G:
en+= [f"op.ks.g.{g[0]}={g[1]}", f"op.ks.g.{g[0]}.help={g[2]}"]
es+= [f"op.ks.g.{g[0]}={g[3]}", f"op.ks.g.{g[0]}.help={g[4]}"]
for (key,t,d,r,g,adv,sw,le,he,ls,hs) in S:
en+= [f"op.ks.{key}={le}", f"op.ks.{key}.help={he}"]
es+= [f"op.ks.{key}={ls}", f"op.ks.{key}.help={hs}"]
for p,b in [(ROOT + '/runway-app/src/main/resources/i18n/operator-messages.properties',en),
(ROOT + '/runway-app/src/main/resources/i18n/operator-messages_es.properties',es)]:
s=open(p,encoding='utf-8').read()
if '# Kernel settings (kernel-settings.yml' in s or '# Ajustes del núcleo' in s:
s=s[:max(s.find('\n# Kernel settings (kernel-settings.yml'), s.find('\n# Ajustes del núcleo'))]
s=s.rstrip('\n')+'\n'+'\n'.join(b)+'\n'
open(p,'w',encoding='utf-8').write(s)
print(len(G),"groups",len(S),"settings")
+183
View File
@@ -0,0 +1,183 @@
#!/usr/bin/env python3
"""Generates docs/SETTINGS-REFERENCE.md: every setting, what it does, its values, and where it is set.
Sources (edit those, then run this; SettingsReferenceTest fails when the document is stale):
runway-app/src/main/resources/kernel-settings.yml console-managed kernel settings (schema)
runway-app/src/main/resources/i18n/operator-messages.properties their English labels and help
scripts/dev/settings-homes.yml settings on other screens, and server-only ones with reasons
runway-plugin-protection/plugin.yml + i18n/messages.properties the essential plugin's settings
Run from the repository root: python3 scripts/dev/gen-settings-reference.py
"""
import os
import yaml
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def props(path):
out = {}
key = None
for line in open(path, encoding='utf-8'):
line = line.rstrip('\n')
if not line or line.startswith('#') or '=' not in line:
continue
k, v = line.split('=', 1)
out[k.strip()] = v.strip()
return out
def cell(text):
return (text or '').replace('|', '\\|').replace('\n', ' ')
def values(s):
t = s.get('type', 'string')
parts = []
if t == 'enum' and s.get('range'):
parts.append('one of ' + ', '.join(f'`{x.strip()}`' for x in str(s['range']).split(',')))
elif t == 'boolean':
parts.append('`true` or `false`')
elif t in ('int', 'decimal') and s.get('range'):
lo, hi = str(s['range']).split('..')
parts.append(f'{"whole number" if t == "int" else "number"} from {lo} to {hi}')
elif t == 'list':
parts.append('comma-separated list')
elif t == 'secret':
parts.append('secret (stored encrypted, never shown)')
else:
parts.append('text')
default = s.get('default')
if isinstance(default, bool):
default = str(default).lower() # YAML booleans print as true/false, not Python's True/False
parts.append('default ' + (f'`{default}`' if default not in (None, '') else 'empty'))
return '; '.join(parts)
SCREENS = [
('server', 'Settings → Server settings', '/__app/config/server'),
('backups', 'Backups → Settings (backup policy)', '/__app/config/backups'),
('bandwidth', 'Bandwidth → Settings (metering and quota)', '/__app/config/bandwidth'),
('activity', 'Activity → Logs → Settings (activity log retention)', '/__app/config/activity'),
('plugins', 'Plugins → Settings (plugin limits)', '/__app/config/plugins'),
]
def main():
ks = yaml.safe_load(open(f'{ROOT}/runway-app/src/main/resources/kernel-settings.yml', encoding='utf-8'))
msg = props(f'{ROOT}/runway-app/src/main/resources/i18n/operator-messages.properties')
homes = yaml.safe_load(open(f'{ROOT}/scripts/dev/settings-homes.yml', encoding='utf-8'))
prot = yaml.safe_load(open(f'{ROOT}/runway-plugin-protection/plugin.yml', encoding='utf-8'))
pmsg = props(f'{ROOT}/runway-plugin-protection/i18n/messages.properties')
out = []
w = out.append
w('# Settings reference')
w('')
w('<!-- GENERATED by scripts/dev/gen-settings-reference.py — do not edit; edit its sources and run it again. -->')
w('')
w('Every setting the Runway kernel and its essential protection plugin read: what it does, the values it takes, '
'and where you set it. Per-site settings are made on the site console\'s screens (SITE-MANAGER-GUIDE.md); '
'optional plugins document their own settings.')
w('')
w('## How settings are layered')
w('')
w('- **The console** keeps what you set on its screens in `external/platform.yml` (platform) and in each '
'site\'s folder (that site). Only values that differ from the default are stored. A blank field restores '
'the default; a blank token field keeps the stored token.')
w('- **The server** can set any key in `external/application.yml`, an environment variable '
'(`RUNWAY_CSP_MODE` for `runway.csp.mode`) or a command-line argument. **A value set there wins**, and the '
'console shows that field disabled with where it is set, and what removing it there would do. To move a key '
'to the console in one restart, click **Use the file\'s value** on its row first (it copies the value the '
'server runs with), then remove the line and restart: nothing changes (ADMINISTRATION.md §8).')
w(' Two exceptions. *Password strength* (`runway.security.password-strength`): the value chosen on Platform '
'settings wins over every server source, and the field is never locked. *The protection plugin\'s settings* '
'(section 2): `external/plugin-settings/protection.yml`, which its settings screen writes, wins over '
'`external/application.yml`, and the form shows no lock; an environment variable or a command-line argument '
'still wins over both.')
w('- **When a change applies:** the settings in section 1 apply after the next restart (the form says which '
'are pending). Settings on the other screens in section 2 say when they apply.')
w('- **Kept out of the console on purpose:** the settings in section 3, each with the reason.')
w('')
w('## 1. Console settings: Server settings and the policy cards')
w('')
groups = {g['id']: g for g in ks['settingGroups']}
for prefix, title, path in SCREENS:
w(f'### {title}')
w('')
w(f'Screen: `{path}` (platform administrators). Applies after a restart.')
w('')
for gid, g in groups.items():
if not gid.startswith(prefix + '.'):
continue
rows = [s for s in ks['settings'] if s['group'] == gid]
if not rows:
continue
w(f'#### {msg.get(g["label"], gid)}')
w('')
if msg.get(g['help']):
w(msg[g['help']])
w('')
w('| Setting | Key | What it does | Values |')
w('|---|---|---|---|')
for s in rows:
label = msg.get(s['label'], s['key'])
adv = ' *(Advanced)*' if s.get('advanced') else ''
w(f'| {cell(label)}{adv} | `{s["key"]}` | {cell(msg.get(s["help"], ""))} | {cell(values(s))} |')
w('')
w('## 2. Settings edited on other console screens')
w('')
w('| Key | Where |')
w('|---|---|')
for key, where in homes['elsewhere'].items():
w(f'| `{key}` | {cell(where)} |')
w('')
w('Log levels (`logging.level.<logger>`) are set on **Activity → Logs → Log levels** (`/__app/logs/levels`): '
'they apply at once and are kept in `platform.yml`; a level set in `application.yml` wins and shows locked.')
w('')
w('The essential protection plugin\'s settings are on **Plugins → Essential Protection → Settings** '
'(`/__app/plugins/protection/settings`). They are stored in `external/plugin-settings/protection.yml` and '
'bound as `runway.plugin.protection.<key>`; they apply after a restart. Its login protection (honeypot, '
'lockout, CAPTCHA) is the panel below that form and applies at once; each site has its own on '
'`/__admin/protection`.')
w('')
pgroups = {g['id']: g for g in prot.get('settingGroups', [])}
for gid, g in pgroups.items():
rows = [s for s in prot['settings'] if s.get('group') == gid]
if not rows:
continue
w(f'#### {pmsg.get(g["label"], gid)}')
w('')
w('| Setting | Key | What it does | Values |')
w('|---|---|---|---|')
for s in rows:
w(f'| {cell(pmsg.get(s["label"], s["key"]))} | `runway.plugin.protection.{s["key"]}` | '
f'{cell(pmsg.get(s.get("help", ""), ""))} | {cell(values(s))} |')
w('')
w('## 3. Server-only settings, and why')
w('')
w('Set these in `external/application.yml` (or the environment). They stay out of the console because the '
'console cannot change them safely, or cannot exist until they are known.')
w('')
by_reason = {}
for key, reason in homes['host-only'].items():
by_reason.setdefault(reason.strip(), []).append(key)
w('| Keys | Why not in the console |')
w('|---|---|')
for reason, keys in by_reason.items():
w(f'| {"<br>".join(f"`{k}`" for k in keys)} | {cell(reason)} |')
w('')
w('Spring Boot keys Runway pins in its shipped `application.yml` (for example '
'`server.forward-headers-strategy`, `spring.web.resources.add-mappings`, `spring.security.filter.order`) are '
'part of how the platform works, not preferences: do not change them. ADMINISTRATION.md §8 lists them.')
w('')
open(f'{ROOT}/docs/SETTINGS-REFERENCE.md', 'w', encoding='utf-8').write('\n'.join(out))
n = len(ks['settings']) + len(homes['elsewhere']) + len(homes['host-only']) + len(prot['settings'])
print(f'docs/SETTINGS-REFERENCE.md: {n} settings')
if __name__ == '__main__':
main()
+83
View File
@@ -0,0 +1,83 @@
# Where each bound runway.* setting is managed when it is not a field of Settings -> Server settings or a policy card
# (those are declared in runway-app/src/main/resources/kernel-settings.yml).
#
# Read by scripts/dev/gen-settings-reference.py (docs/SETTINGS-REFERENCE.md) and by SettingsParityTest, which fails
# when a bound key is in neither place, or when an entry here names a key that no longer exists. The rule: every
# editable parameter is in the Web UI in its section unless that is strictly impossible, and then the reason is
# written down. Add a new runway.* property to kernel-settings.yml (via gen-kernel-settings.py) or here.
# Edited on another console screen.
elsewhere:
runway.compression.enabled: "Settings → Platform settings, Response compression (applies at once)"
runway.compression.brotli.enabled: "Settings → Platform settings, Response compression (applies at once)"
runway.compression.gzip.enabled: "Settings → Platform settings, Response compression (applies at once)"
runway.node.name: "Settings → Platform settings, Node name (the console's value wins over this key)"
runway.security.password-strength: "Settings → Platform settings, Password strength (applies to new passwords after a restart; the console's value wins over this key)"
runway.bandwidth.quota.per-site: "Sites → Edit, Monthly bandwidth cap, per site (applies at once)"
# Set only in the host's external/application.yml (or the environment), with the reason it cannot be in the console.
host-only:
runway.app-activity.enabled: >-
It switches off the operator activity log. If the console could turn it off, an operator could silence the record
of their own actions.
runway.backups.offsite-dir: >-
A folder on the server that receives full site archives (user records, encrypted plugin secrets). Set from a
browser it could point into a web-served folder or another site's folder; choosing and mounting the share is
the server administrator's job. Shown read-only on Backups.
runway.cluster.enabled: &cluster >-
Read before the application is built (the cluster member and the shared session store are created at
startup), and every node must hold the same value; one node's console cannot change the others.
runway.cluster.cluster-name: *cluster
runway.cluster.topology: *cluster
runway.cluster.session-ttl: *cluster
runway.cluster.sessions-map-name: *cluster
runway.cluster.events-topic-name: *cluster
runway.cluster.embedded.discovery: *cluster
runway.cluster.embedded.members: *cluster
runway.cluster.embedded.port: *cluster
runway.cluster.embedded.port-auto-increment: *cluster
runway.cluster.client.addresses: *cluster
runway.cluster.client.smart-routing: *cluster
runway.console.hosts: >-
The host names the operator console answers on. A wrong value would lock every operator out of the console, so
the console cannot be the place to change it: the file on the server is the way back in. Read at startup; each
node of a cluster reads its own.
runway.demo.first-run.id: &demo >-
Used once, on the first start of an unattended evaluation box, before any operator exists to sign in. The
console equivalent is Sites → Install a demo site.
runway.demo.first-run.host: *demo
runway.demo.first-run.master-username: *demo
runway.demo.first-run.master-password: *demo
runway.plugins.root: >-
Read before the application starts: the plugin loader finds the plugins there before the console exists, and
the folder decides what code the server runs.
runway.security.app-master-id: >-
The trust anchor that pins the undeletable application superadmin, read before the application starts; set by
the setup wizard and never edited by hand.
runway.security.secret-key: >-
The key that encrypts every other stored secret. Typing it into a browser would put it on the wire, and
changing it would make every stored secret unreadable; the installer keeps it in a root-only file.
runway.storage.external: &storage >-
Read before the application starts: the data folder holds application.yml, platform.yml and every site, so the
console cannot live anywhere until it is known.
runway.storage.sites: *storage
runway.storage.backups: >-
Read before the application starts, like the data folder, and it receives full site archives (the same reason
as runway.backups.offsite-dir).
runway.storage.stats: &retired >-
Retired before 1.0 and has no effect; a value set in application.yml is reported once at startup.
runway.storage.logs: *retired
runway.tls.enabled: &tls >-
Read before the server starts serving: the HTTPS and redirect listeners are built from it at startup, and a
wrong value set from the console could make the console itself unreachable. The certificate files and their
password belong to the server.
runway.tls.keystore: *tls
runway.tls.keystore-password: *tls
runway.tls.keystore-type: *tls
runway.tls.key-alias: *tls
runway.tls.sni-host-check: *tls
runway.tls.watch-keystore: *tls
runway.tls.redirect-http.enabled: *tls
runway.tls.redirect-http.port: *tls
runway.tls.redirect-http.status: *tls
runway.tls.redirect-http.acme-challenges-dir: *tls
+637
View File
@@ -0,0 +1,637 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
# Runway — installer / upgrader (Linux, root).
#
# Idempotent. Lays the code under a VERSIONED directory and flips a "current"
# symlink to it, while all editable state (external/, logs/, backups/) lives in a
# version-INDEPENDENT data dir symlinked into the release — so an upgrade never
# clobbers configuration, sites, logs, or backups, and a rollback is a symlink flip.
#
# <prefix>/runway-<version>/ the release (bin/, scripts/, seed/), external+logs+backups symlinked
# <prefix>/runway -> runway-<version> "current" (RUNWAY_HOME)
# <prefix>/runway-data/ external/ logs/ backups/ (survives upgrades)
#
# It creates the service user, installs/adjusts the systemd unit (pointing
# JAVA_HOME at a real JDK/JRE 25+ on the host), relabels SELinux contexts so the
# service can exec from the install dir on enforcing RHEL-family hosts, optionally
# opens the app port in the host firewall, and (re)starts the service.
#
# Runway is filesystem/YAML-backed — there is NO database to create. The shell
# installer lays down files + the systemd service and (interactively, on a TTY)
# asks about install location, service user, TLS termination and the firewall; the
# app-superadmin + first site are then created in the app's own web setup wizard.
#
# sudo ./scripts/install.sh # interactive (prompts on a TTY)
# sudo ./scripts/install.sh -y # unattended, all defaults (plain HTTP behind a proxy)
# sudo ./scripts/install.sh --tls-keystore /etc/ssl/runway.p12 --tls-password s3cr3t --tls-redirect -y
# sudo ./scripts/install.sh --port 8080 --open-firewall
# sudo ./scripts/install.sh --dry-run # print actions, change nothing
# ---------------------------------------------------------------------------
set -euo pipefail
APP="runway"
PREFIX="/opt"
APP_USER="runway"
PORT="" # blank => whatever the app/config defaults to
JAVA_HOME_ARG=""
OPEN_FIREWALL="no"
FIREWALL_PORTS=""
NO_FIREWALL="no"
INTERACTIVE="auto"
DRY_RUN="no"
HEAP_MAX="" # --heap SIZE: JVM -Xmx, written to a drop-in so it survives upgrades (blank => leave as-is)
MEMORY_MAX="" # --memory-max SIZE: systemd MemoryMax cgroup backstop, ditto
# TLS termination (default: OFF — plain HTTP behind a reverse proxy). Local TLS points at an existing
# PKCS12 keystore; the installer writes runway.tls.* into the external application.yml (the first-run web
# wizard then merges its superadmin pin without discarding it).
TLS_ENABLED="no"
TLS_KEYSTORE="" # the PKCS12 path the operator gives (may be relative to where they run the installer)
TLS_KEYSTORE_DEST="" # absolute path the keystore is COPIED to inside the deployment (what the config points at)
TLS_PASSWORD=""
TLS_REDIRECT="no"
NO_TLS="no"
# Secret-encryption key (runway.security.secret-key): required for storing ANY secret setting (SMTP / CAPTCHA /
# plugin passwords). Persisted as a root-only systemd drop-in env var. Blank => auto-generate one on first
# install (so a secret store never silently fails); an existing drop-in is NEVER overwritten (changing the key
# makes previously-encrypted secrets undecryptable). Pass --secret-key to reuse a known key (e.g. a migration).
SECRET_KEY=""
SECRET_DROPIN="/etc/systemd/system/${APP}.service.d/30-secret-key.conf"
# Operator memory tuning goes in DROP-INS (not the installer-rewritten main unit), so a custom heap / cgroup cap
# survives every upgrade. Written only when --heap / --memory-max is passed; otherwise left exactly as they are.
MEMORY_DROPIN="/etc/systemd/system/${APP}.service.d/10-memory.conf"
HEAP_DROPIN="/etc/systemd/system/${APP}.service.d/20-heap.conf"
log() { printf '[install] %s\n' "$*"; }
warn() { printf '[install] WARNING: %s\n' "$*" >&2; }
die() { printf '[install] ERROR: %s\n' "$*" >&2; exit 1; }
# Run a privileged/side-effecting command, or just echo it under --dry-run.
run() {
if [ "$DRY_RUN" = "yes" ]; then printf ' + %s\n' "$*"; else "$@"; fi
}
prompt_yesno() { # var "question" default(yes/no)
local __var="$1" __q="$2" __def="${3:-no}" __ans
[ "$INTERACTIVE" = "yes" ] || { printf -v "$__var" '%s' "$__def"; return; }
read -r -p "[install] ${__q} [$( [ "$__def" = yes ] && echo 'Y/n' || echo 'y/N')]: " __ans || true
case "${__ans:-$__def}" in y|Y|yes|YES) printf -v "$__var" 'yes' ;; *) printf -v "$__var" 'no' ;; esac
}
prompt_value() { # var "question" default
local __var="$1" __q="$2" __def="${3:-}" __ans
[ "$INTERACTIVE" = "yes" ] || { printf -v "$__var" '%s' "$__def"; return; }
read -r -p "[install] ${__q}${__def:+ [$__def]}: " __ans || true
printf -v "$__var" '%s' "${__ans:-$__def}"
}
prompt_secret() { # var "question" (never echoed)
local __var="$1" __q="$2" __ans
[ "$INTERACTIVE" = "yes" ] || return
read -r -s -p "[install] ${__q}: " __ans || true; echo
printf -v "$__var" '%s' "$__ans"
}
# Escape a value for a double-quoted YAML scalar (backslash + quote only — enough for a keystore password).
yaml_escape() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
# Writes the external application.yml the operator's choices imply (server.port when non-default, and the
# Copy the operator's PKCS12 keystore INTO the deployment's data dir and record its absolute path in
# TLS_KEYSTORE_DEST. The service resolves runway.tls.keystore relative to its own working directory (the
# deployment root), NOT to where the operator ran the installer — so a bare "runway.p12" would never be found.
# Copying it (owned by the service user, mode 600 — it holds a private key) makes the keystore travel with the
# deployment's version-independent data dir and gives the config a stable, absolute path.
stage_keystore() {
[ "$TLS_ENABLED" = "yes" ] || return 0
local src base
base="$(basename "$TLS_KEYSTORE")"
TLS_KEYSTORE_DEST="$DATA/external/tls/$base"
# Resolve a relative source against the invocation dir (the .bin stub does not cd, so pwd is where it ran).
src="$TLS_KEYSTORE"; case "$src" in /*) : ;; *) src="$(pwd)/$src" ;; esac
if [ "$DRY_RUN" = "yes" ]; then
printf ' + copy keystore %s -> %s\n' "$src" "$TLS_KEYSTORE_DEST"
return 0
fi
mkdir -p "$DATA/external/tls"
if [ -e "$src" ]; then
install -o "$APP_USER" -g "$APP_USER" -m 600 "$src" "$TLS_KEYSTORE_DEST"
log "copied keystore into the deployment: $TLS_KEYSTORE_DEST"
else
warn "keystore not found at $src — drop your PKCS12 at $TLS_KEYSTORE_DEST before starting the service (the config already points there)"
fi
}
# runway.tls.* block for local termination). chmod 600 + owned by the service user (it holds a secret).
# Skipped entirely when nothing needs writing (the common proxy/default case — the web wizard creates it).
# FIRST INSTALL ONLY: it writes the whole file, so over an existing one it would drop the setup wizard's
# application-superadmin pin (the platform reopens /setup to anyone) and every key the operator added. The
# argument check refuses --port/--tls-keystore on an existing install before anything runs; this guard is the
# backstop, so no future caller can reach the overwrite either.
write_app_config() {
[ "$WRITE_CONFIG" = "yes" ] || return 0
local dest="$DATA/external/application.yml"
[ -e "$dest" ] && die "refusing to replace the existing $dest (it holds the setup wizard's superadmin pin and your settings) — edit server.port / runway.tls.* in it instead"
if [ "$DRY_RUN" = "yes" ]; then
printf ' + write %s (tls=%s port=%s redirect=%s)\n' "$dest" "$TLS_ENABLED" "${PORT:-default}" "$TLS_REDIRECT"
return 0
fi
log "writing $dest (server.port / runway.tls.*)"
local tmp; tmp="$(mktemp)"; chmod 600 "$tmp"
{
echo "# Written by the Runway installer. The first-run web wizard MERGES its application-superadmin"
echo "# pin into this file, preserving these settings. Edit freely; restart to apply."
if [ "$WRITE_PORT" = "yes" ]; then
printf 'server:\n port: %s\n' "$PORT"
fi
if [ "$TLS_ENABLED" = "yes" ]; then
echo "runway:"
echo " tls:"
echo " enabled: true"
printf ' keystore: %s\n' "$TLS_KEYSTORE_DEST"
printf ' keystore-password: "%s"\n' "$(yaml_escape "$TLS_PASSWORD")"
echo " key-alias: runway"
if [ "$TLS_REDIRECT" = "yes" ]; then
echo " redirect-http:"
echo " enabled: true"
printf ' acme-challenges-dir: %s/external/acme-challenges\n' "$DATA"
fi
fi
} > "$tmp"
install -o "$APP_USER" -g "$APP_USER" -m 600 "$tmp" "$dest"
rm -f "$tmp"
}
# A high-entropy random key (base64 of 48 bytes = 64 chars). Used when no --secret-key is given; the app
# SHA-256's it into the AES-256 key, so any long random string works.
gen_secret_key() {
if command -v openssl >/dev/null 2>&1; then
openssl rand -base64 48 | tr -d '\n'
else
head -c 48 /dev/urandom | base64 | tr -d '\n'
fi
}
# Persist the secret-encryption key as a root-only systemd drop-in env var (RUNWAY_SECURITY_SECRET_KEY, which
# Spring binds to runway.security.secret-key). Written ONCE, on first install: an existing drop-in is kept so a
# re-run/upgrade never rotates the key (which would make already-stored ENC(...) secrets undecryptable). When no
# key is supplied, one is generated — so even an unattended `-y` install always ends up able to store secrets.
write_secret_key_dropin() {
if [ -f "$SECRET_DROPIN" ] && grep -q 'RUNWAY_SECURITY_SECRET_KEY' "$SECRET_DROPIN" 2>/dev/null; then
log "secret-encryption key already set ($SECRET_DROPIN) — keeping it (never rotated by the installer)"
return 0
fi
[ -n "$SECRET_KEY" ] || SECRET_KEY="$(gen_secret_key)"
if [ -z "$SECRET_KEY" ]; then
warn "could not generate a secret key (no openssl or /dev/urandom) — set runway.security.secret-key yourself, or stored secrets (SMTP/CAPTCHA) will not save"
return 0
fi
if [ "$DRY_RUN" = "yes" ]; then
printf ' + write %s (Environment=RUNWAY_SECURITY_SECRET_KEY=<key>, mode 600)\n' "$SECRET_DROPIN"
return 0
fi
log "writing secret-encryption key drop-in -> $SECRET_DROPIN (value not shown)"
mkdir -p "$(dirname "$SECRET_DROPIN")"
local tmp; tmp="$(mktemp)"; chmod 600 "$tmp"
{
echo "[Service]"
echo "# Secret-encryption key for ENC(...) settings (SMTP / CAPTCHA / plugin passwords), written by the"
echo "# Runway installer. BACK IT UP with your deployment secrets: changing or losing this key makes all"
echo "# previously-encrypted values undecryptable. Root-readable only (chmod 600)."
printf 'Environment=RUNWAY_SECURITY_SECRET_KEY=%s\n' "$SECRET_KEY"
} > "$tmp"
install -o root -g root -m 600 "$tmp" "$SECRET_DROPIN"
rm -f "$tmp"
}
# Write the memory-tuning drop-ins (10-memory.conf / 20-heap.conf) when --memory-max / --heap were passed. They
# live under runway.service.d/ (operator-owned; the installer never removes them), so a custom cgroup cap / heap
# SURVIVES every upgrade — unlike an -Xmx hand-edited into the installer-rewritten main unit. Passing neither leaves
# any existing tuning drop-ins exactly as they are.
write_tuning_dropins() {
if [ -n "$MEMORY_MAX" ]; then
log "writing memory-cap drop-in -> $MEMORY_DROPIN (MemoryMax=$MEMORY_MAX)"
if [ "$DRY_RUN" = "yes" ]; then
printf ' + write %s (MemoryAccounting=yes, MemoryMax=%s)\n' "$MEMORY_DROPIN" "$MEMORY_MAX"
else
mkdir -p "$(dirname "$MEMORY_DROPIN")"
{
echo "[Service]"
echo "# systemd cgroup memory backstop, written by the Runway installer (--memory-max). A DROP-IN so"
echo "# it survives upgrades (the installer rewrites the main unit, never this). Keep MemoryMax >="
echo "# -Xmx + headroom (~max(0.5G, 25% of -Xmx)) or the cgroup OOM-kills a JVM inside its own heap."
echo "MemoryAccounting=yes"
printf 'MemoryMax=%s\n' "$MEMORY_MAX"
} > "$MEMORY_DROPIN"
fi
fi
if [ -n "$HEAP_MAX" ]; then
log "writing heap drop-in -> $HEAP_DROPIN (-Xmx$HEAP_MAX)"
if [ "$DRY_RUN" = "yes" ]; then
printf ' + write %s (Environment="JAVA_OPTS=-Xms256m -Xmx%s")\n' "$HEAP_DROPIN" "$HEAP_MAX"
else
mkdir -p "$(dirname "$HEAP_DROPIN")"
{
echo "[Service]"
echo "# JVM heap, written by the Runway installer (--heap). A DROP-IN Environment= overrides the main"
echo "# unit's JAVA_OPTS (last assignment wins) and survives upgrades — a custom -Xmx in the main unit"
echo "# would be reverted on the next install. Add other JVM flags (GC, etc.) here too if needed."
printf 'Environment="JAVA_OPTS=-Xms256m -Xmx%s"\n' "$HEAP_MAX"
} > "$HEAP_DROPIN"
fi
fi
}
java_major() { # <java-home> -> major version, or empty
local jh="$1" out
[ -x "$jh/bin/java" ] || return 0
out="$("$jh/bin/java" -version 2>&1 | head -1)"
echo "$out" | sed -nE 's/.*version "([0-9]+).*/\1/p'
}
# Pick a JDK/JRE >= 25: the --java-home arg, then $JAVA_HOME, then common install
# dirs (Zulu, Temurin, generic openjdk). A JRE is fine — Runway does not compile.
detect_java_home() {
local cand
for cand in "$JAVA_HOME_ARG" "${JAVA_HOME:-}"; do
[ -n "$cand" ] || continue
[ "$(java_major "$cand")" -ge 25 ] 2>/dev/null && { echo "$cand"; return; }
done
for cand in /usr/lib/jvm/*zulu*25* /usr/lib/jvm/*temurin*25* /usr/lib/jvm/*-25-* \
/usr/lib/jvm/java-25-* /usr/lib/jvm/jdk-25* /usr/lib/jvm/jre-25*; do
[ -d "$cand" ] || continue
[ "$(java_major "$cand")" -ge 25 ] 2>/dev/null && { echo "$cand"; return; }
done
echo ""
}
# The TCP ports the install should open in the host firewall: --firewall-ports if
# given, else the app port (--port) if set, else nothing (behind a proxy the app
# port is internal and the firewall is the operator's call).
firewall_target_ports() {
if [ -n "$FIREWALL_PORTS" ]; then echo "${FIREWALL_PORTS//,/ }"; return; fi
local ports=""
[ -n "$PORT" ] && ports="$PORT"
# local TLS with the HTTP->HTTPS redirect also needs port 80 (also serves Let's Encrypt HTTP-01)
[ "$TLS_ENABLED" = "yes" ] && [ "$TLS_REDIRECT" = "yes" ] && ports="${ports:+$ports }80"
echo "$ports"
}
# Open ports in whatever firewall actually manages this box. firewalld and an
# ALREADY-active ufw are driven directly; anything else is left untouched (we
# never enable ufw — that can drop the SSH session). Best-effort: warns, never dies.
open_firewall() {
local ports; ports="$(firewall_target_ports)"
[ -n "$ports" ] || { warn "no firewall ports to open (set --port or --firewall-ports)"; return 0; }
if command -v firewall-cmd >/dev/null 2>&1 && firewall-cmd --state >/dev/null 2>&1; then
log "opening firewalld ports: $ports"
for p in $ports; do run firewall-cmd --permanent --add-port="${p}/tcp" || warn "firewalld: could not add ${p}/tcp"; done
run firewall-cmd --reload || warn "firewalld: reload failed"; return 0
fi
if command -v ufw >/dev/null 2>&1 && ufw status 2>/dev/null | grep -qiE '^Status:[[:space:]]*active'; then
log "opening ufw ports: $ports"
for p in $ports; do run ufw allow "${p}/tcp" || warn "ufw: could not allow ${p}/tcp"; done; return 0
fi
if command -v ufw >/dev/null 2>&1; then
warn "ufw is installed but inactive — not enabling it (could drop your SSH session)."
for p in $ports; do warn " open manually: ufw allow ${p}/tcp"; done
else
warn "no firewalld/ufw manager active — leaving raw nftables/iptables untouched; open ($ports)/tcp yourself if needed."
fi
}
usage() {
sed -n '2,/^# ----/p' "$(readlink -f "$0")" | sed 's/^# \{0,1\}//'
cat <<EOF
Options:
--prefix DIR Install root (default: $PREFIX).
--user NAME Service user to create/use (default: $APP_USER).
--port N App listen port (written to application.yml when non-default; 443 with TLS, else 8080).
First install only, like --tls-keystore: on an existing install (external/application.yml
present) both are refused — they would replace that file; edit server.port / runway.tls.*.
--tls-keystore PATH Terminate TLS here with this PKCS12 (.p12) keystore (implies local TLS).
--tls-password PASS Keystore password (else prompted; unattended installs must pass it).
--tls-redirect Also add an HTTP->HTTPS redirect + ACME webroot on port 80.
--no-tls Skip the TLS prompt (stay plain HTTP behind a proxy).
--secret-key KEY Master key for encrypting stored secrets (SMTP/CAPTCHA/plugin passwords). Persisted
as a root-only systemd drop-in. Blank => auto-generate on first install. An existing
key is kept (never overwritten). Back it up: losing it makes ENC(...) secrets unreadable.
--java-home DIR JDK/JRE 25+ to run under (else auto-detected).
--open-firewall Open the app port in the host firewall (best-effort).
--firewall-ports LIST Comma-separated TCP ports to open (implies --open-firewall).
--no-firewall Never touch the firewall (wins over --open-firewall).
-y, --yes Non-interactive: accept all defaults.
--heap SIZE Set the JVM heap (-Xmx), e.g. 2g / 1536m. Written to an upgrade-surviving drop-in
(runway.service.d/20-heap.conf) — NOT the installer-rewritten main unit — so a custom heap
is never reverted on the next upgrade. Omit to leave the heap as-is.
--memory-max SIZE Set a systemd MemoryMax cgroup backstop, e.g. 3g / 1945M (drop-in 10-memory.conf). Keep it
>= the heap + headroom (~max(0.5G, 25% of -Xmx)). Omit to leave it as-is.
--update-essential-plugins
Accepted and ignored, so existing runbooks keep working: since 1.0.0-rc1 every
upgrade does what it used to ask for (below).
--dry-run Print every privileged action instead of doing it.
-h, --help This help.
Bundled (essential) plugins on an upgrade: the protection plugin under external/plugins/protection is
ALWAYS refreshed from the new bundle — jar, plugin.yml, lib/, templates/ and i18n/ — because it moves in
lockstep with the kernel: an older copy beside a newer kernel is refused, and a refused essential plugin
makes every tenant page answer 503. Nothing you customized is lost: the previous jar and plugin.yml are
kept as <name>.bak (what a rollback restores — Administration §15; written only when the file changes, so
a re-run keeps them), and a template or i18n file you EDITED since it was installed is copied to
<name>.operator-backup-<timestamp> with a warning naming it. A file nobody edited is refreshed with no
backup: the install records what it laid down in external/plugin-manifests/<id>.sha256, which is how it
tells the two apart. Settings live outside the folder (external/plugin-settings/) and are never touched.
The bundle's copy also stays in the release, <prefix>/runway/seed/plugins/<id>/: if the plugin folder is
ever not the running release's (the fail-closed log line says so), copy it back from there and restart.
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
--prefix) PREFIX="${2:?}"; shift 2 ;;
--user) APP_USER="${2:?}"; shift 2 ;;
--port) PORT="${2:?}"; shift 2 ;;
--java-home) JAVA_HOME_ARG="${2:?}"; shift 2 ;;
--open-firewall) OPEN_FIREWALL="yes"; shift ;;
--firewall-ports) FIREWALL_PORTS="${2:?}"; OPEN_FIREWALL="yes"; shift 2 ;;
--no-firewall) NO_FIREWALL="yes"; shift ;;
--tls-keystore) TLS_KEYSTORE="${2:?}"; TLS_ENABLED="yes"; shift 2 ;;
--tls-password) TLS_PASSWORD="${2:?}"; shift 2 ;;
--tls-redirect) TLS_REDIRECT="yes"; shift ;;
--no-tls) NO_TLS="yes"; shift ;;
--secret-key) SECRET_KEY="${2:?}"; shift 2 ;;
-y|--yes|--non-interactive) INTERACTIVE="no"; shift ;;
--update-essential-plugins)
# Kept so pre-rc1 runbooks still run; the refresh it used to opt into is now every upgrade's.
log "--update-essential-plugins: nothing to do — every upgrade refreshes the bundled plugins now"
shift ;;
--heap) HEAP_MAX="${2:?}"; shift 2 ;;
--memory-max) MEMORY_MAX="${2:?}"; shift 2 ;;
--dry-run) DRY_RUN="yes"; shift ;;
-h|--help) usage; exit 0 ;;
*) die "unknown argument: $1 (see --help)" ;;
esac
done
PORT_FLAG="$PORT" # what --port said (the default is filled in below), so a refusal names only flags actually given
# --no-firewall wins over --open-firewall regardless of order.
[ "$NO_FIREWALL" = "yes" ] && OPEN_FIREWALL="no"
# Validate memory sizes (a number optionally followed by K/M/G — systemd + JVM both accept these).
for __sz in "$HEAP_MAX" "$MEMORY_MAX"; do
case "$__sz" in
"") : ;;
*[!0-9kmgKMG]*|*[kmgKMG]*[kmgKMG]*|[!0-9]*) die "invalid memory size: '$__sz' (use e.g. 2g, 1536m, 3G)" ;;
esac
done
# A heap without a matching cap is a footgun: if an existing/!new MemoryMax is below -Xmx it OOM-kills the JVM.
if [ -n "$HEAP_MAX" ] && [ -z "$MEMORY_MAX" ] && [ -f "$MEMORY_DROPIN" ]; then
warn "set --heap $HEAP_MAX but not --memory-max; ensure $MEMORY_DROPIN's MemoryMax >= -Xmx + headroom (see ADMINISTRATION.md §15)"
fi
# Decide interactivity: a TTY on stdin => prompt, unless -y forced it off.
[ "$INTERACTIVE" = "auto" ] && { [ -t 0 ] && INTERACTIVE="yes" || INTERACTIVE="no"; }
[ "$(id -u)" -eq 0 ] || [ "$DRY_RUN" = "yes" ] || die "run as root (sudo) — or use --dry-run"
# --- interactive setup (only on a TTY, unless -y) — flags supplied become the prompt defaults ---------
prompt_value PREFIX "Install location (prefix)" "$PREFIX"
prompt_value APP_USER "Service user" "$APP_USER"
# An existing install keeps its listen port and TLS in external/application.yml, beside the setup wizard's
# application-superadmin pin and whatever else the operator put there. The installer can only WRITE that file
# whole (merging YAML from shell would be a guess about the operator's formatting), so the port/TLS choices are
# first-install only: on an existing install they are not asked, and the flags are refused below.
APP_CONFIG="$PREFIX/$APP-data/external/application.yml"
HAVE_APP_CONFIG="no"; [ -e "$APP_CONFIG" ] && HAVE_APP_CONFIG="yes"
# TLS termination. A given --tls-keystore already implies local TLS; otherwise ask (unless --no-tls / -y).
if [ "$INTERACTIVE" = "yes" ] && [ -z "$TLS_KEYSTORE" ] && [ "$NO_TLS" != "yes" ] && [ "$HAVE_APP_CONFIG" = "no" ]; then
prompt_yesno TLS_ENABLED "Terminate TLS in Runway itself? (No = plain HTTP behind a reverse proxy)" "no"
fi
if [ "$TLS_ENABLED" = "yes" ]; then
[ -n "$TLS_KEYSTORE" ] || prompt_value TLS_KEYSTORE "Path to the PKCS12 keystore (.p12)" ""
[ -n "$TLS_PASSWORD" ] || prompt_secret TLS_PASSWORD "Keystore password"
[ "$INTERACTIVE" = "yes" ] && prompt_yesno TLS_REDIRECT \
"Also add an HTTP->HTTPS redirect on port 80 (serves Let's Encrypt HTTP-01)?" "$TLS_REDIRECT"
fi
# App listen port: default HTTPS 443 for local TLS, else HTTP 8080 (prompted on a TTY).
# (Not asked on an existing install: its port is whatever its application.yml says.)
if [ -z "$PORT" ]; then
{ [ "$TLS_ENABLED" = "yes" ] && PORT="443" || PORT="8080"; }
[ "$HAVE_APP_CONFIG" = "yes" ] || \
prompt_value PORT "$([ "$TLS_ENABLED" = yes ] && echo 'HTTPS port' || echo 'HTTP port')" "$PORT"
fi
# Secret-encryption key: prompt only on a FRESH install (no existing key drop-in); blank => auto-generate below.
if [ "$INTERACTIVE" = "yes" ] && [ -z "$SECRET_KEY" ] && ! [ -f "$SECRET_DROPIN" ]; then
prompt_value SECRET_KEY "Secret key for stored secrets (SMTP/CAPTCHA passwords; leave empty to auto-generate)" ""
fi
# Validate TLS inputs, and decide what (if anything) to write to application.yml.
if [ "$TLS_ENABLED" = "yes" ]; then
[ -n "$TLS_KEYSTORE" ] || die "local TLS requested but no keystore given (--tls-keystore PATH)"
[ -e "$TLS_KEYSTORE" ] || warn "keystore not found at $TLS_KEYSTORE — the installer copies it into the deployment, so it should exist here now (see ADMINISTRATION §7.1 for PEM→PKCS12)"
[ -n "$TLS_PASSWORD" ] || warn "no keystore password given — TLS start fails fast on a blank password"
fi
WRITE_PORT="no"; [ -n "$PORT" ] && [ "$PORT" != "8080" ] && WRITE_PORT="yes"
WRITE_CONFIG="no"; { [ "$TLS_ENABLED" = "yes" ] || [ "$WRITE_PORT" = "yes" ]; } && WRITE_CONFIG="yes"
# Refuse — before anything is changed — a first-install option that would replace an existing application.yml.
# Refusal rather than a merge: this script has no YAML parser, and a line-based edit of a file the operator and the
# wizard have both written (comments, an existing server:/runway: map, other keys under them) can produce a
# duplicate key, which stops the start just as surely. Editing two keys by hand, with the manual, cannot.
if [ "$WRITE_CONFIG" = "yes" ] && [ "$HAVE_APP_CONFIG" = "yes" ]; then
__flags=""; __keys=""; __what="is a first-install option"
[ "$WRITE_PORT" = "yes" ] && __keys="server.port"
[ -n "$PORT_FLAG" ] && [ "$WRITE_PORT" = "yes" ] && __flags="--port $PORT"
if [ "$TLS_ENABLED" = "yes" ]; then
[ -n "$__flags" ] && __what="are first-install options"
__flags="${__flags:+$__flags and }--tls-keystore"
__keys="${__keys:+$__keys and }runway.tls.* (enabled, keystore, keystore-password, key-alias, redirect-http)"
fi
die "$APP_CONFIG already exists, so this is an existing install: $__flags $__what and would replace that file, losing the setup wizard's superadmin pin (the platform would reopen /setup) and every other setting in it. Nothing was changed. Re-run without it — an upgrade needs only -y — and to change the listen port or TLS, edit $__keys in that file and restart (ADMINISTRATION §7.1; put a new keystore under $PREFIX/$APP-data/external/tls/)."
fi
# Locate the bundle this script ships in: scripts/ is a sibling of bin/.
BUNDLE="$(dirname "$(dirname "$(readlink -f "$0")")")"
JAR_SRC="$(ls "$BUNDLE"/bin/runway-app-*.jar 2>/dev/null | head -1 || true)"
[ -n "$JAR_SRC" ] || die "no runway-app-*.jar under $BUNDLE/bin"
# The bundled jar is the executable one — carrying spring-boot's `exec` classifier
# (runway-app-<version>-exec.jar). Strip both the artifact prefix and that classifier so the
# release dir is runway-<version>, not runway-<version>-exec.
VERSION="$(basename "$JAR_SRC" .jar)"; VERSION="${VERSION#runway-app-}"; VERSION="${VERSION%-exec}"
[ -n "$VERSION" ] || die "could not determine version from $JAR_SRC"
DEST="$PREFIX/$APP-$VERSION" # the versioned release
LINK="$PREFIX/$APP" # the "current" symlink == RUNWAY_HOME
DATA="$PREFIX/$APP-data" # version-independent editable state
JAVA_HOME_USE="$(detect_java_home)"
[ -n "$JAVA_HOME_USE" ] || warn "no JDK/JRE 25+ found — set --java-home or fix the systemd unit's JAVA_HOME afterward."
# Firewall prompt (interactive only, and only when not forced off).
if [ "$NO_FIREWALL" != "yes" ] && [ "$INTERACTIVE" = "yes" ] && [ "$OPEN_FIREWALL" != "yes" ] && [ -n "$(firewall_target_ports)" ]; then
prompt_yesno OPEN_FIREWALL "Open port(s) $(firewall_target_ports | tr ' ' ,)/tcp in the host firewall" "no"
fi
log "Runway ${VERSION}"
log " release : $DEST"
log " current link : $LINK"
log " data dir : $DATA"
log " service user : $APP_USER"
log " java home : ${JAVA_HOME_USE:-<unset — fix the unit>}"
if [ "$HAVE_APP_CONFIG" = "yes" ]; then
log " port / tls : as configured in $APP_CONFIG (kept — the installer never rewrites it)"
elif [ "$TLS_ENABLED" = "yes" ]; then
log " tls : terminate HERE — HTTPS on :$PORT (keystore $TLS_KEYSTORE → copied to $DATA/external/tls/)$([ "$TLS_REDIRECT" = yes ] && echo ', HTTP->HTTPS redirect on :80')"
else
log " tls : none here — plain HTTP on :$PORT (terminate at a reverse proxy)"
fi
log " firewall : $([ "$OPEN_FIREWALL" = yes ] && echo "open $(firewall_target_ports | tr ' ' ,)/tcp" || echo 'leave unchanged')"
log " plugins : bundled (essential) plugins seeded if missing, else refreshed from this release (previous jar + plugin.yml kept as *.bak)"
[ -d "$BUNDLE/seed" ] && log " repair copy : the bundled plugins also kept in the release, $LINK/seed/plugins/ (Administration §12)"
if [ -f "$SECRET_DROPIN" ]; then
log " secret key : already configured (kept as-is)"
elif [ -n "$SECRET_KEY" ]; then
log " secret key : provided (stored in a root-only drop-in)"
else
log " secret key : auto-generate (stored in a root-only drop-in)"
fi
[ "$DRY_RUN" = "yes" ] && log "(dry run — no changes will be made)"
# --- service user ------------------------------------------------------------
if id "$APP_USER" >/dev/null 2>&1; then
log "service user '$APP_USER' already exists"
else
log "creating service user '$APP_USER'"
run useradd --system --home-dir "$LINK" --shell /usr/sbin/nologin "$APP_USER" \
|| run useradd --system --home-dir "$LINK" --shell /sbin/nologin "$APP_USER"
fi
# --- data dir (version-independent editable state) ---------------------------
run mkdir -p "$DATA/external" "$DATA/logs" "$DATA/backups"
# --- external application.yml (server.port / self-managed TLS), when chosen ---
[ "$TLS_ENABLED" = "yes" ] && [ "$TLS_REDIRECT" = "yes" ] && run mkdir -p "$DATA/external/acme-challenges"
stage_keystore # copy the PKCS12 into $DATA/external/tls and set TLS_KEYSTORE_DEST (before writing the config)
write_app_config # no-op unless TLS or a non-default port was chosen; chmod 600, owned by the service user
# --- seed / update bundled plugins --------------------------------------------
# The bundle ships essential/bundled plugins under seed/plugins/<id>/. On FIRST install each is copied into the
# operator-owned external/plugins/<id>. On a re-run (upgrade) each existing folder is REFRESHED — code, descriptor,
# templates and i18n — because an essential plugin moves in lockstep with the kernel (an old copy is refused and the
# platform fails closed). The previous jar + plugin.yml stay as *.bak for a rollback, and a shipped-manifest
# (external/plugin-manifests/<id>.sha256) tells a file the operator edited (backed up, warned) from one that is
# merely stale. Settings live outside the folder and are never touched.
# The logic lives in plugin-seed.sh, beside this script, so it can be tested without root.
# shellcheck source=plugin-seed.sh
. "$(dirname "$(readlink -f "$0")")/plugin-seed.sh"
seed_bundled_plugins "$BUNDLE" "$DATA"
# --- release dir -------------------------------------------------------------
run mkdir -p "$DEST/bin" "$DEST/scripts"
run cp -f "$JAR_SRC" "$DEST/bin/"
run cp -f "$BUNDLE/bin/runway.sh" "$DEST/bin/runway.sh"
run cp -f "$BUNDLE"/scripts/* "$DEST/scripts/" 2>/dev/null || true
run chmod 0755 "$DEST/bin/runway.sh" "$DEST/scripts/install.sh"
# The bundled plugins stay in the release too (seed/plugins/<id>/), so repairing the essential plugin needs no .bin:
# when external/plugins/<id> is not the running release's copy (a hand-copied kernel jar, a hand edit), the kernel's
# fail-closed message says to copy $LINK/seed/plugins/<id>/ over it. After a rollback the symlink names the older
# release, whose seed/ is the older plugin — the same files as the *.bak pair the upgrade kept. Replaced whole, so a
# file this bundle no longer ships does not linger; owned and relabeled with the rest of the release below, and
# read-only to the service (ProtectSystem=strict, ReadWritePaths is the data dir only). Skipped when the installer
# runs from an installed release (its bundle IS $DEST — removing seed/ would delete the source).
if [ -d "$BUNDLE/seed" ] && [ "$(readlink -m "$BUNDLE")" != "$(readlink -m "$DEST")" ]; then
log "keeping the bundled plugins in the release: $DEST/seed/ (the repair copy — Administration §12)"
run rm -rf "$DEST/seed"
run cp -R "$BUNDLE/seed" "$DEST/seed"
fi
# Editable state is symlinked in, so it survives upgrades. Per-site backup archives
# are a version-independent data dir too (the app writes them to the deployment-root
# backups/ — StorageLayout's default), so they must NOT sit in the versioned release.
run ln -sfn "$DATA/external" "$DEST/external"
run ln -sfn "$DATA/logs" "$DEST/logs"
run ln -sfn "$DATA/backups" "$DEST/backups"
# --- flip the "current" symlink ----------------------------------------------
run ln -sfn "$DEST" "$LINK"
# --- ownership ---------------------------------------------------------------
run chown -R "$APP_USER:$APP_USER" "$DATA"
run chown -h "$APP_USER:$APP_USER" "$LINK"
run chown -R "$APP_USER:$APP_USER" "$DEST"
# --- SELinux relabel (REQUIRED on enforcing RHEL-family; no-op elsewhere) -----
# The bundle unpacked into a user-temp dir, so cp -a-style copies can carry
# user_tmp_t; without a relabel systemd refuses to exec the launcher (203/EXEC).
if command -v restorecon >/dev/null 2>&1; then
log "relabeling SELinux contexts (restorecon)"
run restorecon -RF "$DEST" "$DATA" || warn "restorecon failed (continuing)"
fi
# --- systemd unit ------------------------------------------------------------
# A privileged port (<1024) bound by the non-root service user needs CAP_NET_BIND_SERVICE: 443 for local TLS,
# 80 for the HTTP->HTTPS redirect. The unit template ships that capability commented; enable it only when a
# privileged port is actually in play (least privilege — the common 8080-behind-proxy case gets nothing extra).
NEEDS_NET_BIND="no"
case "$PORT" in ''|*[!0-9]*) : ;; *) [ "$PORT" -lt 1024 ] && NEEDS_NET_BIND="yes" ;; esac
[ "$TLS_REDIRECT" = "yes" ] && NEEDS_NET_BIND="yes"
UNIT_SRC="$BUNDLE/scripts/runway.service"
UNIT_DST="${RUNWAY_UNIT_DST:-/etc/systemd/system/runway.service}" # the override exists for the installer tests
# An upgrade cannot tell which port the existing application.yml configures (no YAML parser here: PORT above is only
# the default), and the unit is rewritten from the template, which ships the capability commented. So an install that
# binds 443 or 80 would lose it on every upgrade and fail to start. Keep what the current unit already grants: it is
# what that server has been running with (an operator who uncommented it by hand gets it kept too).
NET_BIND_KEPT="no"
if [ "$NEEDS_NET_BIND" = "no" ] && [ -f "$UNIT_DST" ] \
&& grep -Eq '^[[:space:]]*AmbientCapabilities=.*CAP_NET_BIND_SERVICE' "$UNIT_DST"; then
NEEDS_NET_BIND="yes"; NET_BIND_KEPT="yes"
fi
if [ -f "$UNIT_SRC" ]; then
log "installing systemd unit -> $UNIT_DST"
if [ "$DRY_RUN" = "yes" ]; then
printf ' + install unit with RUNWAY_HOME=%s JAVA_HOME=%s User=%s ReadWritePaths=%s net-bind-cap=%s\n' \
"$LINK" "${JAVA_HOME_USE:-<unset>}" "$APP_USER" "$DATA" "$NEEDS_NET_BIND"
else
sed -E \
-e "s#^Environment=RUNWAY_HOME=.*#Environment=RUNWAY_HOME=${LINK}#" \
-e "s#^Environment=JAVA_HOME=.*#Environment=JAVA_HOME=${JAVA_HOME_USE:-/usr/lib/jvm/java-25-openjdk}#" \
-e "s#^ExecStart=.*#ExecStart=${LINK}/bin/runway.sh -f#" \
-e "s#^User=.*#User=${APP_USER}#" \
-e "s#^Group=.*#Group=${APP_USER}#" \
-e "s#^ReadWritePaths=.*#ReadWritePaths=${DATA}#" \
"$UNIT_SRC" > "$UNIT_DST"
# Uncomment the capability the template ships commented, but only when binding a privileged port.
if [ "$NEEDS_NET_BIND" = "yes" ]; then
sed -i -E 's/^#[[:space:]]*(AmbientCapabilities=CAP_NET_BIND_SERVICE)/\1/; s/^#[[:space:]]*(CapabilityBoundingSet=CAP_NET_BIND_SERVICE)/\1/' "$UNIT_DST"
if [ "$NET_BIND_KEPT" = "yes" ]; then
log "kept CAP_NET_BIND_SERVICE: the unit being replaced granted it (a privileged port is configured)"
else
log "enabled CAP_NET_BIND_SERVICE (binding privileged port ${PORT}$([ "$TLS_REDIRECT" = yes ] && echo ' and 80'))"
fi
fi
fi
write_secret_key_dropin # first install: generate/persist the secret-encryption key (kept as-is on upgrade)
write_tuning_dropins # --heap / --memory-max: operator memory tuning, in upgrade-surviving drop-ins
run systemctl daemon-reload
run systemctl enable runway.service || warn "could not enable runway.service"
else
warn "no runway.service in the bundle — skipping systemd install"
fi
# --- firewall (opt-in, best-effort) ------------------------------------------
[ "$OPEN_FIREWALL" = "yes" ] && open_firewall
# --- start / restart ---------------------------------------------------------
log "starting the service"
run systemctl restart runway.service || warn "could not start runway.service — check: journalctl -u runway -e"
log "done. Runway ${VERSION} is installed at ${LINK}."
log " status : systemctl status runway"
log " logs : journalctl -u runway -f (and ${DATA}/logs/)"
if [ "$TLS_ENABLED" = "yes" ]; then
log " next : browse to https://<host>:$PORT and complete the first-run setup wizard (it keeps your TLS config)."
[ -e "$TLS_KEYSTORE" ] || log " note : put the keystore at $TLS_KEYSTORE (owned/readable by '$APP_USER') before it will serve TLS."
else
log " next : browse to the app (behind your proxy) and complete the first-run setup wizard."
fi
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
#
# make-release-aliases.sh — after the dist build has produced the versioned artifacts
# runway-<version>-dist.zip and runway-<version>.bin
# in the target directory, this creates the stable-named "latest" aliases and a checksum
# manifest so a Runway release exposes a permanent, always-newest download.
#
# 1. Stable-named alias copies (byte-identical to the versioned originals):
# runway-latest-dist.zip runway-latest.bin
# Gitea resolves <repo>/releases/download/latest/<name> to the newest release's asset,
# but ONLY when the asset NAME is stable across releases — the versioned names are not,
# so these fixed-name aliases give the permanent link. "latest" in the name also makes a
# downloaded file self-describing.
#
# 2. SHA256SUMS over every shippable artifact (versioned + aliases + the plugin author's SPI
# jars and poms that make-spi-assets.sh staged). The aliases share the hash of their
# original; SHA256SUMS itself has a stable name, so it too has a latest link. The SPI
# files are listed after the four installer lines and get no alias: an author pins an
# exact kernel version, never "latest" (docs/PLUGIN-DEVELOPMENT.md §3).
#
# Wired into runway-dist's `dist` profile (maven-antrun), so it drops out of
# `mvn -P dist package` automatically — no manual step. Stock tools only (bash, cp, sha256sum).
#
# Usage: make-release-aliases.sh <target-dir> <version>
set -euo pipefail
TARGET="${1:?usage: make-release-aliases.sh <target-dir> <version>}"
VERSION="${2:?usage: make-release-aliases.sh <target-dir> <version>}"
VERSION="${VERSION#v}"
zip="runway-${VERSION}-dist.zip"
bin="runway-${VERSION}.bin"
cd "$TARGET"
[ -f "$zip" ] || { echo "[aliases] missing $zip in $TARGET" >&2; exit 1; }
[ -f "$bin" ] || { echo "[aliases] missing $bin in $TARGET" >&2; exit 1; }
# The plugin author's artifacts (make-spi-assets.sh). Required: a release without them strands every
# third-party plugin build on that version, and publish-release.sh requires and uploads the same set.
spi=()
for m in runway-spi runway-spi-testkit; do
for f in "${m}-${VERSION}.jar" "${m}-${VERSION}-sources.jar" "${m}-${VERSION}.pom"; do
[ -f "$f" ] || { echo "[aliases] missing $f in $TARGET — run make-spi-assets.sh first" >&2; exit 1; }
spi+=( "$f" )
done
done
cp -f "$zip" "runway-latest-dist.zip"
cp -f "$bin" "runway-latest.bin"
# Deterministic order: the versioned installer pair, its aliases, then the SPI files.
sha256sum "$zip" "$bin" "runway-latest-dist.zip" "runway-latest.bin" "${spi[@]}" > SHA256SUMS
echo "[aliases] latest aliases + SHA256SUMS written to $TARGET:"
ls -lh runway-*-dist.zip runway-*.bin "${spi[@]}" SHA256SUMS 2>/dev/null | awk '{printf " %-46s %s\n", $9, $5}'
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env bash
#
# Build the single-file self-extracting installer runway-<version>.bin from the
# distribution zip produced by the Maven `dist` profile.
#
# Invoked automatically by `mvn -P dist package` (via maven-antrun-plugin), and
# runnable by hand:
#
# scripts/make-selfextract.sh \
# --zip runway-app/target/runway-<version>-dist.zip \
# --stub scripts/selfextract-stub.sh \
# --out runway-app/target/runway-<version>.bin
#
# The .bin is a copy of the stub script with a gzip-compressed tar of the bundle
# directory appended after the __RUNWAY_ARCHIVE__ marker. Only stock tools are
# needed — at build time (bash, unzip, tar, gzip, sed) and at install time (bash,
# tar, gzip, awk, tail); no `makeself` dependency.
#
set -euo pipefail
ZIP=""; STUB=""; OUT=""
while [ $# -gt 0 ]; do
case "$1" in
--zip) ZIP="${2:?}"; shift 2 ;;
--stub) STUB="${2:?}"; shift 2 ;;
--out) OUT="${2:?}"; shift 2 ;;
*) echo "make-selfextract: unknown arg: $1" >&2; exit 2 ;;
esac
done
[ -n "$ZIP" ] || { echo "make-selfextract: --zip is required" >&2; exit 2; }
[ -n "$STUB" ] || { echo "make-selfextract: --stub is required" >&2; exit 2; }
[ -n "$OUT" ] || { echo "make-selfextract: --out is required" >&2; exit 2; }
[ -f "$ZIP" ] || { echo "make-selfextract: zip not found: $ZIP" >&2; exit 1; }
[ -f "$STUB" ] || { echo "make-selfextract: stub not found: $STUB" >&2; exit 1; }
command -v unzip >/dev/null || { echo "make-selfextract: 'unzip' is required" >&2; exit 1; }
# Derive the version from the zip name: runway-<version>-dist.zip
base="$(basename "$ZIP")"
version="${base#runway-}"; version="${version%-dist.zip}"
[ -n "$version" ] || { echo "make-selfextract: cannot parse version from $base" >&2; exit 1; }
bundle_dir="runway-${version}"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
echo "[make-selfextract] unpacking $ZIP"
unzip -q "$ZIP" -d "$work"
[ -d "$work/$bundle_dir" ] || { echo "make-selfextract: $bundle_dir not found inside zip" >&2; exit 1; }
# Ensure the scripts are executable inside the payload.
chmod 0755 "$work/$bundle_dir/scripts/install.sh" \
"$work/$bundle_dir/bin/runway.sh" 2>/dev/null || true
echo "[make-selfextract] building payload"
payload="$work/payload.tar.gz"
# Reproducible payload. Three separate sources of drift, all pinned:
# --mtime tar records each entry's mtime, which is "now" for anything the build just staged
# --owner/group + --numeric-owner the builder's uid/gid would otherwise land in the archive
# --sort=name directory read order is filesystem-dependent, so entry ORDER varies between machines
# gzip -n gzip writes the source mtime AND name into its own header unless told not to
# Without these a rebuild of identical source produces a different .bin, which is exactly how the
# "the tree holds what we shipped" invariant quietly stopped holding for the plugin artifacts.
#
# The instant is the cut's, and there is ONE copy of it: the reactor pom's project.build.outputTimestamp, which also
# stamps every jar entry. The Maven build passes it in as BUILD_TIMESTAMP; a hand run reads it from the pom. (Until
# 0.5.0-beta14 this script kept its own hand-edited default, so a cut that bumped only one of the two still built
# reproducibly — building twice cannot catch it — but shipped a jar and a .bin claiming different instants.)
# SOURCE_DATE_EPOCH, the reproducible-builds convention, still wins when set. An instant that cannot be read is an
# error, never a silent fallback: a fallback is how the two copies drifted.
if [ -z "${SOURCE_DATE_EPOCH:-}" ] && [ -z "${BUILD_TIMESTAMP:-}" ]; then
pom="$(dirname "$(readlink -f "$0")")/../pom.xml"
BUILD_TIMESTAMP="$(sed -n 's:.*<project.build.outputTimestamp>\(.*\)</project.build.outputTimestamp>.*:\1:p' \
"$pom" 2>/dev/null | head -n1)"
fi
if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
SOURCE_EPOCH="$SOURCE_DATE_EPOCH"
elif [[ "${BUILD_TIMESTAMP:-}" =~ ^[0-9]+$ ]]; then
SOURCE_EPOCH="$BUILD_TIMESTAMP" # outputTimestamp may also be written as epoch seconds
elif [ -n "${BUILD_TIMESTAMP:-}" ] && SOURCE_EPOCH="$(date -u -d "$BUILD_TIMESTAMP" +%s 2>/dev/null)"; then
:
else
echo "make-selfextract: cannot read the build instant ('${BUILD_TIMESTAMP:-}') — set" >&2
echo " project.build.outputTimestamp in the reactor pom, or BUILD_TIMESTAMP / SOURCE_DATE_EPOCH" >&2
exit 1
fi
echo "[make-selfextract] payload timestamp: $(date -u -d "@${SOURCE_EPOCH}" +%Y-%m-%dT%H:%M:%SZ)"
tar --sort=name --mtime="@${SOURCE_EPOCH}" --owner=0 --group=0 --numeric-owner \
-cf - -C "$work" "$bundle_dir" | gzip -n -9 > "$payload"
echo "[make-selfextract] writing $OUT"
# Stub with the version substituted, then the marker (already in the stub), then
# the binary payload appended.
sed "s/@VERSION@/${version}/g" "$STUB" > "$OUT"
cat "$payload" >> "$OUT"
chmod 0755 "$OUT"
bytes="$(wc -c < "$OUT")"
echo "[make-selfextract] done: $OUT ($(( bytes / 1024 / 1024 )) MB)"
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env bash
#
# make-spi-assets.sh — stage the plugin author's compile-time artifacts next to the release files.
#
# A third-party plugin compiles against mx.quest:runway-spi (provided) and tests against
# mx.quest:runway-spi-testkit (test). No Maven repository serves them: they travel as assets of the kernel
# release (on the project's releases page), and an author installs them into ~/.m2 with `mvn install:install-file`
# (docs/PLUGIN-DEVELOPMENT.md §3). So every release carries, for VERSION = the kernel release version:
#
# runway-spi-<VERSION>.jar runway-spi-<VERSION>-sources.jar runway-spi-<VERSION>.pom
# runway-spi-testkit-<VERSION>.jar runway-spi-testkit-<VERSION>-sources.jar runway-spi-testkit-<VERSION>.pom
#
# The jars are copied byte-for-byte from the reactor modules' target/ (both modules attach a sources jar; all
# four honour project.build.outputTimestamp, so they are reproducible). The poms are CONSUMER poms, generated
# here: the module poms inherit their groupId and version from the reactor parent (mx.quest:runway), which is
# not published, and whose own parent is Spring Boot's. Installed as-is, they would make every author's build
# warn "The POM for mx.quest:runway-spi … is invalid, transitive dependencies … will not be available" and drop
# the testkit's dependency on runway-spi. The consumer pom states the coordinates outright, has no parent, and
# keeps only the non-test dependencies with their versions resolved — read from the module pom, so a dependency
# added there cannot be silently missing here (an unresolvable version is refused, not guessed).
#
# Wired into runway-dist's `dist` profile before make-release-aliases.sh, which lists these files in SHA256SUMS
# and refuses when one is missing. Tools: bash, cp, python3 (standard library only; output is deterministic).
#
# Usage: make-spi-assets.sh <reactor-root> <target-dir> <version>
set -euo pipefail
usage="usage: make-spi-assets.sh <reactor-root> <target-dir> <version>"
ROOT="${1:?$usage}"
TARGET="${2:?$usage}"
VERSION="${3:?$usage}"
VERSION="${VERSION#v}"
command -v python3 >/dev/null 2>&1 || { echo "[spi-assets] python3 is required to write the consumer poms" >&2; exit 1; }
mkdir -p "$TARGET"
for module in runway-spi runway-spi-testkit; do
for f in "${module}-${VERSION}.jar" "${module}-${VERSION}-sources.jar"; do
src="$ROOT/$module/target/$f"
[ -f "$src" ] || { echo "[spi-assets] missing $src — build the reactor with 'mvn -P dist package'" >&2; exit 1; }
cp -f "$src" "$TARGET/$f"
done
part="$TARGET/${module}-${VERSION}.pom.part"
if ! python3 - "$ROOT/$module/pom.xml" "$module" "$VERSION" > "$part" <<'PY'
import sys, re
import xml.etree.ElementTree as ET
from xml.sax.saxutils import escape
pom_path, artifact, version = sys.argv[1], sys.argv[2], sys.argv[3]
NS = {"m": "http://maven.apache.org/POM/4.0.0"}
root = ET.parse(pom_path).getroot()
def text(el, path, default=None):
found = el.find(path, NS)
return default if found is None or found.text is None else " ".join(found.text.split())
def die(msg):
sys.stderr.write("[spi-assets] %s: %s\n" % (pom_path, msg))
sys.exit(1)
if text(root, "m:artifactId") != artifact:
die("artifactId is %r, expected %r" % (text(root, "m:artifactId"), artifact))
group = text(root, "m:groupId") or text(root, "m:parent/m:groupId")
if group != "mx.quest":
die("groupId is %r, expected 'mx.quest'" % group)
def resolve(value, what):
value = value.replace("${project.version}", version).replace("${project.groupId}", group)
if "${" in value:
die("cannot resolve %s %r for the consumer pom" % (what, value))
return value
deps = []
for d in root.findall("m:dependencies/m:dependency", NS):
scope = text(d, "m:scope", "compile")
if scope == "test":
continue
g, a, v = text(d, "m:groupId"), text(d, "m:artifactId"), text(d, "m:version")
if not v:
die("dependency %s:%s has no explicit version (managed versions do not survive without the parent)" % (g, a))
deps.append((resolve(g, "groupId"), a, resolve(v, "version"), scope, text(d, "m:optional")))
out = []
w = out.append
w('<?xml version="1.0" encoding="UTF-8"?>')
w('<!-- Consumer pom for the Runway release assets, generated by scripts/make-spi-assets.sh from %s/pom.xml:' % artifact)
w(' no parent, coordinates and dependency versions resolved. Install with')
w(' mvn install:install-file -Dfile=%s-%s.jar -DpomFile=%s-%s.pom -->' % (artifact, version, artifact, version))
w('<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
w(' xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">')
w(' <modelVersion>4.0.0</modelVersion>')
w(' <groupId>%s</groupId>' % escape(group))
w(' <artifactId>%s</artifactId>' % escape(artifact))
w(' <version>%s</version>' % escape(version))
w(' <packaging>jar</packaging>')
for tag in ("name", "description"):
v = text(root, "m:" + tag)
if v:
w(' <%s>%s</%s>' % (tag, escape(v), tag))
w(' <organization>')
w(' <name>Quest ICT SAS de CV</name>')
w(' <url>https://quest.mx</url>')
w(' </organization>')
w(' <licenses>')
w(' <license>')
w(' <name>GNU Affero General Public License v3.0, with the Runway additional permission for plugins</name>')
w(' <url>https://www.gnu.org/licenses/agpl-3.0.txt</url>')
w(' <distribution>repo</distribution>')
w(' <comments>Additional permission for plugins: META-INF/LICENSE-EXCEPTION in this jar.</comments>')
w(' </license>')
w(' </licenses>')
if deps:
w(' <dependencies>')
for g, a, v, scope, optional in deps:
w(' <dependency>')
w(' <groupId>%s</groupId>' % escape(g))
w(' <artifactId>%s</artifactId>' % escape(a))
w(' <version>%s</version>' % escape(v))
if scope != "compile":
w(' <scope>%s</scope>' % escape(scope))
if optional:
w(' <optional>%s</optional>' % escape(optional))
w(' </dependency>')
w(' </dependencies>')
w('</project>')
sys.stdout.write("\n".join(out) + "\n")
PY
then
rm -f "$part"
exit 1
fi
mv -f "$part" "$TARGET/${module}-${VERSION}.pom"
done
echo "[spi-assets] plugin-author artifacts for ${VERSION} staged in $TARGET:"
(cd "$TARGET" && ls -l runway-spi*-"${VERSION}"*.jar runway-spi*-"${VERSION}".pom | awk '{printf " %-46s %s\n", $9, $5}')
+155
View File
@@ -0,0 +1,155 @@
# plugin-seed.sh — seeding and refreshing the bundled (essential) plugins. Sourced by install.sh; also sourced
# on its own by test-plugin-seed.sh, which is why it defines functions and runs nothing at load time.
#
# The question this file exists to answer correctly: when an upgrade finds that a plugin's template or i18n
# file differs from the one being installed, WHO changed it? Comparing the installed copy with the incoming
# one cannot say — a difference means only "not the new version". Until 0.5.0-beta14 the installer guessed
# "the operator", backed the file up and said so, and it was wrong every time the change was ours: hashing the
# files before two upgrades proved the "operator edits" were the previous shipped versions.
#
# So the installer now remembers what it laid down. A SHIPPED-MANIFEST per plugin records the SHA-256 of
# every template/i18n file as installed, and lives OUTSIDE the plugin folder (external/plugin-manifests/), so
# it survives the folder being replaced. A differing file then falls into one of three cases:
#
# matches the manifest → nobody touched it since we installed it; it is just stale → refresh, no backup
# differs from manifest → the operator edited it → back it up, warn, refresh
# no manifest entry → installed by a release that kept no record → back it up, warn, refresh
#
# The third case fails SAFE rather than quiet: guessing "unmodified" would silently destroy a real edit. It
# fires once — the refresh writes a manifest, so the next upgrade is exact.
#
# Manifest format (part of the on-disk contract): a header line, then sha256sum(1) lines.
# # runway shipped-manifest v1 plugin=<id>
# <64 hex> templates/app-dos.html
PLUGIN_MANIFEST_HEADER_PREFIX="# runway shipped-manifest v1"
# _ps_sha <file> — the file's SHA-256, hex only.
_ps_sha() { sha256sum "$1" | cut -d' ' -f1; }
# _ps_manifest_hash <manifest> <relpath> — the recorded hash for relpath, or nothing.
_ps_manifest_hash() {
[ -f "$1" ] || return 0
awk -v p="$2" 'substr($0,1,1) != "#" && NF >= 2 && substr($0, 67) == p { print $1; exit }' "$1"
}
# _ps_write_manifest <plugin-src-dir> <manifest> <id> — record every shipped template/i18n file. Written to a
# temp file and renamed, so an interrupted install never leaves a half manifest (which would read as
# "no entry" → the safe warning, but still better avoided).
_ps_write_manifest() {
local src="$1" manifest="$2" id="$3" sub f
if [ "${DRY_RUN:-no}" = "yes" ]; then
printf ' + write shipped-manifest %s\n' "$manifest"
return 0
fi
mkdir -p "$(dirname "$manifest")"
{
printf '%s plugin=%s\n' "$PLUGIN_MANIFEST_HEADER_PREFIX" "$id"
for sub in templates i18n; do
[ -d "$src/$sub" ] || continue
for f in "$src/$sub"/*; do
[ -f "$f" ] || continue
printf '%s %s\n' "$(_ps_sha "$f")" "$sub/$(basename "$f")"
done
done
} > "$manifest.tmp"
mv -f "$manifest.tmp" "$manifest"
}
# seed_bundled_plugins <bundle-dir> <data-dir>
# Seeds every bundled plugin a fresh install lacks, and REFRESHES every one an upgrade finds — always; there is no
# opt-in any more. The bundled plugins are the essential ones (today: protection), and an essential plugin is
# lockstep with the kernel: it is the one plugin allowed to link kernel internals, and its descriptor names the
# kernel's SPI level. An old copy beside a new kernel is refused — the essential plugin blocked puts the platform in
# fail-closed mode, every tenant page 503 — or crashes on a missing class. Until 1.0.0-rc1 the refresh needed
# --update-essential-plugins, and an upgrade run without it left the old copy in place; with SPI 1.0.0's mandatory
# floor that became a 503 on every site, so the refresh is part of every upgrade. What makes
# "always" safe is what the refresh keeps:
# - the previous jar and plugin.yml as <name>.bak (written only when the file changes) — the rollback pair;
# - a template/i18n file the operator edited, as <name>.operator-backup-<stamp>, with a warning naming it;
# - settings, which live outside the plugin folder (external/plugin-settings/) and are never touched.
# A hand-set `enabled: false` in plugin.yml is not kept: an essential plugin that does not load fails closed anyway,
# so the refresh can only turn a 503 back into a protected site. The kept plugin.yml.bak holds the edit.
# Uses install.sh's log/warn/run (and DRY_RUN) when present; test-plugin-seed.sh provides its own.
seed_bundled_plugins() {
local bundle="$1" data="$2"
local pdir pid pdst manifest f jn sub src fn dstf rel recorded current bak stamp changed
[ -d "$bundle/seed/plugins" ] || return 0
stamp="$(date -u +%Y%m%d-%H%M%SZ)"
for pdir in "$bundle"/seed/plugins/*/; do
[ -d "$pdir" ] || continue
pdir="${pdir%/}"
pid="$(basename "$pdir")"
pdst="$data/external/plugins/$pid"
manifest="$data/external/plugin-manifests/$pid.sha256"
if [ ! -e "$pdst" ]; then
log "seeding bundled plugin '$pid'"
run mkdir -p "$data/external/plugins"
run cp -a "$pdir" "$pdst"
_ps_write_manifest "$pdir" "$manifest" "$pid"
else
log "refreshing bundled plugin '$pid' from this release (it moves with the kernel; files you edited are backed up)"
changed=no
# The previous jar AND descriptor are kept as <name>.bak: they are what a ROLLBACK needs. The refreshed
# folder outlives the kernel it came with (external/ is version-independent), so flipping /opt/runway
# back to an older release puts that kernel in front of the new jar — which may link SPI types the old
# kernel lacks (0.5.0-beta14's protection 1.5.0 did: beta13 failed to start). Restoring both .bak files
# is the rollback step. The descriptor matters as much as the jar: it carries the requiresSpi floor, so
# the new descriptor beside the old jar would get the old jar refused.
# Backed up only when the file actually changes, so re-running the same installer (it is idempotent)
# never overwrites the previous release's copy with the current one.
for f in "$pdir"/plugin.yml "$pdir"/*.jar; do
[ -f "$f" ] || continue
jn="$(basename "$f")"
if [ -f "$pdst/$jn" ] && cmp -s "$f" "$pdst/$jn"; then
continue # already this release's file
fi
changed=yes
if [ -f "$pdst/$jn" ]; then
log "plugin '$pid': $jn replaced (the previous one kept as $jn.bak, for a rollback)"
run cp -f "$pdst/$jn" "$pdst/$jn.bak"
fi
run cp -f "$f" "$pdst/$jn"
done
[ -d "$pdir/lib" ] && { run mkdir -p "$pdst/lib"; run cp -a "$pdir/lib/." "$pdst/lib/"; }
# Templates and i18n too: an essential plugin's SCREENS ship in these files, so skipping them would
# mean a release that adds a panel never reaches an upgraded install (0.5.0-beta10's "Recently ended
# blocks" did exactly that — no error, just a feature that was not there).
for sub in templates i18n; do
[ -d "$pdir/$sub" ] || continue
run mkdir -p "$pdst/$sub"
for src in "$pdir/$sub"/*; do
[ -f "$src" ] || continue
fn="$(basename "$src")"
rel="$sub/$fn"
dstf="$pdst/$rel"
if [ ! -f "$dstf" ]; then
changed=yes
run cp -f "$src" "$dstf" # new in this release
continue
fi
cmp -s "$src" "$dstf" && continue # already current — nothing to say
changed=yes
current="$(_ps_sha "$dstf")"
recorded="$(_ps_manifest_hash "$manifest" "$rel")"
if [ -n "$recorded" ] && [ "$recorded" = "$current" ]; then
log "plugin '$pid': $rel updated (unchanged since it was installed — no backup needed)"
else
bak="$dstf.operator-backup-$stamp"
if [ -n "$recorded" ]; then
warn "plugin '$pid': $rel was edited after it was installed — your copy saved as $(basename "$bak")"
else
warn "plugin '$pid': $rel differs from the new version, and this install has no record of what was installed before (it predates the shipped-manifest), so it cannot tell your edit from our update — your copy saved as $(basename "$bak") as a precaution"
fi
run cp -f "$dstf" "$bak"
fi
run cp -f "$src" "$dstf"
done
done
# Every shipped file is now installed as shipped, so the manifest is simply the shipped set.
_ps_write_manifest "$pdir" "$manifest" "$pid"
[ "$changed" = "no" ] && log "plugin '$pid' was already this release's — nothing changed"
fi
done
return 0
}
+56
View File
@@ -0,0 +1,56 @@
# release-notes.sh — the release body of a Runway version, taken from CHANGELOG.md. Sourced by publish-release.sh;
# also sourced on its own by test-release-notes.sh, which is why it defines functions and runs nothing at load time.
#
# Why this is a gate and not a convenience. The release body IS the upgrade notes an operator reads
# before upgrading. beta10 shipped with none (the body said "See CHANGELOG.md"), so the notes now come from the
# CHANGELOG section keyed by the version. That made a MISSING section impossible, but not a section WITHOUT the
# part an operator acts on: in 0.5.0-beta14 the [Unreleased] section — 47 KB of entries — had no
# "Upgrading — read this first" at all, while the development guide claimed the publish script refused exactly
# that. It did not. Now it does: the section must open with that heading, the way every release since beta10 has.
# The heading every release section must open with (its first "### " heading). Part of the CHANGELOG contract.
RELEASE_NOTES_UPGRADING_HEADING="### Upgrading — read this first"
# Above this many bytes the body risks a database column limit on the Gitea side (a TEXT column is 64 KiB on
# MySQL/MariaDB). The create-release call would then fail before any asset is uploaded — safe, but unpublished.
RELEASE_NOTES_WARN_BYTES=60000
# release_notes_extract <changelog> <version> — print the body of the "## [<version>]" section (heading line
# excluded, surrounding blank lines trimmed); print nothing when there is no such section. The section ends at the
# next "## [" heading or at the end of the file.
release_notes_extract() {
python3 - "$1" "$2" <<'EXTRACT'
import re, sys
text = open(sys.argv[1], encoding="utf-8").read()
version = sys.argv[2]
m = re.search(r"^## \[" + re.escape(version) + r"\][^\n]*\n(.*?)(?=^## \[|\Z)", text, re.S | re.M)
print(m.group(1).strip() if m else "")
EXTRACT
}
# release_notes_check <notes> <version> — validate an extracted body. Returns 0 when it may be published; otherwise
# prints the reason on stderr and returns 1 (no section) or 2 (no upgrade part, or not first). A body over
# RELEASE_NOTES_WARN_BYTES only warns: whether it fails depends on the server's database, which is not known here.
release_notes_check() {
local notes="$1" version="$2" first bytes
if [ -z "$notes" ]; then
echo "refusing to publish: CHANGELOG.md has no '## [${version}]' section (or it is empty)." >&2
echo " The release body IS the upgrade notes — write the section first (flip [Unreleased] to" >&2
echo " [${version}]), then re-run. beta10 shipped with no notes because nothing enforced this." >&2
return 1
fi
first="$(printf '%s\n' "$notes" | grep -m1 '^### ' || true)"
if [ "$first" != "$RELEASE_NOTES_UPGRADING_HEADING" ]; then
echo "refusing to publish: the '## [${version}]' section does not open with" >&2
echo " '${RELEASE_NOTES_UPGRADING_HEADING}' (its first '### ' heading is: '${first:-none}')." >&2
echo " Write the operator's steps there — what to run, what to expect, how to roll back — even if the" >&2
echo " answer is 'a kernel-only upgrade, nothing else'. It is the part an operator acts on." >&2
return 2
fi
bytes="$(printf '%s' "$notes" | wc -c)"
if [ "$bytes" -gt "$RELEASE_NOTES_WARN_BYTES" ]; then
echo "WARNING: the release notes are ${bytes} bytes; a Gitea on MySQL/MariaDB stores at most 65535." >&2
echo " If the create-release call fails, shorten the CHANGELOG section and re-run." >&2
fi
return 0
}
+45
View File
@@ -0,0 +1,45 @@
[Unit]
Description=Runway (multi-site web platform)
# Runway is filesystem/YAML-backed — no database service to order against.
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=runway
Group=runway
Environment=RUNWAY_HOME=/opt/runway
# JDK/JRE 25+. install.sh rewrites this to the JAVA_HOME it detected on the host
# (e.g. an Azul Zulu JRE 25). A JRE is fine for running; javac is not needed.
Environment=JAVA_HOME=/usr/lib/jvm/java-25-openjdk
# Quote the whole assignment: systemd splits Environment= on whitespace, so an
# unquoted value with spaces makes the heap flags parse as bogus standalone
# assignments and get dropped. runway.sh then word-splits ${JAVA_OPTS}.
Environment="JAVA_OPTS=-Xms256m -Xmx1g"
ExecStart=/opt/runway/bin/runway.sh -f
# Sandboxing: least privilege on the host filesystem. Everything Runway writes is
# under its external tree and the launcher log dir.
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/opt/runway/external /opt/runway/logs /opt/runway/backups
# Uncomment ONLY if Runway must bind a privileged port (< 1024) itself — e.g. it
# terminates TLS on 443 or serves 80 directly rather than behind a reverse proxy.
# The house default is to run plain HTTP on a high port behind HAProxy/nginx, so
# these stay off. NoNewPrivileges remains compatible with AmbientCapabilities.
#AmbientCapabilities=CAP_NET_BIND_SERVICE
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
Restart=on-failure
RestartSec=5
# Runway requests a supervised relaunch (the first-run wizard, plugin install) by
# exiting 42. RestartForceExitStatus makes systemd restart on 42 even though it is
# a "success" code; SuccessExitStatus keeps both a clean SIGTERM shutdown (143)
# and the relaunch (42) from being logged as failures.
RestartForceExitStatus=42
SuccessExitStatus=143 42
[Install]
WantedBy=multi-user.target
+186
View File
@@ -0,0 +1,186 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
# Runway — launcher (Linux).
#
# Modes:
# ./runway.sh # detached: a SUPERVISOR backgrounds the JVM, logs to
# $RUNWAY_HOME/logs/runway.out and writes a PID file at
# $RUNWAY_HOME/runway.pid. Closing the terminal does NOT
# stop it. The supervisor RELAUNCHES the JVM whenever it
# exits with code 42 (Runway's supervised-relaunch signal
# for the first-run wizard and plugin install), and stops
# on any other exit.
# ./runway.sh -f # foreground: the JVM replaces the shell via exec. Use
# with systemd (Type=simple) — the unit's
# RestartForceExitStatus=42 provides the relaunch.
# ./runway.sh stop # stops the supervisor (which SIGTERMs the JVM).
#
# Before launching, the script does `cd "${RUNWAY_HOME}"` so the relative paths in
# application.yml (./external/..., ./logs) resolve against the deployment root.
#
# Environment variables (overridable via systemd `Environment=`):
# RUNWAY_HOME Absolute path to the deployment root (contains external/, bin/
# or target/, scripts/). Default: parent of this script's dir.
# RUNWAY_JAR Absolute path to the executable jar. Default: the single
# runway-app-*.jar under <RUNWAY_HOME>/bin or /runway-app/target.
# RUNWAY_OPTS Extra Spring Boot args (--server.port=, --spring.profiles.active=).
# JAVA_HOME JDK/JRE 25+. If unset, `java` from PATH is used.
# JAVA_OPTS JVM flags. Default: -Xms256m -Xmx1g.
#
# A ready-to-use systemd unit ships alongside this file as scripts/runway.service.
# ---------------------------------------------------------------------------
set -euo pipefail
RESTART_EXIT_CODE=42 # must match wizard.Restarter.RESTART_EXIT_CODE
# Resolve the script's real path (follow symlinks).
SCRIPT_PATH="$(readlink -f "$0")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
APP_DIR="$(dirname "$SCRIPT_DIR")"
: "${RUNWAY_HOME:=${APP_DIR}}"
# Resolve the executable jar: the single runway-app-*-exec.jar under bin/ (installed
# layout) or runway-app/target/ (development tree). The `-exec` classifier is what
# spring-boot:repackage attaches (the plain runway-app-*.jar is the thin library jar
# that reactor siblings compile against — NOT runnable), so matching `*-exec.jar`
# both picks the runnable jar and skips the thin one sitting beside it in target/.
# Globbing instead of a hardcoded version means a release build can never ship a
# launcher pointing at a stale jar name.
if [[ -z "${RUNWAY_JAR:-}" ]]; then
RUNWAY_JAR=""
for _j in "${APP_DIR}"/bin/runway-app-*-exec.jar "${APP_DIR}"/runway-app/target/runway-app-*-exec.jar; do
[[ -e "${_j}" ]] || continue
if [[ -n "${RUNWAY_JAR}" ]]; then
echo "[runway] Multiple candidate jars under ${APP_DIR} — set RUNWAY_JAR explicitly:" >&2
echo " ${RUNWAY_JAR}" >&2
echo " ${_j}" >&2
exit 1
fi
RUNWAY_JAR="${_j}"
done
if [[ -z "${RUNWAY_JAR}" ]]; then
RUNWAY_JAR="${APP_DIR}/{bin,runway-app/target}/runway-app-<version>-exec.jar (none found)"
fi
fi
: "${JAVA_OPTS:=-Xms256m -Xmx1g}"
: "${RUNWAY_OPTS:=}"
# Brotli response compression loads a native library; Hazelcast (opt-in clustering, runway.cluster.enabled)
# likewise touches restricted native calls on a modern JDK. Grant restricted native access so JDK 24+ starts
# without the "loadLibrary called ... in an unnamed module" / restricted-method warnings, and so a future JDK
# that makes native access an error (not a warning) still boots. Appended after any operator-supplied
# JAVA_OPTS, so it is always present.
JAVA_OPTS="${JAVA_OPTS} --enable-native-access=ALL-UNNAMED"
FOREGROUND=0
ACTION="start"
PASSTHRU=()
while [[ $# -gt 0 ]]; do
case "$1" in
-f|--foreground) FOREGROUND=1; shift ;;
stop|--stop) ACTION="stop"; shift ;;
-h|--help)
sed -n '2,/^# ----/p' "$SCRIPT_PATH" | sed 's/^# \{0,1\}//'
exit 0
;;
--) shift; PASSTHRU+=("$@"); break ;;
*) PASSTHRU+=("$1"); shift ;;
esac
done
PID_FILE="${RUNWAY_HOME}/runway.pid" # the supervisor (detached mode)
JVM_PID_FILE="${RUNWAY_HOME}/runway.jvm.pid" # the current JVM under the supervisor
LOG_FILE="${RUNWAY_HOME}/logs/runway.out"
if [[ "${ACTION}" == "stop" ]]; then
stopped=0
# Stop the supervisor first so it does not relaunch; its trap SIGTERMs the JVM.
if [[ -f "${PID_FILE}" ]]; then
SUP="$(cat "${PID_FILE}" 2>/dev/null || true)"
if [[ -n "${SUP}" ]] && kill -0 "${SUP}" 2>/dev/null; then
echo "[runway] Stopping supervisor PID ${SUP}…"; kill -TERM "${SUP}"; stopped=1
fi
fi
if [[ -f "${JVM_PID_FILE}" ]]; then
JVM="$(cat "${JVM_PID_FILE}" 2>/dev/null || true)"
if [[ -n "${JVM}" ]] && kill -0 "${JVM}" 2>/dev/null; then
kill -TERM "${JVM}" 2>/dev/null || true; stopped=1
fi
fi
rm -f "${PID_FILE}" "${JVM_PID_FILE}"
[[ "${stopped}" -eq 1 ]] || echo "[runway] Nothing running (no live PID files)." >&2
exit 0
fi
if [[ -n "${JAVA_HOME:-}" ]]; then
JAVA_BIN="${JAVA_HOME}/bin/java"
else
JAVA_BIN="$(command -v java || true)"
fi
if [[ -z "${JAVA_BIN}" || ! -x "${JAVA_BIN}" ]]; then
echo "[runway] java not found. Set JAVA_HOME or put java on PATH." >&2
exit 1
fi
if [[ ! -f "${RUNWAY_JAR}" ]]; then
echo "[runway] Jar not found: ${RUNWAY_JAR}" >&2
echo " Build first: mvn -DskipTests package" >&2
exit 1
fi
if [[ ! -d "${RUNWAY_HOME}" ]]; then
echo "[runway] RUNWAY_HOME is not a directory: ${RUNWAY_HOME}" >&2
exit 1
fi
mkdir -p "${RUNWAY_HOME}/logs"
# application.yml relies on relative paths (./external/..., ./logs); cwd must be
# RUNWAY_HOME for Spring to resolve them.
cd "${RUNWAY_HOME}"
echo "[runway] RUNWAY_HOME=${RUNWAY_HOME}"
echo "[runway] RUNWAY_JAR=${RUNWAY_JAR}"
echo "[runway] JAVA=${JAVA_BIN}"
if [[ "${FOREGROUND}" -eq 1 ]]; then
# `exec` replaces the shell with the JVM: systemd gets the right PID and
# SIGTERM reaches Java directly. The unit's RestartForceExitStatus=42 does the
# supervised relaunch (a foreground launcher must not loop under a supervisor).
# shellcheck disable=SC2086
exec "${JAVA_BIN}" ${JAVA_OPTS} -jar "${RUNWAY_JAR}" ${RUNWAY_OPTS} "${PASSTHRU[@]}"
fi
# Detached: refuse to double-start.
if [[ -f "${PID_FILE}" ]]; then
OLD_PID="$(cat "${PID_FILE}" 2>/dev/null || true)"
if [[ -n "${OLD_PID}" ]] && kill -0 "${OLD_PID}" 2>/dev/null; then
echo "[runway] An instance is already running (supervisor PID ${OLD_PID})." >&2
echo " Stop it first: $0 stop" >&2
exit 1
fi
rm -f "${PID_FILE}" "${JVM_PID_FILE}"
fi
# The supervisor: relaunch the JVM on exit 42, stop on anything else. On SIGTERM
# (from `stop`) it forwards the signal to the JVM and exits without relaunching.
(
_jvm=0
trap '[[ ${_jvm} -ne 0 ]] && kill -TERM "${_jvm}" 2>/dev/null; rm -f "${JVM_PID_FILE}" "${PID_FILE}"; exit 143' TERM INT
while true; do
# shellcheck disable=SC2086
"${JAVA_BIN}" ${JAVA_OPTS} -jar "${RUNWAY_JAR}" ${RUNWAY_OPTS} "${PASSTHRU[@]}" </dev/null >>"${LOG_FILE}" 2>&1 &
_jvm=$!
echo "${_jvm}" > "${JVM_PID_FILE}"
wait "${_jvm}"; _code=$?
if [[ ${_code} -ne ${RESTART_EXIT_CODE} ]]; then
break
fi
echo "[runway] $(date '+%F %T') relaunch requested (exit ${RESTART_EXIT_CODE}) — restarting…" >>"${LOG_FILE}"
done
rm -f "${JVM_PID_FILE}" "${PID_FILE}"
) &
SUP_PID=$!
disown "${SUP_PID}" 2>/dev/null || true
echo "${SUP_PID}" > "${PID_FILE}"
echo "[runway] Started in background (supervisor PID=${SUP_PID}, relaunch-on-${RESTART_EXIT_CODE})"
echo "[runway] Log: ${LOG_FILE}"
echo "[runway] Stop with: $0 stop"
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
#
# Runway @VERSION@ — self-extracting Linux installer.
#
# This file is a shell script with a gzip-compressed tar archive appended after
# the __RUNWAY_ARCHIVE__ marker line. Running it unpacks the bundle to a temporary
# directory and launches scripts/install.sh; any arguments pass straight through
# to the installer.
#
# sudo ./runway-@VERSION@.bin # install / upgrade (see --help)
# sudo ./runway-@VERSION@.bin --port 8080 --open-firewall
# ./runway-@VERSION@.bin --extract DIR # just unpack the bundle into DIR
# ./runway-@VERSION@.bin --help # installer help
#
set -euo pipefail
RUNWAY_VERSION="@VERSION@"
SELF="$(readlink -f "$0")"
# First marker line; the archive starts on the next line.
archive_start() {
awk '/^__RUNWAY_ARCHIVE__$/ { print NR + 1; exit 0 }' "$SELF"
}
extract_to() {
local dest="$1" start
start="$(archive_start)"
[ -n "$start" ] || { echo "runway installer: corrupt archive (no marker)" >&2; exit 1; }
mkdir -p "$dest"
tail -n +"$start" "$SELF" | tar xzf - -C "$dest"
}
# --extract DIR: unpack only (no install). Handy for inspection or staging.
if [ "${1:-}" = "--extract" ]; then
DEST="${2:?--extract needs a target directory}"
extract_to "$DEST"
echo "runway ${RUNWAY_VERSION} bundle extracted to: ${DEST}/runway-${RUNWAY_VERSION}"
echo "Install with: sudo ${DEST}/runway-${RUNWAY_VERSION}/scripts/install.sh [options]"
exit 0
fi
WORK="$(mktemp -d "${TMPDIR:-/tmp}/runway-install.XXXXXX")"
cleanup() { rm -rf "$WORK"; }
trap cleanup EXIT
extract_to "$WORK"
INSTALL="$WORK/runway-${RUNWAY_VERSION}/scripts/install.sh"
[ -f "$INSTALL" ] || { echo "runway installer: install.sh missing from bundle" >&2; exit 1; }
chmod +x "$INSTALL"
bash "$INSTALL" "$@"
exit $?
# Everything below the next line is the gzip-compressed tar payload.
__RUNWAY_ARCHIVE__
+148
View File
@@ -0,0 +1,148 @@
#!/usr/bin/env bash
# test-install-config.sh — tests that install.sh never replaces an existing external/application.yml.
# Runs without root, in a scratch directory: `bash scripts/test-install-config.sh [scratch-parent]`. The dist
# module runs it in its test phase (skipped with -DskipTests). Exit status 0 = all passed.
#
# Why: the installer writes application.yml WHOLE when --port N (N != 8080) or --tls-keystore is given. On a first
# install that is the point; on an existing one the file also holds the setup wizard's application-superadmin pin
# (runway.security.app-master-id) and whatever the operator added (CSP keys, ...), so a re-run with the flags from
# the first install silently dropped the pin and the platform booted back into wizard mode, /setup open to anyone
# (fixed in 1.0.0-rc1). Those flags are now first-install only: refused, before any change, on an existing install.
# The real installer runs in --dry-run (no root needed), so its printed plan and its exit status are the evidence;
# the write function's own guard (the backstop) is exercised directly, non-dry, as the defect was reproduced.
set -euo pipefail
HERE="$(dirname "$(readlink -f "$0")")"
PARENT="${1:-${TMPDIR:-/tmp}}"
mkdir -p "$PARENT"
ROOT="$(readlink -f "$(mktemp -d "$PARENT/install-config-test.XXXXXX")")"
trap 'rm -rf "$ROOT"' EXIT
FAILS=0
PASSES=0
OUT="$ROOT/install.log"
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILS=$((FAILS + 1)); }
pass() { PASSES=$((PASSES + 1)); }
check() { if eval "$2"; then pass; else fail "$1"; sed 's/^/ | /' "$OUT" >&2; fi; }
# A bundle laid out like the dist zip (bin/ + scripts/), and a keystore to point --tls-keystore at.
B="$ROOT/bundle"
mkdir -p "$B/bin" "$B/scripts"
printf 'jar' > "$B/bin/runway-app-9.9.9-exec.jar"
cp "$HERE/install.sh" "$HERE/plugin-seed.sh" "$B/scripts/"
KS="$ROOT/runway.p12"; printf 'not-a-real-keystore' > "$KS"
# install <prefix> args... — the real installer, dry run, never a firewall; records the exit status in RC.
RC=0
install_dry() { local p="$1"; shift; RC=0; bash "$B/scripts/install.sh" --dry-run -y --no-firewall --prefix "$p" "$@" > "$OUT" 2>&1 || RC=$?; }
# An existing install: the file as a running deployment has it — the installer's port, the operator's CSP keys, the wizard's pin.
existing() {
local p="$1"
mkdir -p "$p/runway-data/external"
cat > "$p/runway-data/external/application.yml" <<'YML'
server:
port: 18921
runway:
csp:
mode: enforce
strict-dynamic: true
public-strict-dynamic: true
security:
app-master-id: app-master
YML
cp "$p/runway-data/external/application.yml" "$ROOT/expected.yml"
}
unchanged() { cmp -s "$ROOT/expected.yml" "$1/runway-data/external/application.yml"; }
# --- 1. A first install still writes the file the flags ask for ---------------------------------------------
F="$ROOT/fresh"
install_dry "$F" --port 9090
check "1: fresh install with --port exits 0" '[ "$RC" -eq 0 ]'
check "1: ... and plans to write application.yml with the port" 'grep -qF " + write $F/runway-data/external/application.yml (tls=no port=9090" "$OUT"'
check "1: ... and the plan names the port as before" 'grep -q "plain HTTP on :9090" "$OUT"'
install_dry "$F" --tls-keystore "$KS" --tls-password pw
check "1: fresh install with --tls-keystore exits 0" '[ "$RC" -eq 0 ]'
check "1: ... and plans to write the TLS block" 'grep -qF " + write $F/runway-data/external/application.yml (tls=yes port=443" "$OUT"'
# --- 2. The reproduction: an upgrade re-run with --port N over an existing file is refused -----------
E="$ROOT/existing"; existing "$E"
install_dry "$E" --port 9090
check "2: --port 9090 on an existing install fails" '[ "$RC" -ne 0 ]'
check "2: ... saying the file exists and why that matters" 'grep -qF "$E/runway-data/external/application.yml already exists, so this is an existing install" "$OUT" && grep -q "superadmin pin" "$OUT"'
check "2: ... naming the flag and the key to edit instead" 'grep -q -- "--port 9090 is a first-install option" "$OUT" && grep -q "edit server.port in that file" "$OUT"'
check "2: ... before any action is planned (nothing ran)" '! grep -q "^ + " "$OUT"'
check "2: ... and says nothing was changed" 'grep -q "Nothing was changed" "$OUT"'
check "2: the file is byte-identical (pin kept)" 'unchanged "$E"'
# --- 3. --tls-keystore on an existing install: refused, naming runway.tls.* -----------------------------------
install_dry "$E" --tls-keystore "$KS" --tls-password pw --tls-redirect
check "3: --tls-keystore on an existing install fails" '[ "$RC" -ne 0 ]'
check "3: ... naming only the flag given (not the implied port) and the runway.tls keys" 'grep -q -- ": --tls-keystore is a first-install option" "$OUT" && grep -q "runway.tls.\* (enabled, keystore, keystore-password, key-alias, redirect-http) in that file" "$OUT"'
check "3: ... and the keystore is not copied either" '! grep -q "copy keystore" "$OUT" && [ ! -e "$E/runway-data/external/tls" ]'
check "3: the file is byte-identical" 'unchanged "$E"'
# --- 4. Both flags at once: both named ------------------------------------------------------------------------
install_dry "$E" --port 9443 --tls-keystore "$KS" --tls-password pw
check "4: both flags: refused" '[ "$RC" -ne 0 ]'
check "4: ... naming both flags and both keys" 'grep -q -- "--port 9443 and --tls-keystore are first-install options" "$OUT" && grep -q "edit server.port and runway.tls" "$OUT"'
# --- 5. What an upgrade is meant to be run with still works, and says the file is kept ------------------------
install_dry "$E"
check "5: a plain -y upgrade over an existing install exits 0" '[ "$RC" -eq 0 ]'
check "5: ... plans no write of application.yml" '! grep -q "write .*application.yml" "$OUT"'
check "5: ... and says the port/TLS come from that file, kept" 'grep -qF "port / tls : as configured in $E/runway-data/external/application.yml (kept" "$OUT"'
install_dry "$E" --port 8080 --open-firewall
check "5: --port 8080 (the default, never written) is still accepted on an existing install" '[ "$RC" -eq 0 ] && ! grep -q "write .*application.yml" "$OUT"'
install_dry "$E" --firewall-ports 80,443
check "5: --firewall-ports (ADMINISTRATION §7.1 suggests a re-run with it) is still accepted" '[ "$RC" -eq 0 ]'
check "5: the file is byte-identical after all of it" 'unchanged "$E"'
# --- 6. An existing install whose file is a symlink (an operator keeping config elsewhere) is existing too -----
L="$ROOT/linked"; mkdir -p "$L/runway-data/external" "$ROOT/elsewhere"
cp "$ROOT/expected.yml" "$ROOT/elsewhere/app.yml"; ln -s "$ROOT/elsewhere/app.yml" "$L/runway-data/external/application.yml"
install_dry "$L" --port 9090
check "6: a symlinked application.yml is an existing install: refused" '[ "$RC" -ne 0 ] && grep -q "first-install option" "$OUT"'
# --- 7. The backstop: write_app_config itself refuses an existing file, even when called non-dry ---------------
# The function body is taken from the installer as shipped, exactly as it was extracted to reproduce the
# overwrite: WRITE_CONFIG=yes WRITE_PORT=yes PORT=9090 over the existing file, DRY_RUN=no.
X="$ROOT/backstop"; existing "$X"
{
sed -n '/^log() {/p; /^warn() {/p; /^die() {/p; /^yaml_escape() {/p' "$B/scripts/install.sh"
sed -n '/^write_app_config() {/,/^}/p' "$B/scripts/install.sh"
} > "$ROOT/fns.sh"
check "7: the functions were found in install.sh" 'grep -q "^write_app_config() {" "$ROOT/fns.sh" && grep -q "^die()" "$ROOT/fns.sh"'
RC=0
( set -e; . "$ROOT/fns.sh"; DRY_RUN=no WRITE_CONFIG=yes WRITE_PORT=yes PORT=9090 TLS_ENABLED=no TLS_REDIRECT=no \
APP_USER="$(id -un)" DATA="$X/runway-data"; write_app_config ) > "$OUT" 2>&1 || RC=$?
check "7: write_app_config over an existing file fails" '[ "$RC" -ne 0 ]'
check "7: ... with its own refusal (not a later install(1) error)" 'grep -q "refusing to replace the existing $X/runway-data/external/application.yml" "$OUT" && ! grep -q "^\[install\] writing" "$OUT"'
check "7: ... and the file is byte-identical (the defect left only server.port: 9090)" 'unchanged "$X"'
RC=0
( set -e; . "$ROOT/fns.sh"; DRY_RUN=yes WRITE_CONFIG=yes WRITE_PORT=yes PORT=9090 TLS_ENABLED=no TLS_REDIRECT=no \
APP_USER="$(id -un)" DATA="$X/runway-data"; write_app_config ) > "$OUT" 2>&1 || RC=$?
check "7: ... in a dry run too" '[ "$RC" -ne 0 ] && grep -q "refusing to replace" "$OUT"'
# --- 8. --help says the flags are first-install only ---------------------------------------------------------
bash "$B/scripts/install.sh" --help > "$OUT" 2>&1 || true
check "8: --help marks --port/--tls-keystore first-install only" 'grep -q "First install only, like --tls-keystore" "$OUT"'
# --- 9. An upgrade keeps CAP_NET_BIND_SERVICE when the unit it replaces granted it ---------------------------
# The installer cannot read the configured port on an existing install (no YAML parser), so it plans 8080; before
# this, an install terminating TLS on 443 (or redirecting on 80) lost the capability on every upgrade and could no
# longer bind its port. An install on 8080 behind HAProxy (capability commented) must keep getting nothing extra.
cp "$HERE/runway.service" "$B/scripts/"
U="$ROOT/upgrade"; existing "$U"
sed -E 's/^#[[:space:]]*(AmbientCapabilities=CAP_NET_BIND_SERVICE)/\1/; s/^#[[:space:]]*(CapabilityBoundingSet=CAP_NET_BIND_SERVICE)/\1/' \
"$HERE/runway.service" > "$ROOT/granting.service"
RUNWAY_UNIT_DST="$ROOT/granting.service" install_dry "$U"
check "9: an upgrade over a unit granting the capability keeps it" '[ "$RC" -eq 0 ] && grep -q "net-bind-cap=yes" "$OUT"'
cp "$HERE/runway.service" "$ROOT/plain.service"
RUNWAY_UNIT_DST="$ROOT/plain.service" install_dry "$U"
check "9: ... and over a unit without it (8080 behind a proxy) adds nothing" '[ "$RC" -eq 0 ] && grep -q "net-bind-cap=no" "$OUT"'
grep -q '^#[[:space:]]*AmbientCapabilities=CAP_NET_BIND_SERVICE' "$HERE/runway.service" && pass \
|| fail "9: the unit template ships the capability commented (the check above depends on it)"
printf 'install-config: %d passed, %d failed\n' "$PASSES" "$FAILS"
[ "$FAILS" -eq 0 ]
+215
View File
@@ -0,0 +1,215 @@
#!/usr/bin/env bash
# test-plugin-seed.sh — tests for plugin-seed.sh, the bundled-plugin seed/refresh logic of install.sh.
# Runs without root, in a scratch directory: `bash scripts/test-plugin-seed.sh [scratch-parent]`. The dist
# module runs it in its test phase (skipped with -DskipTests). Exit status 0 = all passed.
#
# Each case asserts on what the operator would actually see — the backup files on disk and the warning text —
# because the defect this guards against was a true-looking warning about edits nobody made.
set -euo pipefail
HERE="$(dirname "$(readlink -f "$0")")"
# shellcheck source=plugin-seed.sh
. "$HERE/plugin-seed.sh"
PARENT="${1:-${TMPDIR:-/tmp}}"
mkdir -p "$PARENT"
ROOT="$(readlink -f "$(mktemp -d "$PARENT/plugin-seed-test.XXXXXX")")" # absolute: install.sh prints resolved bundle paths
trap 'rm -rf "$ROOT"' EXIT
DRY_RUN="no"
OUT="$ROOT/out.log"
log() { printf '[install] %s\n' "$*" >> "$OUT"; }
warn() { printf '[install] WARNING: %s\n' "$*" >> "$OUT"; }
run() { if [ "$DRY_RUN" = "yes" ]; then printf ' + %s\n' "$*" >> "$OUT"; else "$@"; fi; }
FAILS=0
PASSES=0
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILS=$((FAILS + 1)); }
pass() { PASSES=$((PASSES + 1)); }
check() { if eval "$2"; then pass; else fail "$1"; sed 's/^/ | /' "$OUT" >&2; fi; }
# bundle <dir> <version-tag> — a bundle whose protection plugin ships one template and one i18n file whose
# content depends on the tag (so two tags = "we changed the file between releases").
bundle() {
local b="$1" tag="$2" p="$1/seed/plugins/protection"
rm -rf "$b"; mkdir -p "$p/templates" "$p/i18n"
printf 'id: protection\nversion: %s\n' "$tag" > "$p/plugin.yml"
printf 'jar-%s' "$tag" > "$p/runway-plugin-protection.jar"
printf '<p>dos %s</p>\n' "$tag" > "$p/templates/app-dos.html"
printf 'protection.title=Protection %s\n' "$tag" > "$p/i18n/messages.properties"
}
backups() { find "$1/external/plugins/protection" -name '*.operator-backup-*' | wc -l; }
T="templates/app-dos.html"
I="i18n/messages.properties"
# --- 1. A file nobody edited, which we changed upstream → refreshed, no warning, no backup -------------------
D="$ROOT/c1"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
check "1: first install writes a manifest" '[ -f "$D/external/plugin-manifests/protection.sha256" ]'
check "1: manifest header" 'head -1 "$D/external/plugin-manifests/protection.sha256" | grep -q "^# runway shipped-manifest v1 plugin=protection$"'
bundle "$ROOT/b2" v2; : > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "1: no warning for an unedited stale file" '! grep -q WARNING "$OUT"'
check "1: no backup for an unedited stale file" '[ "$(backups "$D")" -eq 0 ]'
check "1: template refreshed" 'grep -q "dos v2" "$D/external/plugins/protection/$T"'
check "1: i18n refreshed" 'grep -q "Protection v2" "$D/external/plugins/protection/$I"'
check "1: the log says why there was no backup" 'grep -q "unchanged since it was installed" "$OUT"'
check "1: manifest now records v2" '[ "$(_ps_manifest_hash "$D/external/plugin-manifests/protection.sha256" "$T")" = "$(_ps_sha "$ROOT/b2/seed/plugins/protection/$T")" ]'
# --- 2. An operator-edited file → backed up and warned ------------------------------------------------------
D="$ROOT/c2"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
printf '<p>my own dos page</p>\n' > "$D/external/plugins/protection/$T"
bundle "$ROOT/b2" v2; : > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "2: exactly one backup (the edited file only)" '[ "$(backups "$D")" -eq 1 ]'
check "2: the backup holds the operator edit" 'grep -q "my own dos page" "$D"/external/plugins/protection/templates/app-dos.html.operator-backup-*'
check "2: warning names the edit" 'grep -q "WARNING: plugin .protection.: $T was edited after it was installed" "$OUT"'
check "2: the unedited i18n file is not warned about" '! grep -q "WARNING.*$I" "$OUT"'
check "2: edited file still refreshed to v2" 'grep -q "dos v2" "$D/external/plugins/protection/$T"'
# --- 3. No manifest (an install from before this change) → warn for every differing file, write a manifest --
D="$ROOT/c3"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
rm -f "$D/external/plugin-manifests/protection.sha256"
bundle "$ROOT/b2" v2; : > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "3: both differing files backed up" '[ "$(backups "$D")" -eq 2 ]'
check "3: warning admits it cannot tell" '[ "$(grep -c "has no record of what was installed before" "$OUT")" -eq 2 ]'
check "3: a manifest is written for next time" '[ -f "$D/external/plugin-manifests/protection.sha256" ]'
bundle "$ROOT/b3" v3; : > "$OUT"; seed_bundled_plugins "$ROOT/b3" "$D"
check "3: the NEXT upgrade is clean" '! grep -q WARNING "$OUT" && [ "$(backups "$D")" -eq 2 ]'
# --- 4. The manifest survives the plugin folder being replaced ---------------------------------------------
D="$ROOT/c4"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
check "4: the manifest lives outside the plugin folder" '[ ! -e "$D/external/plugins/protection/plugin-manifests" ] && ! find "$D/external/plugins" -name "*.sha256" | grep -q .'
rm -rf "$D/external/plugins/protection"
cp -a "$ROOT/b1/seed/plugins/protection" "$D/external/plugins/protection"
check "4: still there after the folder is replaced" '[ -n "$(_ps_manifest_hash "$D/external/plugin-manifests/protection.sha256" "$T")" ]'
# --- 5. Identical files are silent; a file new in this release is installed; dry run writes nothing ---------
D="$ROOT/c5"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
: > "$OUT"; seed_bundled_plugins "$ROOT/b1" "$D"
check "5: re-running the same release says nothing about files" '! grep -q "app-dos\|messages.properties" "$OUT"'
bundle "$ROOT/b2" v2; printf 'x=1\n' > "$ROOT/b2/seed/plugins/protection/i18n/messages_fr.properties"
cp -a "$D" "$ROOT/c5-before"
DRY_RUN="yes"; : > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"; DRY_RUN="no"
check "5: dry run changes nothing on disk" 'diff -r "$ROOT/c5-before" "$D" > /dev/null'
: > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "5: a new file is installed without a warning" '[ -f "$D/external/plugins/protection/i18n/messages_fr.properties" ] && ! grep -q WARNING "$OUT"'
check "5: a file the operator never had is in the new manifest" '[ -n "$(_ps_manifest_hash "$D/external/plugin-manifests/protection.sha256" "i18n/messages_fr.properties")" ]'
# --- 6. Every upgrade refreshes an existing essential plugin — no flag (the 1.0.0-rc1 blocker) ----------------
# Until rc1 an upgrade without --update-essential-plugins left the old protection in place; on SPI 1.0.0 an old
# descriptor (no requiresSpi) is blocked, and a blocked essential plugin makes every tenant page answer 503. So the
# old copy here is exactly that shape — no requiresSpi, and hand-disabled — and the upgrade must replace it.
D="$ROOT/c6"; P="$D/external/plugins/protection"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
printf 'enabled: false\n' >> "$P/plugin.yml"
mkdir -p "$D/external/plugin-settings"; printf 'rate-limit:\n capacity: 7\n' > "$D/external/plugin-settings/protection.yml"
cp "$D/external/plugin-settings/protection.yml" "$ROOT/c6-settings"
bundle "$ROOT/b2" v2; printf 'requiresSpi: ">=1.0.0"\n' >> "$ROOT/b2/seed/plugins/protection/plugin.yml"
: > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "6: the new descriptor (with its requiresSpi floor) is installed" 'grep -q "version: v2" "$P/plugin.yml" && grep -q "^requiresSpi: \">=1.0.0\"$" "$P/plugin.yml"'
check "6: the new jar is installed" '[ "$(cat "$P/runway-plugin-protection.jar")" = "jar-v2" ]'
check "6: a hand-set enabled: false does not survive (a disabled essential plugin fails closed)" '! grep -q "enabled: false" "$P/plugin.yml"'
check "6: ... but is kept, with the old descriptor, in plugin.yml.bak" 'grep -q "version: v1" "$P/plugin.yml.bak" && grep -q "enabled: false" "$P/plugin.yml.bak"'
check "6: templates and i18n are refreshed too" 'grep -q "dos v2" "$P/$T" && grep -q "Protection v2" "$P/$I"'
check "6: the operator is told the plugin is refreshed" 'grep -q "refreshing bundled plugin .protection. from this release" "$OUT"'
check "6: the operator is told where the previous descriptor and jar are" 'grep -q "plugin.yml replaced (the previous one kept as plugin.yml.bak" "$OUT" && grep -q "runway-plugin-protection.jar replaced (the previous one kept as runway-plugin-protection.jar.bak" "$OUT"'
check "6: no warning (nothing was edited)" '! grep -q WARNING "$OUT"'
check "6: no 'nothing changed' line on a real upgrade" '! grep -q "nothing changed" "$OUT"'
check "6: settings (outside the folder) are untouched" 'cmp -s "$ROOT/c6-settings" "$D/external/plugin-settings/protection.yml"'
check "6: the old 'leaving it as-is' path is gone" '! grep -q "leaving it as-is" "$OUT"'
# --- 7. The previous jar AND descriptor are kept for a rollback, and a re-run never overwrites them -----------
# A rollback is a symlink flip back to the older kernel, which then meets the refreshed plugin folder. The new jar
# may link SPI types that kernel lacks (beta14's protection did: beta13 died on NoClassDefFoundError), and the new
# descriptor carries a requiresSpi floor that refuses the old jar, so the rollback restores BOTH .bak files.
D="$ROOT/c7"; P="$D/external/plugins/protection"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
check "7: a fresh install leaves no .bak" '! find "$P" -name "*.bak" | grep -q .'
bundle "$ROOT/b2" v2; : > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "7: the previous descriptor is kept as plugin.yml.bak" 'grep -q "version: v1" "$P/plugin.yml.bak"'
check "7: the previous jar is kept as .jar.bak" '[ "$(cat "$P/runway-plugin-protection.jar.bak")" = "jar-v1" ]'
check "7: the new descriptor and jar are installed" 'grep -q "version: v2" "$P/plugin.yml" && [ "$(cat "$P/runway-plugin-protection.jar")" = "jar-v2" ]'
: > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
check "7: re-running the same release keeps the PREVIOUS release in plugin.yml.bak" 'grep -q "version: v1" "$P/plugin.yml.bak"'
check "7: re-running the same release keeps the PREVIOUS release in .jar.bak" '[ "$(cat "$P/runway-plugin-protection.jar.bak")" = "jar-v1" ]'
cp -f "$P/plugin.yml.bak" "$P/plugin.yml"; cp -f "$P/runway-plugin-protection.jar.bak" "$P/runway-plugin-protection.jar"
check "7: restoring the two .bak files gives back the previous release" 'grep -q "version: v1" "$P/plugin.yml" && [ "$(cat "$P/runway-plugin-protection.jar")" = "jar-v1" ]'
bundle "$ROOT/b3" v3; cp -a "$D" "$ROOT/c7-before"
DRY_RUN="yes"; : > "$OUT"; seed_bundled_plugins "$ROOT/b3" "$D"; DRY_RUN="no"
check "7: dry run announces the descriptor backup and writes nothing" 'grep -qF "cp -f $P/plugin.yml $P/plugin.yml.bak" "$OUT" && diff -r "$ROOT/c7-before" "$D" > /dev/null'
# --- 8. A re-run with nothing new writes no .bak and no warning, and says so --------------------------------
# Refreshing on every run is only safe if a run that changes nothing is silent: a .bak written by an idempotent
# re-run would overwrite the rollback copy, and a warning would cry wolf.
D="$ROOT/c8"; P="$D/external/plugins/protection"; : > "$OUT"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
: > "$OUT"; seed_bundled_plugins "$ROOT/b1" "$D"
check "8: a re-run of the install's own release writes no .bak" '! find "$P" -name "*.bak" | grep -q .'
check "8: ... and no operator backup" '[ "$(backups "$D")" -eq 0 ]'
check "8: ... and no warning" '! grep -q WARNING "$OUT"'
check "8: ... and replaces nothing" '! grep -q "replaced" "$OUT"'
check "8: ... and says nothing changed" 'grep -q "plugin .protection. was already this release.s — nothing changed" "$OUT"'
bundle "$ROOT/b2" v2; seed_bundled_plugins "$ROOT/b2" "$D"
( cd "$P" && find . -name "*.bak" -exec sha256sum {} + | sort ) > "$ROOT/c8-bak-before"
: > "$OUT"; seed_bundled_plugins "$ROOT/b2" "$D"
( cd "$P" && find . -name "*.bak" -exec sha256sum {} + | sort ) > "$ROOT/c8-bak-after"
check "8: after an upgrade, a re-run keeps the same .bak files, byte for byte" '[ -s "$ROOT/c8-bak-before" ] && cmp -s "$ROOT/c8-bak-before" "$ROOT/c8-bak-after"'
check "8: after an upgrade, a re-run warns about nothing and says nothing changed" '! grep -q WARNING "$OUT" && grep -q "nothing changed" "$OUT"'
# --- 9. install.sh: the refresh needs no flag, and --update-essential-plugins is still accepted -------------
# Runs the real installer in --dry-run (no root needed) from a bundle laid out like the dist zip, over a data dir
# that already holds an older protection: the upgrade case. Dry run writes nothing, so the output is the evidence.
B="$ROOT/b9"; PREFIX9="$ROOT/opt9"; D="$PREFIX9/runway-data"; P="$D/external/plugins/protection"
bundle "$ROOT/b1" v1; seed_bundled_plugins "$ROOT/b1" "$D"
bundle "$B" v2; mkdir -p "$B/bin" "$B/scripts"
printf 'jar' > "$B/bin/runway-app-9.9.9-exec.jar"
cp "$HERE/install.sh" "$HERE/plugin-seed.sh" "$B/scripts/"
cp -a "$D" "$ROOT/c9-before"
INSTALL_OUT="$ROOT/install.log"
install_dry() { bash "$B/scripts/install.sh" --dry-run -y --no-tls --no-firewall --prefix "$PREFIX9" "$@" > "$INSTALL_OUT" 2>&1; }
if install_dry --update-essential-plugins; then pass; else fail "9: install.sh --update-essential-plugins exits 0"; sed 's/^/ | /' "$INSTALL_OUT" >&2; fi
check "9: the flag is accepted and says it has nothing to do" 'grep -q "update-essential-plugins: nothing to do" "$INSTALL_OUT"'
check "9: with the flag, the upgrade refreshes protection" 'grep -qF "cp -f $P/plugin.yml $P/plugin.yml.bak" "$INSTALL_OUT" && grep -q "refreshing bundled plugin .protection." "$INSTALL_OUT"'
if install_dry; then pass; else fail "9: install.sh without the flag exits 0"; sed 's/^/ | /' "$INSTALL_OUT" >&2; fi
check "9: WITHOUT the flag, the upgrade refreshes protection just the same" 'grep -qF "cp -f $B/seed/plugins/protection/plugin.yml $P/plugin.yml" "$INSTALL_OUT" && grep -qF "cp -f $P/runway-plugin-protection.jar $P/runway-plugin-protection.jar.bak" "$INSTALL_OUT"'
check "9: without the flag there is no flag notice" '! grep -q "update-essential-plugins" "$INSTALL_OUT"'
check "9: the plan names the plugin refresh" 'grep -q "plugins : bundled (essential) plugins seeded if missing, else refreshed" "$INSTALL_OUT"'
check "9: dry run left the data dir as it was" 'diff -r "$ROOT/c9-before" "$D" > /dev/null'
bash "$B/scripts/install.sh" --help > "$INSTALL_OUT" 2>&1 || true
check "9: --help no longer offers the flag as an opt-in" 'grep -q "Accepted and ignored" "$INSTALL_OUT" && grep -q "ALWAYS refreshed" "$INSTALL_OUT" && ! grep -q "plugins are never touched on upgrade" "$INSTALL_OUT"'
# --- 10. install.sh keeps the bundle's seed/ in the release, the repair copy the kernel's message points at ------
# A refused essential plugin's fix is the running release's copy; before 1.0.0-rc1 that copy lived only inside the
# .bin, so the operator had to find and extract it. The installer now lays seed/ into <prefix>/runway-<version>/,
# replaced whole (no stale file, no seed/seed nesting on a re-run), before the release is chowned and relabeled.
# Reuses case 9's bundle and prefix; dry run, so the printed plan is the evidence.
DEST9="$PREFIX9/runway-9.9.9"
if install_dry; then pass; else fail "10: install.sh exits 0"; sed 's/^/ | /' "$INSTALL_OUT" >&2; fi
check "10: the plan names the repair copy under the current link" 'grep -qF "repair copy : the bundled plugins also kept in the release, $PREFIX9/runway/seed/plugins/" "$INSTALL_OUT"'
check "10: seed/ is copied into the release" 'grep -qxF " + cp -R $B/seed $DEST9/seed" "$INSTALL_OUT"'
check "10: ... after the old one is removed (replaced whole, never nested as seed/seed)" '[ "$(grep -nxF " + rm -rf $DEST9/seed" "$INSTALL_OUT" | cut -d: -f1)" -lt "$(grep -nxF " + cp -R $B/seed $DEST9/seed" "$INSTALL_OUT" | cut -d: -f1)" ]'
check "10: ... before the release is chowned (same ownership as bin/ and scripts/)" '[ "$(grep -nxF " + cp -R $B/seed $DEST9/seed" "$INSTALL_OUT" | cut -d: -f1)" -lt "$(grep -nxF " + chown -R runway:runway $DEST9" "$INSTALL_OUT" | cut -d: -f1)" ]'
if command -v restorecon > /dev/null 2>&1; then
check "10: ... and before the SELinux relabel of the release" '[ "$(grep -nxF " + cp -R $B/seed $DEST9/seed" "$INSTALL_OUT" | cut -d: -f1)" -lt "$(grep -nF " + restorecon -RF $DEST9 " "$INSTALL_OUT" | cut -d: -f1)" ]'
fi
check "10: the plugin is still seeded into the data dir as well" 'grep -q "refreshing bundled plugin .protection." "$INSTALL_OUT"'
check "10: dry run left the prefix without a release dir" '[ ! -e "$DEST9" ]'
# The installer re-run from an installed release: its bundle IS the release dir, so seed/ must not be removed.
mkdir -p "$DEST9"; cp -a "$B/bin" "$B/scripts" "$B/seed" "$DEST9/"
if bash "$DEST9/scripts/install.sh" --dry-run -y --no-tls --no-firewall --prefix "$PREFIX9" > "$INSTALL_OUT" 2>&1; then pass
else fail "10: install.sh run from the release exits 0"; sed 's/^/ | /' "$INSTALL_OUT" >&2; fi
check "10: run from the release itself, seed/ is neither removed nor copied onto itself" '! grep -q "rm -rf $DEST9/seed" "$INSTALL_OUT" && ! grep -q "cp -R .*/seed $DEST9/seed" "$INSTALL_OUT"'
rm -rf "$DEST9"
# A bundle without seed/ (a hand-made one): nothing to keep, and the plan does not promise a repair copy.
mv "$B/seed" "$ROOT/b9-seed"
if install_dry; then pass; else fail "10: install.sh without seed/ exits 0"; sed 's/^/ | /' "$INSTALL_OUT" >&2; fi
check "10: no seed/ in the bundle: no copy, no repair-copy line" '! grep -q "repair copy" "$INSTALL_OUT" && ! grep -q "$DEST9/seed" "$INSTALL_OUT"'
mv "$ROOT/b9-seed" "$B/seed"
bash "$B/scripts/install.sh" --help > "$INSTALL_OUT" 2>&1 || true
check "10: --help says where the repair copy is" 'grep -q "The bundle.s copy also stays in the release, <prefix>/runway/seed/plugins/<id>/" "$INSTALL_OUT"'
printf 'plugin-seed: %d passed, %d failed\n' "$PASSES" "$FAILS"
[ "$FAILS" -eq 0 ]
+165
View File
@@ -0,0 +1,165 @@
#!/usr/bin/env bash
# test-release-assets.sh — tests for the release's file set: make-spi-assets.sh (the plugin author's SPI jars and
# consumer poms), make-release-aliases.sh (the aliases and SHA256SUMS over everything) and publish-release.sh's
# refusals and --dry-run. Runs offline, without credentials, in a scratch directory:
# `bash scripts/test-release-assets.sh [scratch-parent]`. The dist module runs it in its test phase next to
# test-release-notes.sh (skipped with -DskipTests). Exit status 0 = all passed.
#
# publish-release.sh runs from a COPY of the scripts in a fake reactor tree (it finds runway-dist/target and
# CHANGELOG.md beside its own directory), with `git` and `curl` replaced on PATH by stubs that log and fail, so
# no case can reach the real tag, credential store or Gitea — and the log proves which cases tried.
set -euo pipefail
HERE="$(dirname "$(readlink -f "$0")")"
# Release tooling is maintainer-only: a checkout without scripts/publish-release.sh (the public source tree) has
# nothing for this test to check, so it passes with a note instead of failing the build.
if [ ! -f "$HERE/publish-release.sh" ]; then
echo "release-assets: skipped (scripts/publish-release.sh is not in this checkout)"
exit 0
fi
PARENT="${1:-${TMPDIR:-/tmp}}"
mkdir -p "$PARENT"
ROOT="$(mktemp -d "$PARENT/release-assets-test.XXXXXX")"
trap 'rm -rf "$ROOT"' EXIT
FAILS=0
PASSES=0
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILS=$((FAILS + 1)); }
pass() { PASSES=$((PASSES + 1)); }
check() { if eval "$2"; then pass; else fail "$1"; fi; }
V=1.2.0-rc1
T="$ROOT/tree"
DIST="$T/runway-dist/target"
mkdir -p "$T/scripts" "$DIST" "$T/runway-spi/target" "$T/runway-spi-testkit/target" "$ROOT/bin"
for s in publish-release.sh release-notes.sh make-release-aliases.sh make-spi-assets.sh; do
cp "$HERE/$s" "$T/scripts/$s"
done
# The REAL module poms: the consumer pom is derived from them, so the test follows them as they change.
cp "$HERE/../runway-spi/pom.xml" "$T/runway-spi/pom.xml"
cp "$HERE/../runway-spi-testkit/pom.xml" "$T/runway-spi-testkit/pom.xml"
for m in runway-spi runway-spi-testkit; do
printf 'jar %s\n' "$m" > "$T/$m/target/$m-$V.jar"
printf 'sources %s\n' "$m" > "$T/$m/target/$m-$V-sources.jar"
done
cat > "$T/CHANGELOG.md" <<EOF
# Changelog
## [Unreleased]
## [$V] — 2026-10-18
### Upgrading — read this first
Nothing to do.
## [1.1.0] — 2026-10-01
### Added
- no upgrade part
EOF
# Stubs: any git or curl call is logged and fails (a publish that gets past the local checks stops at the tag).
for tool in git curl; do
printf '#!/usr/bin/env bash\necho "%s $*" >> "%s"\nexit 1\n' "$tool" "$ROOT/net.log" > "$ROOT/bin/$tool"
chmod +x "$ROOT/bin/$tool"
done
: > "$ROOT/net.log"
pub() { local r=0; PATH="$ROOT/bin:$PATH" bash "$T/scripts/publish-release.sh" "$@" > "$ROOT/pub.out" 2> "$ROOT/pub.err" || r=$?; echo "$r"; }
spi_files() { local m; for m in runway-spi runway-spi-testkit; do printf '%s\n' "$m-$V.jar" "$m-$V-sources.jar" "$m-$V.pom"; done; }
# --- 1. make-spi-assets.sh ---------------------------------------------------------------------------------------
r=0; bash "$T/scripts/make-spi-assets.sh" "$T" "$DIST" "$V" > "$ROOT/spi.out" 2>&1 || r=$?
check "1: stages the six files" '[ "$r" = 0 ] && for f in $(spi_files); do [ -f "$DIST/$f" ] || exit 1; done'
check "1: jars are copied byte-for-byte" 'cmp -s "$DIST/runway-spi-$V.jar" "$T/runway-spi/target/runway-spi-$V.jar" && cmp -s "$DIST/runway-spi-testkit-$V-sources.jar" "$T/runway-spi-testkit/target/runway-spi-testkit-$V-sources.jar"'
SPOM="$DIST/runway-spi-$V.pom"; KPOM="$DIST/runway-spi-testkit-$V.pom"
check "1: the consumer pom is well-formed XML" 'python3 -c "import sys,xml.etree.ElementTree as E; E.parse(sys.argv[1]); E.parse(sys.argv[2])" "$SPOM" "$KPOM"'
check "1: it has no parent (the reactor parent is not published)" '! grep -q "<parent>" "$SPOM" "$KPOM"'
check "1: it states the coordinates outright" 'grep -q "<groupId>mx.quest</groupId>" "$SPOM" && grep -q "<artifactId>runway-spi</artifactId>" "$SPOM" && grep -q "<version>$V</version>" "$SPOM"'
check "1: test-scope dependencies are dropped (runway-spi has none left)" '! grep -q "<dependencies>\|junit" "$SPOM"'
check "1: the testkit keeps runway-spi at the SAME version" 'python3 - "$KPOM" "$V" <<PY
import sys, xml.etree.ElementTree as E
ns = {"m": "http://maven.apache.org/POM/4.0.0"}
deps = E.parse(sys.argv[1]).getroot().findall("m:dependencies/m:dependency", ns)
got = [(d.find("m:artifactId", ns).text, d.find("m:version", ns).text, d.find("m:scope", ns)) for d in deps]
sys.exit(0 if got == [("runway-spi", sys.argv[2], None)] else 1)
PY'
check "1: no unresolved property is left" '! grep -q "\${" "$SPOM" "$KPOM"'
cp "$SPOM" "$ROOT/spom.1"
bash "$T/scripts/make-spi-assets.sh" "$T" "$DIST" "$V" > /dev/null 2>&1
check "1: a second run writes the same bytes" 'cmp -s "$SPOM" "$ROOT/spom.1"'
# Refusals, each in its own tree copy so the main tree stays intact.
refuse_tree() { rm -rf "$ROOT/r"; cp -r "$T" "$ROOT/r"; rm -f "$ROOT/r/runway-dist/target/"*; }
refuse_tree; rm "$ROOT/r/runway-spi-testkit/target/runway-spi-testkit-$V-sources.jar"
r=0; bash "$ROOT/r/scripts/make-spi-assets.sh" "$ROOT/r" "$ROOT/r/runway-dist/target" "$V" > /dev/null 2> "$ROOT/err" || r=$?
check "1: a missing sources jar is refused" '[ "$r" -ne 0 ] && grep -q "missing .*runway-spi-testkit-$V-sources.jar" "$ROOT/err"'
refuse_tree; sed -i 's|<version>${project.version}</version>|<version>${some.other}</version>|' "$ROOT/r/runway-spi-testkit/pom.xml"
r=0; bash "$ROOT/r/scripts/make-spi-assets.sh" "$ROOT/r" "$ROOT/r/runway-dist/target" "$V" > /dev/null 2> "$ROOT/err" || r=$?
check "1: an unresolvable dependency version is refused, not guessed" '[ "$r" -ne 0 ] && grep -q "cannot resolve version" "$ROOT/err"'
check "1: ...and leaves no pom (nor a partial one) behind" '[ ! -e "$ROOT/r/runway-dist/target/runway-spi-testkit-$V.pom" ] && [ ! -e "$ROOT/r/runway-dist/target/runway-spi-testkit-$V.pom.part" ]'
refuse_tree; python3 - "$ROOT/r/runway-spi/pom.xml" <<'PY'
import sys
p = sys.argv[1]; s = open(p).read()
s = s.replace("<dependencies>", "<dependencies><dependency><groupId>x</groupId><artifactId>managed</artifactId></dependency>", 1)
open(p, "w").write(s)
PY
r=0; bash "$ROOT/r/scripts/make-spi-assets.sh" "$ROOT/r" "$ROOT/r/runway-dist/target" "$V" > /dev/null 2> "$ROOT/err" || r=$?
check "1: a non-test dependency without an explicit version is refused" '[ "$r" -ne 0 ] && grep -q "x:managed has no explicit version" "$ROOT/err"'
# --- 2. make-release-aliases.sh ----------------------------------------------------------------------------------
printf 'zip\n' > "$DIST/runway-$V-dist.zip"
printf 'bin\n' > "$DIST/runway-$V.bin"
r=0; bash "$T/scripts/make-release-aliases.sh" "$DIST" "$V" > /dev/null 2>&1 || r=$?
check "2: writes SHA256SUMS" '[ "$r" = 0 ] && [ -f "$DIST/SHA256SUMS" ]'
check "2: SHA256SUMS lists the installer pair, the aliases, then the six SPI files, in that order" \
'[ "$(awk "{print \$2}" "$DIST/SHA256SUMS" | tr "\n" " ")" = "runway-$V-dist.zip runway-$V.bin runway-latest-dist.zip runway-latest.bin $(spi_files | tr "\n" " ")" ]'
check "2: every listed hash verifies" '(cd "$DIST" && sha256sum --quiet -c SHA256SUMS)'
check "2: the SPI files get no latest alias" '! ls "$DIST" | grep -q "runway-spi.*latest\|latest.*spi"'
refuse_tree; cp "$DIST/runway-$V-dist.zip" "$DIST/runway-$V.bin" "$ROOT/r/runway-dist/target/"
r=0; bash "$ROOT/r/scripts/make-release-aliases.sh" "$ROOT/r/runway-dist/target" "$V" > /dev/null 2> "$ROOT/err" || r=$?
check "2: refuses when the SPI files were not staged" '[ "$r" -ne 0 ] && grep -q "missing runway-spi-$V.jar" "$ROOT/err" && [ ! -e "$ROOT/r/runway-dist/target/SHA256SUMS" ]'
# --- 3. publish-release.sh --dry-run -----------------------------------------------------------------------------
: > "$ROOT/net.log"
r="$(pub --dry-run "$V")"
check "3: a dry run of a complete set succeeds" '[ "$r" = 0 ]'
check "3: it says nothing is published" 'grep -q "DRY RUN — nothing is created, changed or uploaded" "$ROOT/pub.out"'
check "3: it names the release, non-prerelease" 'grep -q "tag=v$V name=\"Runway $V\" prerelease=false" "$ROOT/pub.out"'
check "3: it lists all 11 assets, the SPI files included" 'grep -q "would upload 11 assets" "$ROOT/pub.out" && for f in $(spi_files) SHA256SUMS runway-latest.bin; do grep -q "^ $f " "$ROOT/pub.out" || exit 1; done'
check "3: ...without touching git, curl or the network" '[ ! -s "$ROOT/net.log" ]'
r="$(pub -n)"
check "3: -n works and the version is detected from SHA256SUMS (the SPI lines do not confuse it)" '[ "$r" = 0 ] && grep -q "tag=v$V " "$ROOT/pub.out"'
r="$(pub --dry-run --bogus)"
check "3: an unknown option is refused (status 2)" '[ "$r" = 2 ] && grep -q "unknown option: --bogus" "$ROOT/pub.err"'
r="$(pub --dry-run "$V" 9.9.9)"
check "3: two versions are refused (status 2)" '[ "$r" = 2 ]'
# --- 4. publish-release.sh refusals (dry run or not, all before the tag, the credential or the network) ----------
mv "$DIST/runway-spi-testkit-$V.pom" "$ROOT/held.pom"
r="$(pub --dry-run "$V")"
check "4: a missing SPI file is refused" '[ "$r" = 1 ] && grep -q "missing artifact: .*runway-spi-testkit-$V.pom" "$ROOT/pub.err"'
mv "$ROOT/held.pom" "$DIST/runway-spi-testkit-$V.pom"
cp "$DIST/runway-spi-$V.jar" "$ROOT/held.jar"; printf 'rebuilt after the manifest\n' > "$DIST/runway-spi-$V.jar"
r="$(pub --dry-run "$V")"
check "4: a file whose hash no longer matches SHA256SUMS is refused" '[ "$r" = 1 ] && grep -q "SHA256SUMS does not match" "$ROOT/pub.err" && grep -q "runway-spi-$V.jar" "$ROOT/pub.err"'
cp "$ROOT/held.jar" "$DIST/runway-spi-$V.jar"
cp "$DIST/SHA256SUMS" "$ROOT/held.sums"; grep -v "runway-spi-$V-sources.jar" "$ROOT/held.sums" > "$DIST/SHA256SUMS"
r="$(pub --dry-run "$V")"
check "4: an asset SHA256SUMS does not list is refused" '[ "$r" = 1 ] && grep -q "SHA256SUMS does not list runway-spi-$V-sources.jar" "$ROOT/pub.err"'
cp "$ROOT/held.sums" "$DIST/SHA256SUMS"
r="$(pub --dry-run 1.1.0)"
check "4: a version whose CHANGELOG section lacks the upgrade part is refused" '[ "$r" -ne 0 ] && grep -q "does not open with" "$ROOT/pub.err"'
r="$(pub --dry-run 1.3.0-SNAPSHOT)"
check "4: a SNAPSHOT is refused" '[ "$r" = 1 ] && grep -q "refusing to publish a SNAPSHOT" "$ROOT/pub.err"'
check "4: no refusal touched git or curl" '[ ! -s "$ROOT/net.log" ]'
# --- 5. Without --dry-run, the complete set goes on to the tag check (stubbed git fails) and stops there ----------
r="$(pub "$V")"
check "5: the real path stops at the tag (stub git: not on origin)" '[ "$r" = 1 ] && grep -q "tag v$V is not on origin" "$ROOT/pub.err"'
check "5: ...after asking git for the tag, never curl" 'grep -q "^git ls-remote" "$ROOT/net.log" && ! grep -q "^curl" "$ROOT/net.log"'
check "5: ...and it did not print a dry-run plan" '! grep -q "DRY RUN" "$ROOT/pub.out"'
printf 'release-assets: %d passed, %d failed\n' "$PASSES" "$FAILS"
[ "$FAILS" -eq 0 ]
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# test-release-notes.sh — tests for release-notes.sh, the release-body extraction and refusal of publish-release.sh.
# Runs offline, in a scratch directory: `bash scripts/test-release-notes.sh [scratch-parent]`. The dist module runs
# it in its test phase next to test-plugin-seed.sh (skipped with -DskipTests). Exit status 0 = all passed.
#
# The defect it guards against: the development guide said publishing refused a release section with no
# "Upgrading — read this first" part, and the script only refused a MISSING section — so the 0.5.0-beta14 notes
# came within one cut of shipping without any operator steps.
set -euo pipefail
HERE="$(dirname "$(readlink -f "$0")")"
# Release tooling is maintainer-only: a checkout without scripts/publish-release.sh (the public source tree) has
# nothing for this test to check, so it passes with a note instead of failing the build.
if [ ! -f "$HERE/publish-release.sh" ]; then
echo "release-notes: skipped (scripts/publish-release.sh is not in this checkout)"
exit 0
fi
# shellcheck source=release-notes.sh
. "$HERE/release-notes.sh"
PARENT="${1:-${TMPDIR:-/tmp}}"
mkdir -p "$PARENT"
ROOT="$(mktemp -d "$PARENT/release-notes-test.XXXXXX")"
trap 'rm -rf "$ROOT"' EXIT
FAILS=0
PASSES=0
fail() { printf 'FAIL: %s\n' "$*" >&2; FAILS=$((FAILS + 1)); }
pass() { PASSES=$((PASSES + 1)); }
check() { if eval "$2"; then pass; else fail "$1"; fi; }
# rc <notes> <version> — release_notes_check's exit status, its stderr kept in $ROOT/err.
rc() { local r=0; release_notes_check "$1" "$2" 2> "$ROOT/err" || r=$?; echo "$r"; }
CL="$ROOT/CHANGELOG.md"
cat > "$CL" <<'EOF'
# Changelog
## [Unreleased]
### Added
- something new
## [1.2.0] — 2026-10-18
_A summary line._
### Upgrading — read this first
Run the installer with --update-essential-plugins.
### Fixed
- a fix
## [1.1.0] — 2026-10-01
### Fixed
- a fix with no upgrade part
### Upgrading — read this first
Too late: not the first heading.
## [1.0.0-beta1] — 2026-09-01
### Added
- the first beta, without an upgrade part
## [1.0.0-beta12] — 2026-09-20
### Upgrading — read this first
Nothing to do.
## [0.9.0] — 2026-08-01
### Upgrading — read this first
The last section of the file.
EOF
# --- 1. Extraction ----------------------------------------------------------------------------------------------
N="$(release_notes_extract "$CL" 1.2.0)"
check "1: the section body starts after the heading line" '[ "$(printf "%s\n" "$N" | head -1)" = "_A summary line._" ]'
check "1: the section stops at the next version" '! printf "%s" "$N" | grep -q "no upgrade part"'
check "1: the section keeps its own sub-sections" 'printf "%s" "$N" | grep -q "^- a fix$"'
check "1: an unknown version extracts nothing" '[ -z "$(release_notes_extract "$CL" 3.0.0)" ]'
check "1: the last section of the file extracts (no following heading)" 'release_notes_extract "$CL" 0.9.0 | grep -q "The last section of the file."'
check "1: 1.0.0-beta1 does not match 1.0.0-beta12" '[ "$(release_notes_extract "$CL" 1.0.0-beta1 | tail -1)" = "- the first beta, without an upgrade part" ]'
check "1: dots are literal (1x2x0 is not 1.2.0)" '[ -z "$(release_notes_extract "$CL" 1x2x0)" ]'
# --- 2. Refusals ------------------------------------------------------------------------------------------------
check "2: a missing section is refused with status 1" '[ "$(rc "" 3.0.0)" = 1 ] && grep -q "has no .## \[3.0.0\]. section" "$ROOT/err"'
check "2: a section without the upgrade part is refused with status 2" '[ "$(rc "$(release_notes_extract "$CL" Unreleased)" Unreleased)" = 2 ] && grep -q "does not open with" "$ROOT/err"'
check "2: the refusal names the first heading it found" 'grep -q "is: .### Added." "$ROOT/err"'
check "2: an upgrade part that is not FIRST is refused" '[ "$(rc "$(release_notes_extract "$CL" 1.1.0)" 1.1.0)" = 2 ]'
check "2: the next section's upgrade part is not borrowed" '[ "$(rc "$(release_notes_extract "$CL" 1.0.0-beta1)" 1.0.0-beta1)" = 2 ]'
check "2: a near-miss heading is refused" '[ "$(rc "$(printf "### Upgrading\n\nx\n")" 9.9.9)" = 2 ]'
check "2: a heading only in body text does not count" '[ "$(rc "$(printf "### Added\n\nsee ### Upgrading — read this first\n")" 9.9.9)" = 2 ]'
# --- 3. Accepted ------------------------------------------------------------------------------------------------
check "3: a section that opens with the upgrade part passes" '[ "$(rc "$(release_notes_extract "$CL" 1.2.0)" 1.2.0)" = 0 ] && [ ! -s "$ROOT/err" ]'
check "3: a section with only the upgrade part passes" '[ "$(rc "$(release_notes_extract "$CL" 1.0.0-beta12)" 1.0.0-beta12)" = 0 ]'
BIG="$(printf '### Upgrading — read this first\n\n'; head -c 61000 /dev/zero | tr '\0' 'x')"
check "3: an oversized body passes with a warning" '[ "$(rc "$BIG" 9.9.9)" = 0 ] && grep -q "WARNING: the release notes are" "$ROOT/err"'
# --- 4. The real CHANGELOG: the published releases since the rule existed pass, an older one does not --------
REAL="$HERE/../CHANGELOG.md"
for v in 0.5.0-beta10 0.5.0-beta11 0.5.0-beta12 0.5.0-beta13; do
check "4: published $v passes" '[ "$(rc "$(release_notes_extract "$REAL" "$v")" "$v")" = 0 ]'
done
check "4: 0.5.0-beta9 (before the rule) is refused" '[ "$(rc "$(release_notes_extract "$REAL" 0.5.0-beta9)" 0.5.0-beta9)" = 2 ]'
# --- 5. publish-release.sh is wired to the check, and refuses before the tag, the credential or the network -----
# It needs runway-dist/target to exist (the dist module's test phase has created it). 0.5.0-beta9's artifacts are
# never in target/, so even a broken script stops at "missing artifact" — nothing can be published from here.
if [ -d "$HERE/../runway-dist/target" ]; then
r=0; bash "$HERE/publish-release.sh" 0.5.0-beta9 > "$ROOT/pub.out" 2> "$ROOT/pub.err" || r=$?
check "5: publish-release.sh refuses a section without the upgrade part" '[ "$r" -ne 0 ] && grep -q "does not open with" "$ROOT/pub.err"'
check "5: ...before looking for artifacts, the tag or a credential" '! grep -q "missing artifact\|is not on origin\|no stored credential" "$ROOT/pub.err"'
else
fail "5: runway-dist/target does not exist — run this from the dist module's test phase (mvn test)"
fi
printf 'release-notes: %d passed, %d failed\n' "$PASSES" "$FAILS"
[ "$FAILS" -eq 0 ]