[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: initial templates list



This one time, at band camp, sean finney said:
> hey steve,
> 
> On Thu, Jun 30, 2005 at 01:38:11AM -0400, Stephen Gran wrote:
> > These look fine.  I'll let those who have an eye for grammar and the
> > like (bubulle strikes me as someone to talk to - he has a very good ear
> > for template language).
> 
> believe it or not, bubulle helped me develop the original versions of
> these questions (again, in dbconfig-common).  after things have settled
> with these templates, i'll send this to the translation lists for
> review too.

:) Glad to see you got to know him - he has been an extremely big help
in standardizing the 'look-n-feel' part of debconf questions.

> > > Template: webapps-common/httpd/select_httpd
> > 
> > Fine, although the possibilities could be preselected - ISTR some apps
> > asking if I wanted to install for apache-perl when it's not installed.
> > that seems unnecessary.  A simple test for /usr/share/doc/${pkg} before
> > filling the string should do.
> 
> what i was planning on doing was having a list of supported httpds
> internal in the code somewhere, and populating the choices at run-time
> with that.  additionally, the choices could be verified for their
> installation status and non-installed choices could be somehow
> differentiated in the list (like being preceded by a !), and/or the
> installed choices could be selected by default.

to preselect an htppd out of a list, the following should work:

HTTPDS="apache apache-ssl apache-perl apache2" # Give or take
INSTALLED_HTTPDS=''

for httpd in $HTTPDS; do 
  if [ -d "/usr/share/doc/${httpd}" ]; then
    INSTALLED_HTTPDS="$httpd $INSTALLED_HTTPDS"
  fi
done

db_set webapps-common/httpd/select_httpd "$INSTALLED_HTTPDS" || true

(totally untested, of course)

The idea is that the only thing that can be absolutely relied on as an
inidcator that a package is installed in debian is the doc/ directory.
a removed but not purged package may leave behind a directory in /etc,
trying to sort out where logs or document roots are is a mess, etc.
Since policy dictates a doc/ directory for each package (and it's uder
/usr, so it goes away when the package is removed), it's a quick and
easy test.

> > > Template: webapps-common/httpd/virtualhost_new
> > > 
> > > Template: webapps-common/httpd/virtualhost
> > > 
> > > Template: webapps-common/httpd/virtualhost_more
> > > 
> > > Template: webapps-common/httpd/site_directory
> > 
> > Can these possibly be autodetected?  Something like checking for
> > directories that look like FQDN under /srv/www and parsing httpd.conf?
> 
> it'd probably be a bit of a clunky shell script, but would certainly
> be possible.  you'd need to read httpd.conf, as well as all files and
> directories Include'd, and then grab out all the <VirtualHost></VirtualHost>
> blocks, and then from those grab all the ServerName settings... i think...
> 
> > I realize this is some work (I'm happy to hack on it in the next few
> > weeks, when I'm on enforced vacation, if you think it's a good idea).
> 
> well, i'd be a hypocrite if i were to chastise you for working on debian
> during vacation as i'm frequently guilty of the same :)  if you
> are interested in doing this, could you write a /bin/sh function
> that does what's described above (or whatever really needs to be done)?
> i could then include it with the other internal httpd functions in
> webapps common.

This is harder.

db_get webapps-common/httpd/select_httpd || true
HTTPDS_TO_BE_CONFIGURED="$RET"

split_line() {
  line=$1
  newline=`echo $line | awk '{print $2}'`
}

parse_file() {
  file=$1
  egrep -v '^[[:space:]]*(#|$)' $file | while read line; do
    case line in
      /VirtHost*)
        in_vhost=0
        ;;
      Include*)
        extra_files="split_line($line) $extra_files"
        ;;
      VirtHost*)
        in_vhost=1
      ServerName*)
        if [ "$in_vhost" = '1' ]; then
          virt_hosts="split_line($line $virt_hosts"
        fi
        ;;
      *)
        ;;
    esac
  done
}  

for httpd in $HTTPDS_TO_BE_CONFIGURED; do
  parse_file(/etc/${httpd}/httpd.conf)
done

if [ -n "extra_files" ]; then
  for include in $extra_files; do
    parse_config($include)
  done
fi

db_set webapps-common/httpd/virtualhost "$virt_hosts" || true

This seriously needs error checking, but it may give you a rough
framework to start with.  I'll see if I can do better later.  It also
doesn't support recursion (no Includes from included files are checked),
but for that you would actually have to use bash arrays, and I have
always hated them syntactically and just ran to perl when the need for a
real array reared it's head :)
-- 
 -----------------------------------------------------------------
|   ,''`.					     Stephen Gran |
|  : :' :					 sgran@debian.org |
|  `. `'			Debian user, admin, and developer |
|    `-					    http://www.debian.org |
 -----------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature


Reply to: