uci: Initial version.
This commit is contained in:
parent
9ba1c7abf8
commit
76ddba55d8
1 changed files with 44 additions and 0 deletions
44
uci/manifests/init.pp
Normal file
44
uci/manifests/init.pp
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
# Helper class for UCI commit
|
||||
#
|
||||
class uci {
|
||||
|
||||
if $::operatingsystem != "OpenWRT" {
|
||||
fail("uci not supported on ${::operatingsystem}")
|
||||
}
|
||||
|
||||
exec { "uci commit":
|
||||
user => "root",
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Set value using UCI
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# UCI key to set
|
||||
# $value:
|
||||
# Value for given key
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# uci::set { "uhttpd.main.listen_http":
|
||||
# value => "8080",
|
||||
# }
|
||||
#
|
||||
define uci::set($value) {
|
||||
|
||||
include uci
|
||||
|
||||
exec { "uci set ${name}=${value}":
|
||||
user => "root",
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
unless => "uci get ${name} | egrep '^${value}\$'",
|
||||
notify => Exec["uci commit"],
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue