The following commands set property values:
Changes the value of a property.
Adds a value to a multi-value property.
Changes the value of an environment variable for a service process execution environment.
Remember to use the svccfg refresh command or svcadm refresh command to commit configuration changes into the running snapshot.
Example 20 Setting a Simple ValueIn the simplest use of setprop, specify a pg/name for the selected service or instance, where pg is the name of the property group and name is the name of the property, and specify the new value after an equals symbol. If the property already exists or is templated, you do not need to specify the property type.
$ svccfg -s pkg/server:s11 setprop pkg/port=81Example 21 Setting a Value that Contains a Colon Character
If the property value contains a colon character (:), then specify the property type as shown in the following example where the type is astring:
$ svccfg -s system-repository:default setprop config/http_proxy = astring: https://proxyURI
Use the listprop subcommand to find the type of the property you want to set.
$ svccfg -s system-repository:default listprop config/http_proxy config/http_proxy astringExample 22 Setting a Value that Contains Embedded Spaces
Use double quotation marks to set a value that contains embedded spaces. Depending on your shell, you might need to enclose the double-quoted string in single quotation marks.
$ svccfg -s pkg/mirror setprop config/crontab_period = "00 3 25 * *" $ svccfg -s pkg/mirror setprop config/crontab_period = '"00 3 25 * *"'
Use quotation marks to set a value that contains double quotation marks or backslash characters, and use a backslash character to escape any double quotation marks or backslash characters.
Example 23 Setting a Value that Is a Set of ValuesUse parentheses to specify a set of values as a single value. Depending on your shell, you might need to enclose the value set in single quotation marks as well.
$ svccfg -s dns/client setprop config/nameserver = (10.0.0.1 192.168.0.1) $ svccfg -s dns/client setprop config/nameserver = '(10.0.0.1 192.168.0.1)' $ svccfg -s dns/client listprop config/nameserver config/nameserver net_address 10.0.0.1 192.168.0.1
Use the describe subcommand to find the number of values allowed in the set of values.
$ svccfg -s dns/client describe -v config/nameserver config/nameserver net_address 10.0.0.1 192.168.0.1 type: net_address required: false The IP address of a DNS nameserver to be used by the resolver. visibility: readwrite minimum number of values: 1 maximum number of values: 3 value: 10.0.0.1 value: 192.168.0.1Example 24 Adding a Value
Use the addpropvalue subcommand to add the given value to the specified property of the selected service or service instance. The new value is appended to the end of the existing list of property values for the property.
$ svcprop -p keymap/layout keymap:default US-English $ svccfg -s keymap:default addpropvalue keymap/layout UK-English $ svccfg -s keymap:default listprop keymap/layout keymap/layout astring "US-English" "UK-English"
In the previous setprop example, all values in the set of values must be specified at once. If only one value is specified, that value becomes the new set of one value. In this addpropvalue example, the added values are distinct. To access these added values, you must use the libscf function scf_iter_property_values() to iterate over the values. While listprop lists both values, describe lists only the first value and reports that the maximum allowed number of values for this property is one.
$ svccfg -s keymap:default describe -v keymap/layout keymap/layout astring US-English type: astring required: true The keyboard layout visibility: readwrite minimum number of values: 1 maximum number of values: 1 value: US-English