[BACK]Return to install.sxxu CVS log [TXT][DIR] Up to [local] / openbsd / sxxu

Annotation of openbsd/sxxu/install.sxxu, Revision 1.7

1.6       andrew      1: #!/bin/ksh -
1.4       andrew      2: # $Id$
                      3:
                      4: # Copyright (c) 2010 Andrew Fresh <andrew@afresh1.com>
                      5: #
                      6: # Permission to use, copy, modify, and distribute this software for any
                      7: # purpose with or without fee is hereby granted, provided that the above
                      8: # copyright notice and this permission notice appear in all copies.
                      9: #
                     10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17: #
                     18: # based on (and some parts taken from) siteXXtools/install.site
                     19: # Copyright (c) 2006 Alex Holst <a@mongers.org>
                     20:
1.6       andrew     21: BASEDIR=/var/siteXX
                     22: user_add_args="-m -gid =uid"
                     23: [ -e /var/siteXX/siteXXrc ] && . /var/siteXX/siteXXrc
                     24:
                     25: export PKG_PATH
                     26:
                     27: do_pre() {
                     28:     # nothing to do
                     29: }
                     30:
                     31: do_post() {
                     32:     # nothing to do
                     33: }
                     34:
                     35: process_roles() {
                     36:     local _oldpwd="${PWD}"
                     37:
                     38:     cd "${BASEDIR}"
                     39:     if [ ! -e roles ]; then
                     40:         echo 'No roles defined.'
                     41:         exit
                     42:     fi
                     43:
                     44:     local _roles
                     45:     set -A _roles
                     46:     local _role
                     47:     while read _role; do
                     48:         _roles[${#_roles[@]}]="$_role"
                     49:     done < roles
                     50:
                     51:     for _role in "${_roles[@]}"; do
                     52:         apply_role "$_role"
                     53:     done
1.4       andrew     54:
1.6       andrew     55:     cd "${_oldpwd}"
                     56: }
1.4       andrew     57:
1.6       andrew     58:
                     59: append_pkg_path() {
                     60:     [ ! -e pkg_path ] && return
                     61:
                     62:     echo ' ==> Setting PKG_PATH'
1.4       andrew     63:     local _line
                     64:     while read _line; do
1.6       andrew     65:         if [ -z "${PKG_PATH}" ]; then
                     66:             PKG_PATH="$_line"
                     67:         else
                     68:             PKG_PATH="${PKG_PATH}:${_line}"
                     69:         fi
                     70:     done < pkg_path
                     71: }
                     72:
                     73: run_command_lists() {
                     74:     local _f
                     75:     for _f in *_list; do
                     76:         [ ! -f "${_f}" ] && continue
                     77:
                     78:         local _cmd=`basename "${_f%_list}"`
                     79:         local _args=`eval echo \\${${_cmd}_args}`
                     80:
                     81:         echo " ==> Running $_cmd $_args"
                     82:         local _line
                     83:         while read _line; do
                     84:             echo "  => ${_line}"
                     85:             eval ${_cmd} ${_args} ${_line}
                     86:         done < ${_f}
                     87:     done
                     88: }
                     89:
                     90: apply_patches() {
                     91:     [ ! -d patches ] && return
                     92:
                     93:     echo ' ==> Applying patches'
                     94:     local _p
                     95:     for _p in /patches/*; do
                     96:         echo "  => $_p"
                     97:         # -N Always assume a forward patch.
                     98:         # -t Never prompt; assume the user is expert
                     99:         # -p0 full path, always
                    100:         patch -N -t -p0 < $_p
                    101:     done
                    102: }
                    103:
                    104: install_packages() {
                    105:     [ ! -d packages ] && return
                    106:
                    107:     echo ' ==> Installing packages'
                    108:     find packages -name '*.tgz' -print0 | xargs -0 pkg_add ${pkg_add_args}
                    109: }
                    110:
                    111: apply_role() {
                    112:     local _role="$1"
                    113:
                    114:     if [ ! -d "${_role}" ]; then
                    115:         echo "===> Missing ${_role}"
                    116:         return
                    117:     fi
                    118:
                    119:     echo "===> Applying ${_role}"
                    120:
                    121:     local _oldpwd="${PWD}"
                    122:     cd "${_role}"
                    123:
                    124:     if [ -e siteXXrc ]; then
                    125:         echo ' ==> Including siteXXrc'
                    126:         . siteXXrc
                    127:     fi
                    128:
                    129:     append_pkg_path
                    130:     run_command_lists
                    131:     apply_patches
                    132:     install_packages
                    133:
                    134:     if [ -e install.site ]; then
                    135:         if [ -x install.site ]; then
                    136:             echo ' ==> Running install.site'
                    137:             ./install.site
                    138:         else
                    139:             echo ' ==> Including install.site'
                    140:             . install.site
                    141:         fi
                    142:     fi
                    143:
                    144:     cd "${_oldpwd}"
                    145: }
                    146:
                    147:
                    148: if [ ! -d "${BASEDIR}" ]; then
                    149:     echo Nothing to do.
                    150:     exit
                    151: fi
                    152:
                    153: do_pre
                    154: process_roles
                    155: do_post

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>