aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-08-10 16:57:23 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2016-08-10 16:58:01 +0200
commit4c9c24b11fa49edd270288882fbb81380c5dd3ac (patch)
treef8709573d29a4c5f1caf7196804b646db72c4d8f /main/openrc
parent763aae0d1827616dae68317ab10bc6dd73001773 (diff)
downloadaports-4c9c24b11fa49edd270288882fbb81380c5dd3ac.tar.bz2
aports-4c9c24b11fa49edd270288882fbb81380c5dd3ac.tar.xz
main/openrc: add sysfsconf script
so we can edit sysfs variables during boot
Diffstat (limited to 'main/openrc')
-rw-r--r--main/openrc/APKBUILD12
-rw-r--r--main/openrc/sysfsconf.initd66
2 files changed, 74 insertions, 4 deletions
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD
index 6f5d4cb3e1..d096e33bd5 100644
--- a/main/openrc/APKBUILD
+++ b/main/openrc/APKBUILD
@@ -2,7 +2,7 @@
pkgname=openrc
pkgver=0.21.2
_ver=${pkgver/_git*/}
-pkgrel=0
+pkgrel=1
pkgdesc="OpenRC manages the services, startup and shutdown of a host"
url="http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git"
arch="all"
@@ -32,6 +32,7 @@ source="openrc-$pkgver.tar.gz::https://github.com/OpenRC/openrc/archive/$pkgver.
modloop.confd
consolefont.initd
consolefont.confd
+ sysfsconf.initd
"
_builddir="$srcdir/$pkgname-$_ver"
@@ -94,7 +95,8 @@ d83df5513f08f09fa9e7353327701bf7 openrc.logrotate
27c22aa4e5cdba499ac9a0b6b9385f7d networking.initd
c1ec888202d868710b5749f7b217d1e3 modloop.confd
bd51c5353d6dbbb34d929bf59097b232 consolefont.initd
-1c629807d282ca1dc73ffe55c29146ef consolefont.confd"
+1c629807d282ca1dc73ffe55c29146ef consolefont.confd
+443f231c3e866981b8916a821dd51e90 sysfsconf.initd"
sha256sums="b47e9cbf1a8dec22d4811d8da9ff6a1b3899f9add1d58e6021f21d5b14514404 openrc-0.21.2.tar.gz
c807aed11d7eb42de5c421a6d117532f6215697f159f40cb3404bdc80270bee1 openrc-0.4.3-mkmntdirs.patch
e869e2076c10a7134f5d9e4ae4a5d09ca35c6333d400556f1e329170d2e58066 0001-Force-root-be-rw-before-localmount.patch
@@ -113,7 +115,8 @@ e92994dfd5ad6b099eca7627e36dbbe1107c5862b46722c1e1e1b13d10276b60 modloop.initd
66151b5cc199485ddd188528a0f22f081994721f04c15b33df38f41a5d08ea78 networking.initd
a5a0316cd59f5401b1d789bb466c98186201277ba6f014017b14965fcc10c254 modloop.confd
8a3f663e9ac14f62c3aef4121736a71edd676bdc9dd93c1d411f13a0e7ab4ee6 consolefont.initd
-9010b94892280f0bb42be39c0e989a70439eb97cbfe2a7a41a32df9a3035b8c2 consolefont.confd"
+9010b94892280f0bb42be39c0e989a70439eb97cbfe2a7a41a32df9a3035b8c2 consolefont.confd
+4f5a5bebf4361e0db84546910231a61f824a8ea38325bd88b1adadec48f2338d sysfsconf.initd"
sha512sums="52f4b747bab252adaee046ecb04aceda55cacc7fc8e1439f0f57a3dfb1bf2c7e60aab695f6aa8996c57fdd4f8541af40e09fed06fbf88a566c6d0182de338326 openrc-0.21.2.tar.gz
eee27fbf72776fb70d3aa6c6464180731d522191e5755aa431ab09ea11dd11bf001a95618adcaa5ccc08455268003ca2917b2bff31adc9894214221c469a97db openrc-0.4.3-mkmntdirs.patch
51c77be5ab726d50ef1d0b9dab644edef1ff739e855e3a12ab27beada8911998e0c6a7491eb92df621dcdb633b672d933a4edc00115ec43bdf1271105239ebb7 0001-Force-root-be-rw-before-localmount.patch
@@ -132,4 +135,5 @@ c4de2292b5a175f082f4f80de5145746e4d97481fccb1d22f3a637e46c7c986ad4cd363cb1096312
9aeba2c5cae539f16185b82c6e6e84c1b044e838749b92e8994172296d86ec3f1c674d62d54db1e08a8191e513ddb0ab3509f50ccae6cb5d7ba5ff5a5b6abb46 networking.initd
aa702a7da8e6c0e5d8738febaf6b4e4cb021b30ce5c1809b530abf2b36739079446b16fc054740da8d86ed099942cf5deed6597cedb64c058f3def587a8b4689 modloop.confd
c8d52d69692a00862cd55719174d7a260d5149f4951dd71196f5e9cebce3a75420a8815f0fe8b186d00b4d46739dc54542dae01a941605fcb1435f4385e444b7 consolefont.initd
-260fb9500cf59ad00006086b80d463b5557c4779eb6683966a570471d302ec00325acedabf542a70f7f4bda7b5d813b51128b46d75e0c01f78223c68b3c75260 consolefont.confd"
+260fb9500cf59ad00006086b80d463b5557c4779eb6683966a570471d302ec00325acedabf542a70f7f4bda7b5d813b51128b46d75e0c01f78223c68b3c75260 consolefont.confd
+795bf842ee223d97cf803eb280de73be3742bf1b32586446b0df0caeddbdde7fa7d6512f81f16191522fd7d55da54dd5485a801d267b8724fa363d950f0e168d sysfsconf.initd"
diff --git a/main/openrc/sysfsconf.initd b/main/openrc/sysfsconf.initd
new file mode 100644
index 0000000000..cefc3595dd
--- /dev/null
+++ b/main/openrc/sysfsconf.initd
@@ -0,0 +1,66 @@
+#!/sbin/openrc-run
+
+description="Set sysfs variables from /etc/sysfs.conf and /etc/sysfs.d/*.conf"
+conffile=/etc/sysfs.conf
+confdir=/etc/sysfs.d
+
+depend() {
+ need sysfs
+}
+
+setval() {
+ local value="$1" attrib="$2"
+ # Some fields need a terminating newline, others
+ # need the terminating newline to be absent :-(
+ echo -n "$value" > "$attrib" 2>/dev/null \
+ || echo "$value" > "$attrib"
+}
+
+load_conffile() {
+ local file="$1"
+ while read line; do
+ local line=${line%%#*}
+ local cmd= attrib= value=
+ set -- $line
+ if [ $# -eq 0 ]; then
+ continue
+ fi
+ case "$1$3" in
+ mode=) cmd=chmod
+ attrib="$2"
+ value="$4"
+ ;;
+ owner=) cmd=chown
+ attrib="$2"
+ value="$4"
+ ;;
+ *) if [ "$2" = "=" ]; then
+ cmd=setval
+ attrib="$1"
+ value="$3"
+ fi
+ ;;
+ esac
+ if ! [ -e "/sys/$attrib" ]; then
+ eerror "$attrib: unknown attribute"
+ continue
+ fi
+ if [ -z "$attrib" ] || [ -z "$value" ]; then
+ eerror "syntax error in $file: '$line'"
+ continue
+ fi
+ $cmd "$value" "/sys/$attrib"
+ done < "$file"
+}
+
+start() {
+ [ -r "$conffile" -o -d "$confdir" ] || return 0
+ ebegin "Setting sysfs variables"
+ for file in $conffile $confdir/*.conf; do
+ [ -r "$file" ] || continue
+ load_conffile "$file" || return 1
+ done
+ eend 0
+
+}
+