aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2022-01-30 19:39:21 +0000
committerDaniel Golle <daniel@makrotopia.org>2022-01-30 20:19:37 +0000
commit88baf6ce2c880149bd1c1d8ddacc7bc61dd4f18b (patch)
tree2b6b41ad8204a84f8361cdc5d5d08d1b584b7ac1
parent6d76ec38721f964ae9ac65d80ef8628199986fa4 (diff)
downloadupstream-88baf6ce2c880149bd1c1d8ddacc7bc61dd4f18b.tar.gz
upstream-88baf6ce2c880149bd1c1d8ddacc7bc61dd4f18b.tar.bz2
upstream-88baf6ce2c880149bd1c1d8ddacc7bc61dd4f18b.zip
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>
-rw-r--r--package/system/ubox/files/log.init28
1 files changed, 25 insertions, 3 deletions
diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init
index c4802d4199..6587cf6b06 100644
--- a/package/system/ubox/files/log.init
+++ b/package/system/ubox/files/log.init
@@ -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
+}