=================================================================== RCS file: /cvs/openbsd/sxxu/Attic/install.sxxu,v retrieving revision 1.16 retrieving revision 1.20 diff -u -r1.16 -r1.20 --- openbsd/sxxu/Attic/install.sxxu 2010/04/23 00:01:30 1.16 +++ openbsd/sxxu/Attic/install.sxxu 2013/04/20 22:36:26 1.20 @@ -1,5 +1,5 @@ #!/bin/ksh - -# $Id: install.sxxu,v 1.16 2010/04/22 23:01:30 andrew Exp $ +# $Id: install.sxxu,v 1.20 2013/04/20 21:36:26 andrew Exp $ # Copyright (c) 2010 Andrew Fresh # @@ -20,7 +20,7 @@ BASEDIR=/var/siteXX useradd_args="-m -gid =uid" -[ -e /var/siteXX/siteXXrc ] && . /var/siteXX/siteXXrc +[ -e $BASEDIR/siteXXrc ] && . $BASEDIR/siteXXrc export PKG_PATH @@ -32,22 +32,6 @@ echo 'See /var/log/install.log for install messages.' } -# Strip comments (and leading/trailing whitespace if IFS is set) -# from a file and spew to stdout -stripcom() { - local _file="$1" - local _line - - { - while read _line ; do - _line=${_line%%#*} # strip comments - test -z "$_line" && continue - echo $_line - done - } < $_file -} - - process_roles() { local _oldpwd="${PWD}" @@ -61,11 +45,13 @@ unset _roles set -A _roles local _role - stripcom roles | while read _role; do + while read _role; do if [ -n "${_role}" ]; then + _role=${_role%%#*} # strip comments + test -z "$_role" && continue _roles[${#_roles[@]}]="$_role" fi - done + done < roles for _role in "${_roles[@]}"; do apply_role "$_role" @@ -76,19 +62,19 @@ append_pkg_path() { - [ ! -e pkg_path ] && return + [ -e pkg_path -o -d packages ] || return echo ' ==> Setting PKG_PATH' + [ -d packages ] && PKG_PATH="${PKG_PATH}:${PWD}/packages" + [ -e pkg_path ] || return; local _line - stripcom pkg_path | while read _line; do - if [ -z "${PKG_PATH}" ]; then - PKG_PATH="$_line" - else - PKG_PATH="${PKG_PATH}:${_line}" - fi - done + while read _line; do + _line=${_line%%#*} # strip comments + [ -z "$_line" ] && continue + PKG_PATH="${PKG_PATH}:${_line}" + done < pkg_path - PKG_PATH=`eval echo $PKG_PATH` + PKG_PATH=`eval echo $PKG_PATH | sed -e 's/^:*//'` } run_command_lists() { @@ -101,10 +87,12 @@ echo " ==> Running $_cmd $_args" local _line - stripcom "${_f}" | while read _line; do + while read _line; do + _line=${_line%%#*} # strip comments + test -z "$_line" && continue echo " => ${_cmd} ${_args} ${_line}" eval ${_cmd} ${_args} ${_line} - done + done < "${_f}" done }