Use >/dev/null 2>&1 instead of just 2>/dev/null when sourcing master-link.sh and calling chain_add_block, mesh_init, peer_add, factory_trust_peer, and gossip_sync to prevent p2p-mesh.sh usage text and block hashes from corrupting CGI JSON responses. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1.1 KiB
Bash
43 lines
1.1 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# SecuBox Master-Link - Token cleanup cron
|
|
|
|
START=95
|
|
STOP=15
|
|
USE_PROCD=1
|
|
|
|
EXTRA_COMMANDS="cleanup"
|
|
EXTRA_HELP=" cleanup Run token cleanup now"
|
|
|
|
start_service() {
|
|
local enabled=$(uci -q get master-link.main.enabled)
|
|
[ "$enabled" != "1" ] && return 0
|
|
|
|
# Initialize master-link directories (suppress sourced library output)
|
|
. /usr/lib/secubox/master-link.sh >/dev/null 2>&1
|
|
ml_init >/dev/null 2>&1
|
|
|
|
# Add cron job for token cleanup every 5 minutes
|
|
local cron_line="*/5 * * * * /usr/lib/secubox/master-link.sh token-cleanup >/dev/null 2>&1"
|
|
local cron_tag="# master-link-cleanup"
|
|
|
|
# Remove old entry if exists
|
|
crontab -l 2>/dev/null | grep -v "master-link" | crontab -
|
|
|
|
# Add new entry
|
|
(crontab -l 2>/dev/null; echo "$cron_line $cron_tag") | crontab -
|
|
|
|
logger -t master-link "Master-Link service started (role: $(uci -q get master-link.main.role))"
|
|
}
|
|
|
|
stop_service() {
|
|
# Remove cron job
|
|
crontab -l 2>/dev/null | grep -v "master-link" | crontab -
|
|
|
|
logger -t master-link "Master-Link service stopped"
|
|
}
|
|
|
|
cleanup() {
|
|
. /usr/lib/secubox/master-link.sh
|
|
ml_token_cleanup
|
|
}
|