"Fossies" - the Fresh Open Source Software Archive

Member "shorewall6-5.2.8/configure" (24 Sep 2020, 5430 Bytes) of package /linux/misc/shorewall/shorewall6-5.2.8.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure": 5.2.7_vs_5.2.8.

    1 #!/bin/bash
    2 #
    3 #     Shorewall Packet Filtering Firewall configuration program - V5.2
    4 #
    5 #     (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
    6 #
    7 #   Shorewall documentation is available at https://shorewall.org
    8 #
    9 #       This program is part of Shorewall.
   10 #
   11 #   This program is free software; you can redistribute it and/or modify
   12 #   it under the terms of the GNU General Public License as published by the
   13 #       Free Software Foundation, either version 2 of the license or, at your
   14 #       option, any later version.
   15 #
   16 #   This program is distributed in the hope that it will be useful,
   17 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   18 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   19 #   GNU General Public License for more details.
   20 #
   21 #   You should have received a copy of the GNU General Public License
   22 #   along with this program; if not, see <http://www.gnu.org/licenses/>.
   23 #
   24 #       Usage: ./configure [ <option>=<setting> ] ...
   25 #
   26 #
   27 ################################################################################################
   28 #
   29 # Build updates this
   30 #
   31 VERSION=5.2.8
   32 
   33 case "$BASH_VERSION" in
   34     [4-9].*)
   35     ;;
   36     *)
   37     echo "ERROR: This program requires Bash 4.0 or later" >&2
   38     exit 1
   39     ;;
   40 esac
   41 
   42 declare -A params
   43 declare -A options
   44 
   45 getfileparams() {
   46     while read option; do
   47     case $option in
   48         \#*)
   49         ;;
   50         *)
   51         on=${option%=*}
   52         ov=${option#*=}
   53         ov=${ov%#*}
   54         [ -n "$on" ] && options[${on}]="${ov}"
   55         ;;
   56     esac
   57 
   58     done
   59 
   60     return 0
   61 }
   62 
   63 for p in $@; do
   64 
   65     if [ -n "${p}" ]; then
   66     declare -u pn
   67 
   68     pn=${p%=*}
   69     pn=${pn#--}
   70     pv=${p#*=}
   71 
   72     if [ -n "${pn}" ]; then
   73 
   74         case ${pn} in
   75         VENDOR)
   76             pn=HOST
   77             ;;
   78         SHAREDSTATEDIR)
   79             pn=VARLIB
   80             ;;
   81         DATADIR)
   82             pn=SHAREDIR
   83             ;;
   84         esac
   85 
   86         params[${pn}]="${pv}"
   87     else
   88         echo "ERROR: Invalid option ($p)" >&2
   89         exit 1
   90     fi
   91     fi
   92 done
   93 
   94 cd $(dirname $0)
   95 
   96 vendor=${params[HOST]}
   97 
   98 if [ -z "$vendor" ]; then
   99     if [ -f /etc/os-release ]; then
  100     eval $(cat /etc/os-release | grep ^ID=)
  101 
  102     case $ID in
  103         fedora|rhel)
  104         vendor=redhat
  105         ;;
  106         debian|ubuntu)
  107         vendor=debian
  108         ;;
  109         opensuse)
  110         vendor=suse
  111         ;;
  112         alt|basealt|altlinux)
  113         vendor=alt
  114         ;;
  115         *)
  116         vendor="$ID"
  117         ;;
  118     esac
  119 
  120     params[HOST]="$vendor"
  121     fi
  122 fi
  123 
  124 if [ -z "$vendor" ]; then
  125     case `uname` in
  126     Darwin)
  127         params[HOST]=apple
  128         rcfile=shorewallrc.apple
  129         ;;
  130     cygwin*|CYGWIN*)
  131         params[HOST]=cygwin
  132         rcfile=shorewallrc.cygwin
  133         ;;
  134     *)
  135         if [ -f /etc/debian_version ]; then
  136         params[HOST]=debian
  137         ls -l /sbin/init | fgrep -q systemd &&  rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
  138         elif [ -f /etc/altlinux-release ] ; then
  139         params[HOST]=alt
  140         elif [ -f /etc/redhat-release ]; then
  141         params[HOST]=redhat
  142         rcfile=shorewallrc.redhat
  143         elif [ -f /etc/slackware-version ] ; then
  144         params[HOST]=slackware
  145         rcfile=shorewallrc.slackware
  146         elif [ -f /etc/SuSE-release ]; then
  147         params[HOST]=suse
  148         rcfile=shorewallrc.suse
  149         elif [ -f /etc/arch-release ] ; then
  150         params[HOST]=archlinux
  151         rcfile=shorewallrc.archlinux
  152         elif [ -f /etc/openwrt_release ]; then
  153         params[HOST]=openwrt
  154         rcfile=shorewallrc.openwrt
  155         else
  156         params[HOST]=linux
  157         rcfile=shorewallrc.default
  158         fi
  159         ;;
  160     esac
  161     vendor=${params[HOST]}
  162 else
  163     if [ $vendor = linux ]; then
  164     rcfile=shorewallrc.default;
  165     elif [ $vendor = debian -a -f /etc/debian_version ]; then
  166     ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
  167     else
  168     rcfile=shorewallrc.$vendor
  169     fi
  170 
  171     if [ ! -f $rcfile ]; then
  172     echo "ERROR: $vendor is not a recognized host type" >&2
  173     exit 1
  174     elif [ $vendor = default ]; then
  175     params[HOST]=linux
  176     vendor=linux
  177     elif [[ $vendor == debian.* ]]; then
  178     params[HOST]=debian
  179     vendor=debian
  180     fi
  181 fi
  182 
  183 if [ $vendor = linux ]; then
  184     echo "INFO: Creating a generic Linux installation - " `date`;
  185 else
  186     echo "INFO: Creating a ${params[HOST]}-specific installation - " `date`;
  187 fi
  188 
  189 echo
  190 
  191 getfileparams < $rcfile || exit 1
  192 
  193 for p in ${!params[@]}; do
  194     options[${p}]="${params[${p}]}"
  195 done
  196 
  197 echo '#'                                                                 > shorewallrc
  198 echo "# Created by Shorewall Core version $VERSION configure - " `date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}"` >> shorewallrc
  199 echo "# rc file: $rcfile"                                               >> shorewallrc
  200 echo '#'                                                                >> shorewallrc
  201 
  202 if [ $# -gt 0 ]; then
  203     echo "# Input: $@" >> shorewallrc
  204     echo '#'           >> shorewallrc
  205 fi
  206 
  207 if [ -n "${options[VARLIB]}" ]; then
  208     if [ -z "${options[VARDIR]}" ]; then
  209     options[VARDIR]='${VARLIB}/${PRODUCT}'
  210     fi
  211 elif [ -n "${options[VARDIR]}" ]; then
  212     if [ -z "{$options[VARLIB]}" ]; then
  213     options[VARLIB]=${options[VARDIR]}
  214     options[VARDIR]='${VARLIB}/${PRODUCT}'
  215     fi
  216 fi
  217 
  218 if [ -z "${options[SERVICEDIR]}" ]; then
  219     options[SERVICEDIR]="${options[SYSTEMD]}"
  220 fi
  221 
  222 for on in \
  223     HOST \
  224     PREFIX \
  225     SHAREDIR \
  226     LIBEXECDIR \
  227     PERLLIBDIR \
  228     CONFDIR \
  229     SBINDIR \
  230     MANDIR \
  231     INITDIR \
  232     INITSOURCE \
  233     INITFILE \
  234     AUXINITSOURCE \
  235     AUXINITFILE \
  236     SERVICEDIR \
  237     SERVICEFILE \
  238     SYSCONFFILE \
  239     SYSCONFDIR \
  240     SPARSE \
  241     ANNOTATED \
  242     VARLIB \
  243     VARDIR \
  244     DEFAULT_PAGER
  245 do
  246     echo "$on=${options[${on}]}"
  247     echo "$on=${options[${on}]}" >> shorewallrc
  248 done