aboutsummaryrefslogtreecommitdiffstats
path: root/package/libs/sysfsutils/files
diff options
context:
space:
mode:
Diffstat (limited to 'package/libs/sysfsutils/files')
-rw-r--r--package/libs/sysfsutils/files/local.conf1
-rw-r--r--package/libs/sysfsutils/files/sysfs.conf22
-rw-r--r--package/libs/sysfsutils/files/sysfsutils48
3 files changed, 71 insertions, 0 deletions
diff --git a/package/libs/sysfsutils/files/local.conf b/package/libs/sysfsutils/files/local.conf
new file mode 100644
index 0000000000..891da73df8
--- /dev/null
+++ b/package/libs/sysfsutils/files/local.conf
@@ -0,0 +1 @@
+# local sysctl settings can be stored in this directory
diff --git a/package/libs/sysfsutils/files/sysfs.conf b/package/libs/sysfsutils/files/sysfs.conf
new file mode 100644
index 0000000000..f03246284f
--- /dev/null
+++ b/package/libs/sysfsutils/files/sysfs.conf
@@ -0,0 +1,22 @@
+#
+# /etc/sysfs.conf - Configuration file for setting sysfs attributes.
+#
+# The sysfs mount directory is automatically prepended to the attribute paths.
+#
+# Syntax:
+# attribute = value
+# mode attribute = 0600 # (any valid argument for chmod)
+# owner attribute = root:wheel # (any valid argument for chown)
+#
+# Examples:
+#
+# Always use the powersave CPU frequency governor
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
+#
+# Use userspace CPU frequency governor and set initial speed
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = userspace
+# devices/system/cpu/cpu0/cpufreq/scaling_setspeed = 600000
+#
+# Set permissions of suspend control file
+# mode power/state = 0660
+# owner power/state = root:power
diff --git a/package/libs/sysfsutils/files/sysfsutils b/package/libs/sysfsutils/files/sysfsutils
new file mode 100644
index 0000000000..0305ca82a9
--- /dev/null
+++ b/package/libs/sysfsutils/files/sysfsutils
@@ -0,0 +1,48 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2017 Rodolfo Giometti <giometti@enneenne.com>
+#
+# Based on Debian's script /etc/init.d/sysfsutils by
+# Martin Pitt <mpitt@debian.org>
+
+load_conffile() {
+ FILE="$1"
+ sed 's/#.*$//; /^[[:space:]]*$/d;
+ s/^[[:space:]]*\([^=[:space:]]*\)[[:space:]]*\([^=[:space:]]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1 \2 \3/' \
+ $FILE | {
+ while read f1 f2 f3; do
+ if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then
+ if [ -f "/sys/$f2" ] || [ -d "/sys/$f2" ]; then
+ chmod "$f3" "/sys/$f2"
+ else
+ echo "unknown attribute $f2"
+ fi
+ elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then
+ if [ -f "/sys/$f2" ]; then
+ chown "$f3" "/sys/$f2"
+ else
+ echo "unknown attribute $f2"
+ fi
+ elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then
+ if [ -f "/sys/$f1" ]; then
+ # Some fields need a terminating newline, others
+ # need the terminating newline to be absent :-(
+ echo -n "$f2" > "/sys/$f1" 2>/dev/null ||
+ echo "$f2" > "/sys/$f1"
+ else
+ echo "unknown attribute $f1"
+ fi
+ else
+ echo "syntax error in $CONFFILE: '$f1' '$f2' '$f3'"
+ exit 1
+ fi
+ done
+ }
+}
+
+START=11
+start() {
+ for file in /etc/sysfs.conf /etc/sysfs.d/*.conf; do
+ [ -r "$file" ] || continue
+ load_conffile "$file"
+ done
+}