feat: add fnOS packaging, storage workflows and release pipeline

This commit is contained in:
2026-08-11 18:05:49 +08:00
parent c5922f9b08
commit 95932f0199
181 changed files with 24024 additions and 1164 deletions
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
Executable
+75
View File
@@ -0,0 +1,75 @@
#!/bin/bash
set -u
LOG_FILE="${TRIM_PKGVAR}/info.log"
PID_FILE="${TRIM_PKGVAR}/app.pid"
CMD="${TRIM_APPDEST}/server/dy.net"
DATA_ROOT="${TRIM_APPDEST_VOL}/@appshare/dy.net"
log_msg() {
printf '%s - %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$1" >> "${LOG_FILE}"
}
running_pid() {
if [ -f "${PID_FILE}" ]; then
pid=$(head -n 1 "${PID_FILE}" | tr -d '[:space:]')
if [ -n "${pid}" ] && kill -0 "${pid}" 2>/dev/null; then
printf '%s' "${pid}"
return 0
fi
fi
return 1
}
start_process() {
if [ ! -x "${CMD}" ]; then
log_msg "程序不存在或不可执行:${CMD}"
exit 1
fi
mkdir -p "${TRIM_PKGVAR}" "${TRIM_PKGVAR}/.net-bundle" "${DATA_ROOT}"
if pid=$(running_pid); then
log_msg "程序已运行,PID ${pid}"
return 0
fi
(
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
# fnOS package accounts may not have HOME. Keep any future single-file native
# extraction in the package's writable var directory instead of ~/.net.
export DOTNET_BUNDLE_EXTRACT_BASE_DIR="${TRIM_PKGVAR}/.net-bundle"
cd "$(dirname "${CMD}")" || exit 1
exec "${CMD}" "${DATA_ROOT}"
) >> "${LOG_FILE}" 2>&1 &
pid=$!
sleep 1
if kill -0 "${pid}" 2>/dev/null; then
printf '%s' "${pid}" > "${PID_FILE}"
log_msg "程序启动成功,PID ${pid}"
else
log_msg "程序启动失败,请检查日志"
exit 1
fi
}
stop_process() {
if ! pid=$(running_pid); then
rm -f "${PID_FILE}"
return 0
fi
kill "${pid}" 2>/dev/null || true
count=0
while kill -0 "${pid}" 2>/dev/null && [ "${count}" -lt 20 ]; do
sleep 0.5
count=$((count + 1))
done
if kill -0 "${pid}" 2>/dev/null; then kill -9 "${pid}" 2>/dev/null || true; fi
rm -f "${PID_FILE}"
}
case "${1:-}" in
start) start_process ;;
stop) stop_process ;;
status) running_pid >/dev/null && exit 0 || exit 3 ;;
*) echo "用法:$0 {start|stop|status}"; exit 1 ;;
esac
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
# Database changes are performed by the application after its own pre-schema backup.
# Storage migration is intentionally never started by an fnOS upgrade hook.
exit 0
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
set -eu
DATA_ROOT="${TRIM_APPDEST_VOL}/@appshare/dy.net"
DB_ROOT="${DATA_ROOT}/db"
DB_FILE="${DB_ROOT}/dy.sqlite"
BACKUP_ROOT="${DB_ROOT}/upgrade-backups"
if [ ! -f "${DB_FILE}" ]; then exit 0; fi
mkdir -p "${BACKUP_ROOT}"
DEST="${BACKUP_ROOT}/fpk-pre-0.2.25-$(date '+%Y%m%d-%H%M%S')"
mkdir -p "${DEST}"
cp -p "${DB_FILE}" "${DEST}/dy.sqlite"
if [ -f "${DB_FILE}-wal" ]; then cp -p "${DB_FILE}-wal" "${DEST}/dy.sqlite-wal"; fi
if [ -f "${DB_FILE}-shm" ]; then cp -p "${DB_FILE}-shm" "${DEST}/dy.sqlite-shm"; fi
if [ -d "${DB_ROOT}/keys" ]; then cp -a "${DB_ROOT}/keys" "${DEST}/keys"; fi
# Avoid GNU find -printf: fnOS releases may provide the BusyBox find implementation.
ls -1dt -- "${BACKUP_ROOT}"/* 2>/dev/null | tail -n +4 | while IFS= read -r backup; do
if [ -d "${backup}" ]; then rm -rf -- "${backup}"; fi
done
exit 0