fix(hexojs): Bind server to 0.0.0.0, add publish command

- Server now binds to 0.0.0.0 instead of localhost for external access
- Added publish command to copy static files to /www/blog/
- Startup script always regenerates to ensure correct binding
- Bumped release to r3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-24 14:23:04 +01:00
parent 170f4a90e2
commit b17da12677
2 changed files with 37 additions and 8 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=secubox-app-hexojs
PKG_VERSION:=1.0.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_ARCH:=all
PKG_MAINTAINER:=CyberMind Studio <contact@cybermind.fr>

View File

@ -101,7 +101,8 @@ Build Commands:
serve Start preview server (port $http_port)
build Generate static files
clean Clean generated files
deploy Deploy to configured target
deploy Deploy to configured git target
publish Copy static files to /www/blog/
Service Commands:
service-run Run in foreground (for init)
@ -293,8 +294,7 @@ lxc_run() {
# Ensure start script exists in container
local start_script="$LXC_ROOTFS/opt/start-hexo.sh"
if [ ! -f "$start_script" ]; then
cat > "$start_script" << 'STARTEOF'
cat > "$start_script" << 'STARTEOF'
#!/bin/sh
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH
export HOME=/root
@ -302,11 +302,11 @@ export NODE_ENV=production
HEXO_PORT="${HEXO_PORT:-4000}"
SITE_DIR="/opt/hexojs/site"
cd "$SITE_DIR" 2>/dev/null || exec tail -f /dev/null
[ -d "node_modules" ] || npm install
[ -d "$SITE_DIR/public" ] || hexo generate
exec hexo server -p "$HEXO_PORT"
exec hexo server -p "$HEXO_PORT" -i 0.0.0.0
STARTEOF
chmod +x "$start_script"
fi
chmod +x "$start_script"
log_info "Starting Hexo container on port $http_port..."
exec lxc-start -n "$LXC_NAME" -F -f "$LXC_CONFIG"
@ -762,7 +762,7 @@ cmd_serve() {
fi
log_info "Starting preview server on port $http_port..."
lxc_exec sh -c "cd /opt/hexojs/site && hexo server -p $http_port"
lxc_exec sh -c "cd /opt/hexojs/site && hexo server -p $http_port -i 0.0.0.0"
}
cmd_build() {
@ -813,6 +813,34 @@ cmd_deploy() {
log_info "Deploy complete!"
}
cmd_publish() {
require_root
load_config
local public_dir="$data_path/site/public"
local portal_path="/www/blog"
# Allow custom portal path from config
local custom_path=$(uci_get portal.path)
[ -n "$custom_path" ] && portal_path="$custom_path"
if [ ! -d "$public_dir" ]; then
log_error "No public directory found. Run: hexoctl build"
return 1
fi
log_info "Publishing to $portal_path..."
# Create portal directory
ensure_dir "$portal_path"
# Sync files
rsync -av --delete "$public_dir/" "$portal_path/"
log_info "Published $(find "$portal_path" -type f | wc -l) files to $portal_path"
log_info "Access at: http://$(uci -q get network.lan.ipaddr || echo 'router')/blog/"
}
cmd_logs() {
load_config
@ -1089,6 +1117,7 @@ case "${1:-}" in
build) shift; cmd_build "$@" ;;
clean) shift; cmd_clean "$@" ;;
deploy) shift; cmd_deploy "$@" ;;
publish) shift; cmd_publish "$@" ;;
logs) shift; cmd_logs "$@" ;;
shell) shift; cmd_shell "$@" ;;