home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / etc / sysconfig / network / scripts / ifup-skel < prev    next >
Text File  |  2006-11-29  |  4KB  |  136 lines

  1. #! /bin/bash
  2. #
  3. # Copyright (c) 2002-2003 SuSE Linux AG Nuernberg, Germany.
  4. # All rights reserved.
  5. #
  6. # This program is free software; you can redistribute it and/or modify it under
  7. # the terms of the GNU General Public License as published by the Free Software
  8. # Foundation; either version 2 of the License, or (at your option) any later
  9. # version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  14. # details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. # Place, Suite 330, Boston, MA 02111-1307 USA
  19. #
  20. # Authors: Michal Svec <msvec@suse.cz>
  21. #          Christian Zoz <zoz@suse.de>
  22. #
  23. # $Id: ifup-skel 1344 2006-01-13 15:12:41Z zoz $
  24. #
  25.  
  26. # USE THIS AS A SKELETON FOR ADDITIONAL if{up,down,status}-* SCRIPTS
  27. #
  28.  
  29. usage () {
  30.     echo $@
  31.     echo "Usage: if{up,down}-..... [<config>] <hwdesc> [-o <options>]"
  32.     echo "  hwdesc may be the interface name or any valid description"
  33.     echo "  of the corresponding device, for details see ifup(8)."
  34.     echo
  35.     echo "Options are: option    : explanation"
  36.     echo "All other or wrong options are silently ignored."
  37.     echo
  38.     echo "      This is just a skeleton."
  39.     echo "  !!! PLEASE MODIFY THESE LINES !!!"
  40.     exit $R_USAGE
  41. }
  42.  
  43. ######################################################################
  44. # change the working direcory and source some common files
  45. #
  46. R_INTERNAL=1      # internal error, e.g. no config or missing scripts
  47. cd /etc/sysconfig/network || exit $R_INTERNAL
  48. test -f ./config && . ./config
  49. test -f scripts/functions && . scripts/functions || exit $R_INTERNAL
  50.  
  51. ######################################################################
  52. # check arguments and how we are called (in case of links)
  53. #
  54. SCRIPTNAME=${0##*/}
  55. debug $*
  56. ACTION=${SCRIPTNAME#if}
  57. ACTION=${ACTION%%-skel}  # <--- adapt it to the scriptname !!!!!!!!!!!
  58. case "${ACTION}" in
  59.     up|status|down|check) ;;
  60.     *) usage
  61. esac
  62. INTERFACE=$1
  63. case "$INTERFACE" in ""|-h|*help*) usage; esac
  64. shift
  65. if [ -n "$1" -a "$1" != "-o" ] ; then
  66.     CONFIG=$INTERFACE
  67.     INTERFACE=$1
  68. fi
  69. shift
  70. test "$1" = "-o" && shift
  71. OPTIONS="$@"
  72. MODE=manual
  73. while [ $# -gt 0 ]; do
  74.     case $1 in
  75.         boot|onboot) MODE=auto ;;
  76.         hotplug)     MODE=auto ;;
  77.         auto)        MODE=auto ;;
  78.         quiet)       be_quiet_has_gone ;;
  79.         debug)       DEBUG=yes ;;
  80.         *)           debug unknown option $1 ;;
  81.     esac
  82.     shift
  83. done
  84.  
  85. ######################################################################
  86. # get the interface and check if it is available or up
  87. #
  88. # If your script needs a base interface upon which the new interface resides
  89. # (e.g. for tunnels) then pay attention to the following:
  90. # Imagine you have a variable BASE_DEVICE in your configuration which you expect
  91. # to contain the interface name of the base interface. This variable may contain
  92. # any valid description of the base device and need not to be an interface name.
  93. # Moreover it is recommended to prefer an device description to the interface
  94. # name, because interface names are not always persistent the may change. See
  95. # man ifup for valid device descriptions. You will get the current interface
  96. # name to this device with /sbin/getcfg-interface:
  97. #
  98. # BASE_INTERFACE=`/sbin/getcfg-interface -- $BASE_DEVICE`
  99. #
  100. # if ! is_iface_available  $INTERFACE ; then
  101. #     logerror "interface ${INTERFACE} is not available"
  102. #     exit $R_NODEV
  103. # fi
  104. # if ! is_iface_up $INTERFACE ; then
  105. #     logerror "interface ${INTERFACE} is not up"
  106. #     exit $R_NOTRUNNING
  107. # fi
  108.  
  109. ######################################################################
  110. # check presence of configuration file and source it
  111. #
  112. if [ -f ifcfg-$CONFIG ] ; then
  113.     . ifcfg-$CONFIG
  114. else
  115.     message "could not find configuration file ifcfg-$CONFIG"
  116. fi
  117.  
  118. ######################################################################
  119. # now do what has to be done
  120. #
  121. case $ACTION in
  122.     up)
  123.         : do ifup job
  124.         ;;
  125.     down)
  126.         : do ifdown job
  127.         ;;
  128.     status)
  129.         : do status job
  130.         ;;
  131.     check)
  132.         : do check job
  133.         ;;
  134. esac
  135.