Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ././../../../../../../lib/svc/share/net_include.sh
Real path: /lib/svc/share/net_include.sh
Zurück
#!/bin/sh # # Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. # All rights reserved. # # commands CAT=/usr/bin/cat CP=/usr/bin/cp DLADM=/usr/sbin/dladm GREP=/usr/bin/grep IPADM=/usr/sbin/ipadm MV=/usr/bin/mv NAWK=/usr/bin/nawk NETBOOTINFO=/usr/lib/inet/wanboot/netbootinfo NETSTAT=/usr/bin/netstat RM=/usr/bin/rm ROUTE=/usr/sbin/route SVCADM=/usr/sbin/svcadm SVCCFG=/usr/sbin/svccfg SVCPROP=/usr/bin/svcprop ROUTING_SETUP_FMRI="svc:/network/routing-setup:default" # net_strategy # -> (_INIT_NET_IF, _INIT_NET_IF_AF, _INIT_NET_STRATEGY) # # Sets _INIT_NET_STRATEGY to the value of the current network # configuration strategy. Valid values for _INIT_NET_STRATEGY # are "none" and "dhcp". # # If _INIT_NET_STRATEGY is "none", sets _INIT_NET_IF and # _INIT_NET_IF_AF to "none". # # If _INIT_NET_STRATEGY is "dhcp", sets _INIT_NET_IF to the # "primary" dhcp interface (the interface which had an up dhcp # addr, which caused the "dhcp" strategy selection), and # _INIT_NET_IF_AF to the address family of that interface. # # The network boot strategy for a shared-stack zone is always # "none". # net_strategy () { if smf_dont_configure_ip; then _INIT_NET_STRATEGY="none" export _INIT_NET_STRATEGY _INIT_NET_IF="none" export _INIT_NET_IF _INIT_NET_IF_AF="none" export _INIT_NET_IF_AF return 0 fi set -- `/usr/sbin/netstrategy -v` if [ $? -eq 0 ]; then _INIT_NET_IF="$2" export _INIT_NET_IF _INIT_NET_STRATEGY="$3" export _INIT_NET_STRATEGY _INIT_NET_IF_AF="$4" export _INIT_NET_IF_AF else return 1 fi return 0 } # Print warnings to console warn_failed_ifs() { echo "Failed to $1 interface(s):$2" >/dev/msglog } # # shcat file # Simulates cat in sh so it doesn't need to be on the root filesystem. # shcat() { while [ $# -ge 1 ]; do while read i; do echo "$i" done < $1 shift done } net_record_err() { message=$1 err=$2 echo "$message" | smf_console if [ $err -ne 0 ]; then echo "Error code = $err" | smf_console fi } # # service_exists fmri # # returns success (0) if the service exists, 1 otherwise. # service_exists() { $SVCCFG -s $1 listpg > /dev/null 2>&1 if [ $? -eq 0 ]; then return 0; fi return 1; } # # service_is_enabled fmri # # returns success (0) if the service is enabled (permanently or # temporarily), 1 otherwise. # service_is_enabled() { # # The -c option must be specified to use the composed view # because the general/enabled property takes immediate effect. # See Example 2 in svcprop(1). # # Look at the general_ovr/enabled (if it is present) first to # determine the temporarily enabled state. # tstate=$($SVCPROP -c -p general_ovr/enabled $1 2>/dev/null) if [ $? -eq 0 ]; then [ "$tstate" = "true" ] && return 0 return 1 fi state=$($SVCPROP -c -p general/enabled $1 2>/dev/null) [ "$state" = "true" ] && return 0 return 1 } # # service_is_in_maintenance fmri # # return success (0) if the service is in maintenance state, 1 otherwise. # service_is_in_maintenance() { state=$(/usr/bin/svcs -Ho STATE $1 2>/dev/null) [ "$state" = "maintenance" ] && return 0 return 1 } # # is_valid_v4addr addr # # Returns 0 if a valid IPv4 address is given, 1 otherwise. # is_valid_v4addr() { echo $1 | /usr/xpg4/bin/awk 'NF != 1 { exit 1 } \ $1 !~ /^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}\ (25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/ \ { exit 1 }' return $? } # # is_valid_v6addr addr # # Returns 0 if a valid IPv6 address is given, 1 otherwise. # is_valid_v6addr() { echo $1 | /usr/xpg4/bin/awk 'NF != 1 { exit 1 } \ # 1:2:3:4:5:6:7:8 $1 !~ /^([a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/ && # 1:2:3::6:7:8 $1 !~ /^([a-fA-F0-9]{1,4}:){0,6}:([a-fA-F0-9]{1,4}:){0,6}\ [a-fA-F0-9]{1,4}$/ && # 1:2:3:: $1 !~ /^([a-fA-F0-9]{1,4}:){0,7}:$/ && # ::7:8 $1 !~ /^:(:[a-fA-F0-9]{1,4}){0,6}:[a-fA-F0-9]{1,4}$/ && # ::f:1.2.3.4 $1 !~ /^:(:[a-fA-F0-9]{1,4}){0,5}:\ ((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}\ (25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/ && # a:b:c:d:e:f:1.2.3.4 $1 !~ /^([a-fA-F0-9]{1,4}:){6}\ ((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}\ (25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/ \ { exit 1 }' return $? } # # is_valid_addr addr # # Returns 0 if a valid IPv4 or IPv6 address is given, 1 otherwise. # is_valid_addr() { is_valid_v4addr $1 || is_valid_v6addr $1 } # # netmask2plen netmask # # Converts a subnet mask to its CIDR prefixlen. # netmask2plen () { mask=$1 plen=0 ocnt=1 done=0 pmask=$mask while [ $ocnt -le 4 -a "$pmask" != "" ] do octet=`echo $pmask | /usr/bin/cut -f 1-1 -d '.'` ocnt=`expr $ocnt + 1` if [ $octet -lt 0 -o $octet -ge 256 ]; then echo "Failed to compute prefixlen from subnet mask." echo "$mask is not a valid subnet mask." return 1 fi if [ $done -ne 0 -a $octet -ne 0 ]; then echo "Failed to compute prefixlen from" \ "subnet mask." echo "$mask is a non-contiguous subnet mask." return 1 fi case $octet in '255' ) plen=`expr $plen + 8` ;; '0' ) ;; '254' ) plen=`expr $plen + 7` ;; '252' ) plen=`expr $plen + 6` ;; '248' ) plen=`expr $plen + 5` ;; '240' ) plen=`expr $plen + 4` ;; '224' ) plen=`expr $plen + 3` ;; '192' ) plen=`expr $plen + 2` ;; '128' ) plen=`expr $plen + 1` ;; *) echo "Failed to compute prefixlen from" \ "subnet mask." echo "$mask is a non-contiguous subnet mask." return 1 ;; esac if [ $octet -ne 255 ]; then done=1 fi tmask=`echo $pmask | /usr/bin/cut -f 2- -d '.'` if [ "$tmask" = "$pmask" ]; then pmask="" else pmask=$tmask fi done if [ "$pmask" != "" ]; then echo "Failed to compute prefixlen from subnet mask." echo "$mask is not a valid subnet mask." return 1 fi echo $plen return 0 } is_iptun () { intf=$(echo $1 | cut -f1 -d:) # Is this a persistent IP tunnel link? $DLADM show-iptun -P $intf > /dev/null 2>&1 if [ $? -eq 0 ]; then return 0 fi # Is this an implicit IP tunnel (i.e., ip.tun0) ORIGIFS="$IFS" IFS="$IFS." set -- $intf IFS="$ORIGIFS" if [ $# -eq 2 -a \( "$1" = "ip" -o "$1" = "ip6" \) ]; then # # It looks like one, but another type of link might be # using a name that looks like an implicit IP tunnel. # If dladm show-link -P finds it, then it's not an IP # tunnel. # $DLADM show-link -Pp $intf > /dev/null 2>&1 if [ $? -eq 0 ]; then return 1 else return 0 fi fi return 1 } # iscsi_is_active # # Returns zero (success) if iscsi targets are configured. 1 otherwise. # iscsi_is_active() { /usr/lib/iscsiactive 2>/dev/null if [ $? -eq 0 ]; then return 0 fi return 1 } # Some services care about whether or not they are running in the install # environment. Most notably is the identity:node service that will use # netbootinfo to obtain a hostname if running in the install environment. # The following service only exists in the install environment and # can therefore be used to identify whether or not Solaris is running # in an install environment. # is_install_environment() { /usr/bin/svcs svc:/application/manifest-locator >/dev/null 2>&1 if [ $? -eq 0 ]; then return 1 fi return 0 }