Print this page
XXX Remove nawk(1)


 152 #
 153 # set_daemon_nonoption_properties inst_fmri optstring options propnames
 154 #       default
 155 #
 156 # Function looks past option list for addition values, and sets properties
 157 # specified in propnames to additional positional values. If no value
 158 # is found for additional property, default is used.
 159 #
 160 set_daemon_nonoption_properties()
 161 {
 162         OPTIND=1
 163         # Skip options
 164         while getopts $3 opt $2; do
 165                 case $opt in
 166                         ? )
 167                 esac
 168         done
 169         pos=$OPTIND
 170         for prop in $4
 171         do
 172                 val=`/usr/bin/echo $2 | /usr/bin/nawk -v POS=$pos \
 173                     '{ print $POS }'`
 174                 if [ -z "$val" ]; then
 175                         val="$5"
 176                 fi
 177                 set_routeadm_property $1 $prop $val
 178                 pos=`expr $pos + 1`
 179         done
 180 }
 181 
 182 #
 183 # get_daemon_args $inst_fmri
 184 #
 185 # Retrieves routeadm/daemon-args property values, if any.  Removes
 186 # quotes around values including spaces.
 187 #
 188 get_daemon_args()
 189 {
 190         args=`/usr/sbin/svccfg -s $1 listprop routeadm/daemon-args | \
 191             /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf "%s ", $i }' | \
 192             /usr/bin/nawk '{sub(/^\"/, ""); sub(/\"[ \t]*$/,""); print}'`
 193         echo "$args"
 194 }
 195 
 196 #
 197 # clear_daemon_args $inst_fmri
 198 #
 199 # Blanks routeadm/daemon-args property used in upgrade.
 200 #
 201 clear_daemon_args()
 202 {
 203         /usr/sbin/svccfg -s $1 delprop routeadm/daemon-args 2>/dev/null
 204 }
 205 
 206 #
 207 # The functions below are used to map back from property settings to
 208 # commandline arguments to launch daemons.
 209 #
 210 
 211 get_routeadm_property()
 212 {
 213         propval=`/sbin/routeadm -l $1 | /usr/bin/nawk -v PROP=$2 \
 214             '($1 == PROP) { for (i = 3; i < NF; i++) printf $i" "; \
 215             if (NF >= 3) {printf $NF}}'`
 216         echo "$propval"
 217 }
 218 
 219 #
 220 # get_daemon_option_from_boolean_property inst_fmri prop option value_set
 221 #
 222 # Returns appropriate daemon option for boolean property prop - if current
 223 # value matches value_set.
 224 #
 225 get_daemon_option_from_boolean_property()
 226 {
 227         propval=`get_routeadm_property $1 $2`
 228         if [ "$propval" = "$4" ]; then
 229                 echo "${3}"
 230         fi
 231 }
 232 
 233 #


 238 #
 239 get_daemon_option_from_property()
 240 {
 241         propval=`get_routeadm_property $1 $2`
 242         if [ "$propval" != "$4" ]; then
 243                 echo "-${3} $propval"
 244         fi
 245 }
 246 
 247 #
 248 # get_daemon_ordered_multivalue_option_from_property inst_fmri prop
 249 # option
 250 #
 251 # Returns appropriate daemon option and associated values. Values are
 252 # unquoted, i.e. -A value1 -A value2
 253 #
 254 get_daemon_ordered_multivalue_option_from_property()
 255 {
 256         # get property values, removing trailing delimiter.
 257         propvals=`get_routeadm_property $1 $2 | \
 258             /usr/bin/nawk '{sub(/;[ \t]*$/, ""); print }'`
 259         # Substitute switch for internal delimiters.
 260         fixed_propvals=`/usr/bin/echo $propvals | \
 261             /usr/bin/nawk -v SWITCH=" -${3} " \
 262             '{sub(/;/, SWITCH); print }'`
 263         if [ -n "$fixed_propvals" ]; then
 264                 echo "-${3} $fixed_propvals"
 265         fi
 266 }
 267 
 268 #
 269 # get_nonoption_property inst_fmri prop ignore_value
 270 #
 271 # Returns appropriate non-option property (at end of option list), unless
 272 # value matches ignore value, in which case nothing is returned.
 273 #
 274 get_daemon_nonoption_property()
 275 {
 276         propval=`get_routeadm_property $1 $2`
 277         if [ -n "$propval" -a "$propval" != "$3" ]; then
 278                 echo "$propval"
 279         fi
 280 }


 152 #
 153 # set_daemon_nonoption_properties inst_fmri optstring options propnames
 154 #       default
 155 #
 156 # Function looks past option list for addition values, and sets properties
 157 # specified in propnames to additional positional values. If no value
 158 # is found for additional property, default is used.
 159 #
 160 set_daemon_nonoption_properties()
 161 {
 162         OPTIND=1
 163         # Skip options
 164         while getopts $3 opt $2; do
 165                 case $opt in
 166                         ? )
 167                 esac
 168         done
 169         pos=$OPTIND
 170         for prop in $4
 171         do
 172                 val=`/usr/bin/echo $2 | /usr/xpg4/bin/awk -v POS=$pos \
 173                     '{ print $POS }'`
 174                 if [ -z "$val" ]; then
 175                         val="$5"
 176                 fi
 177                 set_routeadm_property $1 $prop $val
 178                 pos=`expr $pos + 1`
 179         done
 180 }
 181 
 182 #
 183 # get_daemon_args $inst_fmri
 184 #
 185 # Retrieves routeadm/daemon-args property values, if any.  Removes
 186 # quotes around values including spaces.
 187 #
 188 get_daemon_args()
 189 {
 190         args=`/usr/sbin/svccfg -s $1 listprop routeadm/daemon-args | \
 191             /usr/xpg4/bin/awk '{ for (i = 3; i <= NF; i++) printf "%s ", $i }' | \
 192             /usr/xpg4/bin/awk '{sub(/^\"/, ""); sub(/\"[ \t]*$/,""); print}'`
 193         echo "$args"
 194 }
 195 
 196 #
 197 # clear_daemon_args $inst_fmri
 198 #
 199 # Blanks routeadm/daemon-args property used in upgrade.
 200 #
 201 clear_daemon_args()
 202 {
 203         /usr/sbin/svccfg -s $1 delprop routeadm/daemon-args 2>/dev/null
 204 }
 205 
 206 #
 207 # The functions below are used to map back from property settings to
 208 # commandline arguments to launch daemons.
 209 #
 210 
 211 get_routeadm_property()
 212 {
 213         propval=`/sbin/routeadm -l $1 | /usr/xpg4/bin/awk -v PROP=$2 \
 214             '($1 == PROP) { for (i = 3; i < NF; i++) printf $i" "; \
 215             if (NF >= 3) {printf $NF}}'`
 216         echo "$propval"
 217 }
 218 
 219 #
 220 # get_daemon_option_from_boolean_property inst_fmri prop option value_set
 221 #
 222 # Returns appropriate daemon option for boolean property prop - if current
 223 # value matches value_set.
 224 #
 225 get_daemon_option_from_boolean_property()
 226 {
 227         propval=`get_routeadm_property $1 $2`
 228         if [ "$propval" = "$4" ]; then
 229                 echo "${3}"
 230         fi
 231 }
 232 
 233 #


 238 #
 239 get_daemon_option_from_property()
 240 {
 241         propval=`get_routeadm_property $1 $2`
 242         if [ "$propval" != "$4" ]; then
 243                 echo "-${3} $propval"
 244         fi
 245 }
 246 
 247 #
 248 # get_daemon_ordered_multivalue_option_from_property inst_fmri prop
 249 # option
 250 #
 251 # Returns appropriate daemon option and associated values. Values are
 252 # unquoted, i.e. -A value1 -A value2
 253 #
 254 get_daemon_ordered_multivalue_option_from_property()
 255 {
 256         # get property values, removing trailing delimiter.
 257         propvals=`get_routeadm_property $1 $2 | \
 258             /usr/xpg4/bin/awk '{sub(/;[ \t]*$/, ""); print }'`
 259         # Substitute switch for internal delimiters.
 260         fixed_propvals=`/usr/bin/echo $propvals | \
 261             /usr/xpg4/bin/awk -v SWITCH=" -${3} " \
 262             '{sub(/;/, SWITCH); print }'`
 263         if [ -n "$fixed_propvals" ]; then
 264                 echo "-${3} $fixed_propvals"
 265         fi
 266 }
 267 
 268 #
 269 # get_nonoption_property inst_fmri prop ignore_value
 270 #
 271 # Returns appropriate non-option property (at end of option list), unless
 272 # value matches ignore value, in which case nothing is returned.
 273 #
 274 get_daemon_nonoption_property()
 275 {
 276         propval=`get_routeadm_property $1 $2`
 277         if [ -n "$propval" -a "$propval" != "$3" ]; then
 278                 echo "$propval"
 279         fi
 280 }