QuecManager non-beta
Its about time I did this!
This commit is contained in:
65
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecmanager_cell_locking
Executable file
65
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecmanager_cell_locking
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
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"
|
||||
LOG_DIR="/tmp/log/cell_lock"
|
||||
LOG_FILE="$LOG_DIR/cell_lock.log"
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
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" -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
|
||||
}
|
||||
|
||||
stop() {
|
||||
# Remove crontab entries
|
||||
crontab -l | grep -v "$SCRIPTS_DIR/" | crontab -
|
||||
|
||||
log_message "Cell lock scheduler service stopped" "info"
|
||||
}
|
||||
|
||||
reload() {
|
||||
# Update crontab entries based on current config
|
||||
"$UPDATE_SCRIPT"
|
||||
|
||||
log_message "Cell lock scheduler service reloaded" "info"
|
||||
}
|
||||
42
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecmanager_services
Executable file
42
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecmanager_services
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=49
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
# Configuration paths
|
||||
QUEUE_DIR="/tmp/at_queue"
|
||||
RESULTS_DIR="$QUEUE_DIR/results"
|
||||
LOG_DIR="/www/signal_graphs"
|
||||
|
||||
start_service() {
|
||||
# Ensure required directories exist
|
||||
mkdir -p "$QUEUE_DIR" "$RESULTS_DIR" "$LOG_DIR"
|
||||
chmod 755 "$QUEUE_DIR" "$RESULTS_DIR" "$LOG_DIR"
|
||||
|
||||
# Start the AT Command Queue Manager
|
||||
echo "Starting AT Command Queue Manager..."
|
||||
procd_open_instance
|
||||
procd_set_param command /www/cgi-bin/services/at_queue_manager.sh
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
echo "AT Queue Manager Started"
|
||||
|
||||
# Start the Signal Metrics Logger
|
||||
echo "Starting Signal Metrics Logger..."
|
||||
procd_open_instance
|
||||
procd_set_param command /www/cgi-bin/services/log_signal_metrics.sh
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
echo "Signal Metrics Logger started"
|
||||
|
||||
echo "All QuecManager services Started"
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
# procd will handle stopping all instances automatically
|
||||
echo "Stopping QuecManager services."
|
||||
}
|
||||
84
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecprofiles
Executable file
84
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecprofiles
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=99
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
# Configuration paths
|
||||
PROG="/www/cgi-bin/services/quecprofile.sh"
|
||||
CONF="/etc/config/quecprofiles"
|
||||
TRACK_FILE="/tmp/quecprofiles_active"
|
||||
CHECK_TRIGGER="/tmp/quecprofiles_check"
|
||||
STATUS_FILE="/tmp/quecprofiles_status.json"
|
||||
DEBUG_LOG="/tmp/quecprofiles_debug.log"
|
||||
|
||||
start_service() {
|
||||
# Ensure configuration exists
|
||||
if [ ! -f "$CONF" ]; then
|
||||
# Create default configuration
|
||||
cat > "$CONF" <<-EOF
|
||||
config quecprofiles 'settings'
|
||||
option check_interval '60'
|
||||
option enable_autoswitch '1'
|
||||
option apply_priority '20'
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Ensure script is executable
|
||||
if [ -f "$PROG" ]; then
|
||||
chmod 755 "$PROG"
|
||||
else
|
||||
logger -t quecprofiles -p daemon.error "Profile daemon script not found at $PROG"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Clear any existing logs
|
||||
echo "$(date) - Init script starting service" > "$DEBUG_LOG"
|
||||
|
||||
# Check if service is enabled
|
||||
local enabled
|
||||
config_load quecprofiles
|
||||
config_get_bool enabled settings enable_autoswitch 1
|
||||
|
||||
if [ "$enabled" -eq 0 ]; then
|
||||
logger -t quecprofiles -p daemon.info "QuecProfiles service is disabled in config"
|
||||
echo "$(date) - Service is disabled in config" >> "$DEBUG_LOG"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Log before starting daemon
|
||||
logger -t quecprofiles -p daemon.info "Starting QuecProfiles Daemon with script: $PROG"
|
||||
echo "$(date) - Starting daemon using script: $PROG" >> "$DEBUG_LOG"
|
||||
|
||||
# Start the profile daemon
|
||||
echo "Starting QuecProfiles Daemon..."
|
||||
procd_open_instance "quecprofiles"
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
echo "QuecProfiles Daemon Started"
|
||||
echo "$(date) - Daemon started via procd" >> "$DEBUG_LOG"
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
# Clean up state files
|
||||
rm -f "$TRACK_FILE"
|
||||
rm -f "$CHECK_TRIGGER"
|
||||
|
||||
# Log stop action
|
||||
logger -t quecprofiles -p daemon.info "Stopping QuecProfiles service"
|
||||
echo "$(date) - Stopping service" >> "$DEBUG_LOG"
|
||||
|
||||
# procd will handle stopping the instance automatically
|
||||
echo "Stopping QuecProfiles service."
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "quecprofiles"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
touch "$CHECK_TRIGGER"
|
||||
restart
|
||||
}
|
||||
49
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecwatch
Executable file
49
ipk-source/sdxpinn-quecmanager/root/etc/init.d/quecwatch
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
DAEMON="/www/cgi-bin/services/quecwatch.sh"
|
||||
UCI_CONFIG="quecmanager"
|
||||
PID_FILE="/var/run/quecwatch.pid"
|
||||
LOG_DIR="/tmp/log/quecwatch"
|
||||
|
||||
start_service() {
|
||||
# Check if the daemon script exists
|
||||
if [ ! -x "$DAEMON" ]; then
|
||||
logger -t quecwatch -p daemon.error "Daemon script not found or not executable: $DAEMON"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if service is enabled in UCI
|
||||
local enabled
|
||||
config_load "$UCI_CONFIG"
|
||||
config_get_bool enabled quecwatch enabled 0
|
||||
|
||||
if [ "$enabled" -ne 1 ]; then
|
||||
logger -t quecwatch -p daemon.info "QuecWatch service is disabled in config"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Create log directory
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# Start the service via procd
|
||||
logger -t quecwatch -p daemon.info "Starting QuecWatch daemon"
|
||||
procd_open_instance "quecwatch"
|
||||
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"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
Reference in New Issue
Block a user