mirror of
				https://github.com/Ysurac/openmptcprouter.git
				synced 2025-03-09 15:40:20 +00:00 
			
		
		
		
	Add tools for RUTX platform on 6.1 kernel
This commit is contained in:
		
							parent
							
								
									f9d849ae11
								
							
						
					
					
						commit
						34d19875d7
					
				
					 34 changed files with 4894 additions and 0 deletions
				
			
		
							
								
								
									
										70
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/boot
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										70
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/boot
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,70 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2006-2011 OpenWrt.org | ||||
| 
 | ||||
| START=10 | ||||
| STOP=90 | ||||
| 
 | ||||
| uci_apply_defaults() { | ||||
| 	. /lib/functions/system.sh | ||||
| 
 | ||||
| 	cd /etc/uci-defaults || return 0 | ||||
| 	files="$(find . -type f | sort)" | ||||
| 	[ -z "$files" ] && return 0 | ||||
| 	mkdir -p /tmp/.uci | ||||
| 	for file in $files; do | ||||
| 		( . "./$file" ) && rm -f "$file" | ||||
| 	done | ||||
| 	uci commit | ||||
| } | ||||
| 
 | ||||
| boot() { | ||||
| 	[ -f /proc/mounts ] || /sbin/mount_root | ||||
| 	[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc | ||||
| 
 | ||||
| 	mkdir -p /var/run | ||||
| 	mkdir -p /var/log | ||||
| 	mkdir -p /var/lock | ||||
| 	mkdir -p /var/state | ||||
| 	mkdir -p /var/tmp | ||||
| 	mkdir -p /tmp/.uci | ||||
| 	chmod 0700 /tmp/.uci | ||||
| 	touch /var/log/wtmp | ||||
| 	touch /var/log/lastlog | ||||
| 	mkdir -p /tmp/resolv.conf.d | ||||
| 	touch /tmp/resolv.conf.d/resolv.conf.auto | ||||
| 	ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf | ||||
| 	grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug | ||||
| 	grep -q bpf /proc/filesystems && /bin/mount -o nosuid,nodev,noexec,noatime,mode=0700 -t bpf bpffs /sys/fs/bpf | ||||
| 	grep -q pstore /proc/filesystems && /bin/mount -o noatime -t pstore pstore /sys/fs/pstore | ||||
| 
 | ||||
| 	# mount all entries in fstab | ||||
| 	/bin/mount -a & | ||||
| 
 | ||||
| 	# /log directory might be created on preinit | ||||
| 	# symlink /storage to /log on TRB14X devices | ||||
| 	[ -d /storage -a ! -h /log ] && { | ||||
| 		rm -rf /log | ||||
| 		ln -sf /storage /log | ||||
| 	} | ||||
| 
 | ||||
| 	# Wifi --- | ||||
| 	param=$(/sbin/mnf_info "--name") | ||||
| 	router_name=${param:0:6} | ||||
| 	if [ $router_name == "RUTX08" ] || [ $router_name == "RUTX09" ]; then | ||||
| 		rm /etc/modules.d/ath10k | ||||
| 	fi | ||||
| 
 | ||||
| 	/bin/board_detect | ||||
| 
 | ||||
| 	/sbin/kmodloader | ||||
| 
 | ||||
| 	/bin/config_generate | ||||
| 	uci_apply_defaults | ||||
| 
 | ||||
| 	[ -f "/etc/config/teltonika" ] && rm /etc/config/teltonika | ||||
| 
 | ||||
| 	# temporary hack until configd exists | ||||
| 	/sbin/reload_config | ||||
| 	# leave finished boot script indication | ||||
| 	touch /var/run/boot-done | ||||
| } | ||||
							
								
								
									
										13
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/done
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/done
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2006 OpenWrt.org | ||||
| 
 | ||||
| START=95 | ||||
| boot() { | ||||
| 	mount_root done | ||||
| 	rm -f /sysupgrade.tgz && sync | ||||
| 
 | ||||
| 	# process user commands | ||||
| 	[ -f /etc/rc.local ] && { | ||||
| 		sh /etc/rc.local | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										66
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/gpio_switch
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										66
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/gpio_switch
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,66 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2015 OpenWrt.org | ||||
| 
 | ||||
| START=94 | ||||
| STOP=10 | ||||
| USE_PROCD=1 | ||||
| 
 | ||||
| 
 | ||||
| load_gpio_switch() | ||||
| { | ||||
| 	local name | ||||
| 	local gpio_pin | ||||
| 	local value | ||||
| 
 | ||||
| 	config_get gpio_pin "$1" gpio_pin | ||||
| 	config_get name "$1" name | ||||
| 	config_get value "$1" value 0 | ||||
| 
 | ||||
| 	[ -z "$gpio_pin" ] && { | ||||
| 		echo >&2 "Skipping gpio_switch '$name' due to missing gpio_pin" | ||||
| 		return 1 | ||||
| 	} | ||||
| 
 | ||||
| 	local gpio_path | ||||
| 	if [ -n "$(echo "$gpio_pin" | grep -E "^[0-9]+$")" ]; then | ||||
| 		gpio_path="/sys/class/gpio/gpio${gpio_pin}" | ||||
| 
 | ||||
| 		# export GPIO pin for access | ||||
| 		[ -d "$gpio_path" ] || { | ||||
| 			echo "$gpio_pin" >/sys/class/gpio/export | ||||
| 			# we need to wait a bit until the GPIO appears | ||||
| 			[ -d "$gpio_path" ] || sleep 1 | ||||
| 		} | ||||
| 
 | ||||
| 		# direction attribute only exists if the kernel supports changing the | ||||
| 		# direction of a GPIO | ||||
| 		if [ -e "${gpio_path}/direction" ]; then | ||||
| 			# set the pin to output with high or low pin value | ||||
| 			{ [ "$value" = "0" ] && echo "low" || echo "high"; } \ | ||||
| 				>"$gpio_path/direction" | ||||
| 		else | ||||
| 			{ [ "$value" = "0" ] && echo "0" || echo "1"; } \ | ||||
| 				>"$gpio_path/value" | ||||
| 		fi | ||||
| 	else | ||||
| 		gpio_path="/sys/class/gpio/${gpio_pin}" | ||||
| 
 | ||||
| 		[ -d "$gpio_path" ] && { | ||||
| 			{ [ "$value" = "0" ] && echo "0" || echo "1"; } \ | ||||
| 				>"$gpio_path/value" | ||||
| 		} | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| service_triggers() | ||||
| { | ||||
| 	procd_add_reload_trigger "system" | ||||
| } | ||||
| 
 | ||||
| start_service() | ||||
| { | ||||
| 	[ -e /sys/class/gpio/ ] && { | ||||
| 		config_load system | ||||
| 		config_foreach load_gpio_switch gpio_switch | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										140
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/led
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										140
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/led
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,140 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2008 OpenWrt.org | ||||
| 
 | ||||
| START=96 | ||||
| 
 | ||||
| load_led() { | ||||
| 	local name | ||||
| 	local sysfs | ||||
| 	local trigger | ||||
| 	local dev | ||||
| 	local ports | ||||
| 	local mode | ||||
| 	local default | ||||
| 	local delayon | ||||
| 	local delayoff | ||||
| 	local interval | ||||
| 
 | ||||
| 	config_get sysfs $1 sysfs | ||||
| 	config_get name $1 name "$sysfs" | ||||
| 	config_get trigger $1 trigger "none" | ||||
| 	config_get dev $1 dev | ||||
| 	config_get ports $1 port | ||||
| 	config_get mode $1 mode | ||||
| 	config_get_bool default $1 default "0" | ||||
| 	config_get delayon $1 delayon | ||||
| 	config_get delayoff $1 delayoff | ||||
| 	config_get interval $1 interval "50" | ||||
| 	config_get port_state $1 port_state | ||||
| 	config_get delay $1 delay "150" | ||||
| 	config_get message $1 message "" | ||||
| 	config_get gpio $1 gpio "0" | ||||
| 	config_get inverted $1 inverted "0" | ||||
| 
 | ||||
| 	if [ "$trigger" = "rssi" ]; then | ||||
| 		# handled by rssileds userspace process | ||||
| 		return | ||||
| 	fi | ||||
| 
 | ||||
| 	[ "$trigger" = "usbdev" ] && { | ||||
| 		# Backward compatibility: translate to the new trigger | ||||
| 		trigger="usbport" | ||||
| 		# Translate port of root hub, e.g. 4-1 -> usb4-port1 | ||||
| 		ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p') | ||||
| 		# Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4 | ||||
| 		[ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p') | ||||
| 	} | ||||
| 
 | ||||
| 	[ -e /sys/class/leds/${sysfs}/brightness ] && { | ||||
| 		echo "setting up led ${name}" | ||||
| 
 | ||||
| 		printf "%s %s %d\n" \ | ||||
| 			"$sysfs" \ | ||||
| 			"$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \ | ||||
| 			"$(cat /sys/class/leds/${sysfs}/brightness)" \ | ||||
| 				>> /var/run/led.state | ||||
| 
 | ||||
| 		[ "$default" = 0 ] && | ||||
| 			echo 0 >/sys/class/leds/${sysfs}/brightness | ||||
| 
 | ||||
| 		echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null | ||||
| 		ret="$?" | ||||
| 
 | ||||
| 		[ $default = 1 ] && | ||||
| 			cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness | ||||
| 
 | ||||
| 		[ $ret = 0 ] || { | ||||
| 			echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module" | ||||
| 			return 1 | ||||
| 		} | ||||
| 		case "$trigger" in | ||||
| 		"netdev") | ||||
| 			[ -n "$dev" ] && { | ||||
| 				echo $dev > /sys/class/leds/${sysfs}/device_name | ||||
| 				for m in $mode; do | ||||
| 					[ -e "/sys/class/leds/${sysfs}/$m" ] && \ | ||||
| 						echo 1 > /sys/class/leds/${sysfs}/$m | ||||
| 				done | ||||
| 				echo $interval > /sys/class/leds/${sysfs}/interval | ||||
| 			} | ||||
| 			;; | ||||
| 
 | ||||
| 		"timer"|"oneshot") | ||||
| 			[ -n "$delayon" ] && \ | ||||
| 				echo $delayon > /sys/class/leds/${sysfs}/delay_on | ||||
| 			[ -n "$delayoff" ] && \ | ||||
| 				echo $delayoff > /sys/class/leds/${sysfs}/delay_off | ||||
| 			;; | ||||
| 
 | ||||
| 		"usbport") | ||||
| 			local p | ||||
| 
 | ||||
| 			for p in $ports; do | ||||
| 				echo 1 > /sys/class/leds/${sysfs}/ports/$p | ||||
| 			done | ||||
| 			;; | ||||
| 
 | ||||
| 		"port_state") | ||||
| 			[ -n "$port_state" ] && \ | ||||
| 				echo $port_state > /sys/class/leds/${sysfs}/port_state | ||||
| 			;; | ||||
| 
 | ||||
| 		"gpio") | ||||
| 			echo $gpio > /sys/class/leds/${sysfs}/gpio | ||||
| 			echo $inverted > /sys/class/leds/${sysfs}/inverted | ||||
| 			;; | ||||
| 
 | ||||
| 		switch[0-9]*) | ||||
| 			local port_mask speed_mask | ||||
| 
 | ||||
| 			config_get port_mask $1 port_mask | ||||
| 			[ -n "$port_mask" ] && \ | ||||
| 				echo $port_mask > /sys/class/leds/${sysfs}/port_mask | ||||
| 			config_get speed_mask $1 speed_mask | ||||
| 			[ -n "$speed_mask" ] && \ | ||||
| 				echo $speed_mask > /sys/class/leds/${sysfs}/speed_mask | ||||
| 			[ -n "$mode" ] && \ | ||||
| 				echo "$mode" > /sys/class/leds/${sysfs}/mode | ||||
| 			;; | ||||
| 		esac | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| start() { | ||||
| 	[ -e /sys/class/leds/ ] && { | ||||
| 		[ -s /var/run/led.state ] && { | ||||
| 			local led trigger brightness | ||||
| 			while read led trigger brightness; do | ||||
| 				[ -e "/sys/class/leds/$led/trigger" ] && \ | ||||
| 					echo "$trigger" > "/sys/class/leds/$led/trigger" | ||||
| 
 | ||||
| 				[ -e "/sys/class/leds/$led/brightness" ] && \ | ||||
| 					echo "$brightness" > "/sys/class/leds/$led/brightness" | ||||
| 			done < /var/run/led.state | ||||
| 			rm /var/run/led.state | ||||
| 		} | ||||
| 
 | ||||
| 		config_load system | ||||
| 		config_foreach load_led led | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										37
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/modem_tracker
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										37
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/modem_tracker
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2021 Teltonika Networks | ||||
| # Copyright (C) 2022 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> | ||||
| 
 | ||||
| START=2 | ||||
| 
 | ||||
| USE_PROCD=1 | ||||
| 
 | ||||
| PROG=/bin/board_track | ||||
| NAME=board_track | ||||
| PIDCOUNT=1 | ||||
| 
 | ||||
| start_service() { | ||||
| 	. /lib/functions | ||||
| 	 | ||||
| 	[ "$(board_name)" != "teltonika,rutx" ] && return 0 | ||||
| 	local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid" | ||||
| 
 | ||||
| 	procd_open_instance | ||||
| 	procd_set_param command "$PROG" | ||||
| 	procd_set_param file /etc/config/system | ||||
| 
 | ||||
| 	procd_set_param respawn | ||||
| 
 | ||||
| 	procd_set_param stdout 1 | ||||
| 	procd_set_param pidfile $pid_file | ||||
| 	procd_close_instance | ||||
| } | ||||
| 
 | ||||
| reload_service() { | ||||
| 	stop | ||||
| 	start | ||||
| } | ||||
| 
 | ||||
| service_triggers() { | ||||
| 	procd_add_reload_trigger "system" | ||||
| } | ||||
							
								
								
									
										28
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/ntpserver
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/ntpserver
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| 
 | ||||
| # Copyright (C) 2021 Teltonika | ||||
| 
 | ||||
| START=50 | ||||
| STOP=51 | ||||
| USE_PROCD=1 | ||||
| 
 | ||||
| service_triggers() | ||||
| { | ||||
| 	procd_add_reload_trigger "ntpserver" | ||||
| } | ||||
| 
 | ||||
| start_service() { | ||||
| 	. /lib/functions.sh | ||||
| 	local enabled | ||||
| 
 | ||||
| 	config_load ntpserver | ||||
| 	config_get enabled general enabled "0" | ||||
| 
 | ||||
| 	[ "$enabled" -gt 0 ] || return | ||||
| 
 | ||||
| 	logger -t "ntpd" "Starting NTP server" | ||||
| 	procd_open_instance | ||||
| 	procd_set_param respawn 0 | ||||
| 	procd_set_param command "ntpd" -ln | ||||
| 	procd_close_instance | ||||
| } | ||||
							
								
								
									
										32
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/powerctl
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										32
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/powerctl
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| 
 | ||||
| START=98 | ||||
| 
 | ||||
| ipq40xx_power_auto() { | ||||
| 	# change scaling governor as ondemand to enable clock scaling based on system load | ||||
| 	echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | ||||
| 
 | ||||
| 	# set scaling min freq as 200 MHz | ||||
| 	echo "716000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq | ||||
| 
 | ||||
| 	# Change sampling rate for frequency scaling decisions to 1s, from 10 ms | ||||
| 	#echo "1000000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate | ||||
| 
 | ||||
| 	# Change sampling rate for frequency down scaling decision to 10s | ||||
| 	#echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor | ||||
| 
 | ||||
| 	# Change the CPU load threshold above which frequency is up-scaled to | ||||
| 	# turbo frequency,to 50% | ||||
| 	#echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold | ||||
| } | ||||
| 
 | ||||
| start() { | ||||
| 	. /lib/functions.sh | ||||
| 
 | ||||
| 	local board=$(board_name) | ||||
| 	case "$board" in | ||||
| 	teltonika,rutx | ap-dk01.1-c1 | ap-dk01.1-c2 | ap-dk04.1-c1 | ap-dk04.1-c2 | ap-dk04.1-c3 | \ | ||||
| 	ap-dk04.1-c4   | ap-dk04.1-c5 | ap-dk05.1-c1 | ap-dk06.1-c1 | ap-dk07.1-c1 | ap-dk07.1-c2 | ap-dk07.1-c3) | ||||
| 		ipq40xx_power_auto ;; | ||||
| 	esac | ||||
| } | ||||
							
								
								
									
										46
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/sysctl
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/sysctl
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,46 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2006 OpenWrt.org | ||||
| 
 | ||||
| START=11 | ||||
| 
 | ||||
| apply_defaults() { | ||||
| 	local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)" | ||||
| 	local min_free frag_low_thresh frag_high_thresh | ||||
| 
 | ||||
| 	if [ "$mem" -gt 65536 ]; then # 128M | ||||
| 		min_free=16384 | ||||
| 	elif [ "$mem" -gt 32768 ]; then # 64M | ||||
| 		#Too high for RUT3 device, lets make 2048 | ||||
| 		#min_free=8192 | ||||
| 		min_free=2048 | ||||
| 	else | ||||
| 		min_free=1024 | ||||
| 		frag_low_thresh=393216 | ||||
| 		frag_high_thresh=524288 | ||||
| 	fi | ||||
| 
 | ||||
| 	sysctl -qw vm.min_free_kbytes="$min_free" | ||||
| 
 | ||||
| 	[ "$frag_low_thresh" ] && sysctl -qw \ | ||||
| 		net.ipv4.ipfrag_low_thresh="$frag_low_thresh" \ | ||||
| 		net.ipv4.ipfrag_high_thresh="$frag_high_thresh" \ | ||||
| 		net.ipv6.ip6frag_low_thresh="$frag_low_thresh" \ | ||||
| 		net.ipv6.ip6frag_high_thresh="$frag_high_thresh" \ | ||||
| 		net.netfilter.nf_conntrack_frag6_low_thresh="$frag_low_thresh" \ | ||||
| 		net.netfilter.nf_conntrack_frag6_high_thresh="$frag_high_thresh" | ||||
| 
 | ||||
| 	# first set default, then all interfaces to avoid races with appearing interfaces | ||||
| 	if [ -d /proc/sys/net/ipv6/conf ]; then | ||||
| 		echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra | ||||
| 		for iface in /proc/sys/net/ipv6/conf/*/accept_ra; do | ||||
| 			echo 0 > "$iface" | ||||
| 		done | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| start() { | ||||
| 	apply_defaults | ||||
| 	for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do | ||||
| 		[ -f "$CONF" ] && sysctl -e -p "$CONF" >&- | ||||
| 	done | ||||
| } | ||||
							
								
								
									
										34
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/sysfixtime
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/sysfixtime
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2013-2014 OpenWrt.org | ||||
| 
 | ||||
| START=00 | ||||
| STOP=90 | ||||
| 
 | ||||
| RTC_DEV=/dev/rtc0 | ||||
| HWCLOCK=/sbin/hwclock | ||||
| 
 | ||||
| boot() { | ||||
| #	start && exit 0 | ||||
| 
 | ||||
| 	local maxtime="$(maxtime)" | ||||
| 	local curtime="$(date +%s)" | ||||
| 	[ $curtime -lt $maxtime ] && date -s @$maxtime | ||||
| } | ||||
| 
 | ||||
| start() { | ||||
| 	boot | ||||
| } | ||||
| 
 | ||||
| stop() { | ||||
| 	[ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -u -f $RTC_DEV && \ | ||||
| 		logger -t sysfixtime "saved '$(date)' to $RTC_DEV" | ||||
| } | ||||
| 
 | ||||
| maxtime() { | ||||
| 	local file newest | ||||
| 
 | ||||
| 	for file in $( find /etc -type f ) ; do | ||||
| 		[ -z "$newest" -o "$newest" -ot "$file" ] && newest=$file | ||||
| 	done | ||||
| 	[ "$newest" ] && date -r "$newest" +%s | ||||
| } | ||||
							
								
								
									
										45
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/system
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										45
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/system
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2014 OpenWrt.org | ||||
| 
 | ||||
| START=10 | ||||
| USE_PROCD=1 | ||||
| 
 | ||||
| validate_system_section() { | ||||
| 	uci_load_validate system system "$1" "$2" \ | ||||
| 		'hostname:string:%%NAME%%' \ | ||||
| 		'conloglevel:uinteger' \ | ||||
| 		'buffersize:uinteger' \ | ||||
| 		'timezone:string:UTC' \ | ||||
| 		'zonename:string' | ||||
| } | ||||
| 
 | ||||
| system_config() { | ||||
| 	[ "$2" = 0 ] || { | ||||
| 		echo "validation failed" | ||||
| 		return 1 | ||||
| 	} | ||||
| 
 | ||||
| 	echo "$hostname" > /proc/sys/kernel/hostname | ||||
| 	[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} | ||||
| 	echo "$timezone" > /tmp/TZ | ||||
| 	[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/${zonename// /_}" ] \ | ||||
| 		&& ln -sf "/usr/share/zoneinfo/${zonename// /_}" /tmp/localtime \ | ||||
| 		&& rm -f /tmp/TZ | ||||
| 
 | ||||
| 	# apply timezone to kernel | ||||
| 	hwclock -u --systz | ||||
| } | ||||
| 
 | ||||
| reload_service() { | ||||
| 	config_load system | ||||
| 	config_foreach validate_system_section system system_config | ||||
| } | ||||
| 
 | ||||
| service_triggers() { | ||||
| 	procd_add_reload_trigger "system" | ||||
| 	procd_add_validation validate_system_section | ||||
| } | ||||
| 
 | ||||
| start_service() { | ||||
| 	reload_service | ||||
| } | ||||
							
								
								
									
										13
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/umount
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								6.1/target/linux/ipq40xx/base-files/etc/init.d/umount
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2006 OpenWrt.org | ||||
| 
 | ||||
| STOP=90 | ||||
| 
 | ||||
| restart() { | ||||
| 	: | ||||
| } | ||||
| 
 | ||||
| stop() { | ||||
| 	sync | ||||
| 	/bin/umount -a -d -r | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue