Fixed Signal Quality and Cell Locking
This commit is contained in:
@@ -1,49 +1,65 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=95
|
||||
START=99
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
DAEMON="/www/cgi-bin/services/scheduled_cell_locking.sh"
|
||||
SCRIPTS_DIR="/www/cgi-bin/quecmanager/cell-locking"
|
||||
BOOT_SCRIPT="$SCRIPTS_DIR/boot_check.sh"
|
||||
UPDATE_SCRIPT="$SCRIPTS_DIR/update_crontab.sh"
|
||||
UCI_CONFIG="quecmanager"
|
||||
PID_FILE="/var/run/cell_lock_scheduler.pid"
|
||||
LOG_DIR="/tmp/log/cell_lock"
|
||||
LOG_FILE="$LOG_DIR/cell_lock.log"
|
||||
|
||||
start_service() {
|
||||
# Check if the daemon script exists
|
||||
if [ ! -x "$DAEMON" ]; then
|
||||
logger -t cell_lock -p daemon.error "Daemon script not found or not executable: $DAEMON"
|
||||
return 1
|
||||
fi
|
||||
# Function to log messages
|
||||
log_message() {
|
||||
local message="$1"
|
||||
local level="${2:-info}"
|
||||
local component="init_script"
|
||||
local timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# Ensure log directory exists
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# Format: [timestamp] [level] [component] message
|
||||
echo "[$timestamp] [$level] [$component] $message" >> "$LOG_FILE"
|
||||
|
||||
# Also log to system log
|
||||
logger -t "cell_lock_$component" -p "daemon.$level" "$message"
|
||||
}
|
||||
|
||||
# Check if service is enabled in UCI
|
||||
start() {
|
||||
# Make scripts executable
|
||||
chmod +x "$SCRIPTS_DIR"/*.sh
|
||||
chmod +x /www/cgi-bin/quecmanager/cell-locking/handle_scheduled_locking.sh
|
||||
|
||||
# Check if enabled
|
||||
local enabled
|
||||
config_load "$UCI_CONFIG"
|
||||
config_get_bool enabled cell_lock enabled 0
|
||||
|
||||
if [ "$enabled" -ne 1 ]; then
|
||||
logger -t cell_lock -p daemon.info "Cell lock scheduler is disabled in config"
|
||||
return 0
|
||||
if [ "$enabled" -eq 1 ]; then
|
||||
# Update crontab entries
|
||||
"$UPDATE_SCRIPT"
|
||||
|
||||
# Run boot check
|
||||
"$BOOT_SCRIPT"
|
||||
|
||||
log_message "Cell lock scheduler service started" "info"
|
||||
else
|
||||
log_message "Cell lock scheduler is disabled in config" "info"
|
||||
fi
|
||||
|
||||
# Create log directory
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# Start the service via procd
|
||||
logger -t cell_lock -p daemon.info "Starting cell lock scheduler daemon"
|
||||
procd_open_instance "cell_lock_scheduler"
|
||||
procd_set_param command "$DAEMON"
|
||||
procd_set_param respawn 3600 5 5 # Retry every hour, 5 times max
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param pidfile "$PID_FILE"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$UCI_CONFIG"
|
||||
stop() {
|
||||
# Remove crontab entries
|
||||
crontab -l | grep -v "$SCRIPTS_DIR/" | crontab -
|
||||
|
||||
log_message "Cell lock scheduler service stopped" "info"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
reload() {
|
||||
# Update crontab entries based on current config
|
||||
"$UPDATE_SCRIPT"
|
||||
|
||||
log_message "Cell lock scheduler service reloaded" "info"
|
||||
}
|
||||
Reference in New Issue
Block a user