mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 13:48:06 +00:00
ubox: only start log to file when filesystem has been mounted
If log_file is on an filesystem mounted using /etc/config/fstab we have to wait for that to happen before starting the logread process. Inhibit the start of the file-writer process and use a mount trigger to fire it up once the filesystem actually becomes available. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
6d76ec3872
commit
88baf6ce2c
@ -9,6 +9,8 @@ PIDCOUNT=0
|
||||
USE_PROCD=1
|
||||
PROG=/sbin/logread
|
||||
|
||||
extra_command "start_file" "Start writing to log file"
|
||||
|
||||
validate_log_section()
|
||||
{
|
||||
uci_load_validate system system "$1" "$2" \
|
||||
@ -34,7 +36,7 @@ start_service_daemon()
|
||||
{
|
||||
[ $log_buffer_size -eq 0 -a $log_size -gt 0 ] && log_buffer_size=$log_size
|
||||
[ $log_buffer_size -eq 0 ] && log_buffer_size=64
|
||||
procd_open_instance
|
||||
procd_open_instance logd
|
||||
procd_set_param command "/sbin/logd"
|
||||
procd_append_param command -S "${log_buffer_size}"
|
||||
procd_set_param respawn 5 1 -1
|
||||
@ -52,9 +54,12 @@ start_service_file()
|
||||
}
|
||||
[ -z "${log_file}" ] && return
|
||||
|
||||
[ "$_BOOT" = "1" ] &&
|
||||
[ "$(procd_get_mountpoints "${log_file}")" ] && return 0
|
||||
|
||||
mkdir -p "$(dirname "${log_file}")"
|
||||
|
||||
procd_open_instance
|
||||
procd_open_instance logfile
|
||||
procd_set_param command "$PROG" -f -F "$log_file" -p "$pid_file"
|
||||
[ -n "${log_size}" ] && procd_append_param command -S "$log_size"
|
||||
procd_close_instance
|
||||
@ -73,7 +78,7 @@ start_service_remote()
|
||||
[ -z "${log_ip}" ] && return
|
||||
[ -z "${log_hostname}" ] && log_hostname=$(cat /proc/sys/kernel/hostname)
|
||||
|
||||
procd_open_instance
|
||||
procd_open_instance logremote
|
||||
procd_set_param command "$PROG" -f -h "$log_hostname" -r "$log_ip" "${log_port}" -p "$pid_file"
|
||||
case "${log_proto}" in
|
||||
"udp") procd_append_param command -u;;
|
||||
@ -83,10 +88,17 @@ start_service_remote()
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
register_mount_trigger()
|
||||
{
|
||||
[ -n "${log_file}" ] && procd_add_action_mount_trigger start_file "${log_file}"
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
config_load system
|
||||
procd_add_reload_trigger "system"
|
||||
procd_add_validation validate_log_section
|
||||
config_foreach validate_log_section system register_mount_trigger
|
||||
}
|
||||
|
||||
start_service()
|
||||
@ -96,3 +108,13 @@ start_service()
|
||||
config_foreach validate_log_section system start_service_file
|
||||
config_foreach validate_log_section system start_service_remote
|
||||
}
|
||||
|
||||
start_file()
|
||||
{
|
||||
config_load system
|
||||
config_foreach validate_log_section system start_service_file
|
||||
}
|
||||
|
||||
boot() {
|
||||
_BOOT=1 start
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user