home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
plugins
/
apache
/
init.tcl
< prev
next >
Wrap
Text File
|
2000-11-02
|
11KB
|
312 lines
set currentDir [file dirname [file join [pwd] [info script]]]
mesg::processMesgCatalogDir [file join $currentDir messages]
#source [file join $currentDir specialCases.tcl]
source [file join $currentDir apache.tcl]
source [file join $currentDir apacheModuleManager.tcl]
source [file join $currentDir moduleManagement.tcl]
source [file join $currentDir apacheParser.tcl]
source [file join $currentDir apacheParserUtils.tcl]
#source [file join $currentDir dumper.tcl]
source [file join $currentDir apacheDumper.tcl]
#source [file join $currentDir prettyDumper.tcl]
source [file join $currentDir setup/apacheInstallDialog.tcl]
source [file join $currentDir setup/apacheInstallConfig.tcl]
namespace eval ::apacheplugin:: {
variable modules
variable propertypages
array set modules {}
array set propertypages {}
variable disabledModules
variable disabledModulesFile
}
# XXX This is a quick hack since it is done globally for all Apache intallations
# Change so it is per-installation
set ::apacheplugin::disabledModulesFile [file join $currentDir disabledModules.conf]
set f [open $::apacheplugin::disabledModulesFile]
set ::apacheplugin::disabledModules [read $f]
close $f
proc apache_init {args} {
array set options $args
xuiBuilder ::xuiB [list \
boolean [booleanCreator ::#auto] \
string [stringCreator ::#auto] \
structure [structureCreator ::#auto] \
alternate [alternateCreator ::#auto] \
choice [choiceCreator ::#auto] \
list [listCreator ::#auto] \
group [groupCreator ::#auto] \
propertyPage [propertyPageCreator ::#auto] \
propertyPages [propertyPagesCreator ::#auto] \
dirDefinition [dirDefinitionCreator ::#auto] \
label [labelCreator ::#auto] \
number [numberCreator ::#auto] \
]
# Read the apache plugin configuration, to figure out where the
# Apache servers to be configured are. In Windows, we can
# to do it via the registry.
set apacheConfFile [file join $options(-moduledirectory) apache.conf]
# What is going on here:
# Am I in Windows?
# Y -> Do I have any version in the registry?
# Y -> Configure them
# Is there any apache.conf file?
# Y -> continue
# N -> return
# N -> Continue
# N -> continue
# Is there any apache.conf file? If not create
# Instead of having an if-else here for Windows and Unix, it is better
# To detect the Windows Web Servers when adding servers (to allow
# configuration of servers that are not in the registry)
# Still the problem of creating a management plugIn that manages the rest
# Should we abstract this in the plugIn management?
# Not for 1.0
# For this release, we will create a function that creates plugIns
# If Windows, look into registry + apache.conf
# Apache, just apache.conf
global tcl_platform
set apacheRootNode [[::plugInUtils::getChildByClass $options(-namespace) \
root networkServices] getId]
if {$tcl_platform(platform) == "windows"} {
# Apache docs say only one version can be installed at any given time
# We consider however multiple version
package require registry
if [catch {registry keys [file nativename [file join \
HKEY_LOCAL_MACHINE SOFTWARE {Apache Group} Apache]]} \
versionNumbers] {
} else {
foreach version $versionNumbers {
set commandList {}
set httpd {}
set configurationFiles {}
set serverDescription "Windows"
set base [registry get [file nativename [file join \
HKEY_LOCAL_MACHINE SOFTWARE {Apache Group}\
Apache $version ]] ServerRoot]
set serverRoot $base
set httpd [file nativename [file join $base apache.exe]]
set configurationFiles [file nativename [file join $base \
conf httpd.conf]]
if ![file exists $configurationFiles] {
puts "Configuration file $configurationFiles \
could not be found. Server ignored"
break
}
set commented {
set commandList [list start \
\"$env(COMSPEC) /c \
[file join $currentDir windows cmd.bat] \
[file join $base apache.exe] \
-k start\" \
smallWheel]
lappend commandlist [list stop \
\"$env(COMSPEC) /c \
[file join $currentDir windows cmd.bat] \
[file join $base apache.exe] \
-k shutdown\" \
smallWheel]
lappend commandlist [list restart \
\"$env(COMSPEC) /c \
[file join $currentDir windows cmd.bat] \
[file join $base apache.exe] \
-k restart\" \
smallWheel]
}
set commandList [list \
[list start [file join $base apache.exe] smallWheel] \
[list stop "[file join $base \
apache.exe] -k shutdown" smallWheel] \
[list restart "[file join $base \
apache.exe] -k restart" smallWheel] \
]
apache_create_plugin -commandList $commandList \
-serverRoot $serverRoot \
-configurationFiles $configurationFiles \
-httpd $httpd -serverDescription $serverDescription\
-moduledirectory $options(-moduledirectory)\
-namespace $options(-namespace) -rootNode $apacheRootNode
}
# If version in registry and no apache.conf file, we are done
# If version in registry and there is a apacheConf, do it
if ![file exists $apacheConfFile] { return }
}
}
if ![file exists $apacheConfFile] {
# First time, we ought to create a new one
# XXX
global apacheIDInstance
set apacheIDInstance [ apacheInstallConfig ::#auto \
[file join $options(-moduledirectory) \
setup propertyPage.xml] [file join $options(-moduledirectory) \
apache.conf ]]
if {[$apacheIDInstance configure] == -1} {
# No hosts configured
return
}
}
if [catch { set f [open $apacheConfFile]}] {
# If problem reading apache.conf file, just ignore it
return
}
set apacheConf [dom::DOMImplementation parse [read $f]]
close $f
set servers [dom::getElements [dom::getElements $apacheConf]]
foreach serverElement $servers {
set commandList {}
set httpd {}
set configurationfiles {}
set serverRoot {}
set serverDescription [dom::getAttribute $serverElement name]
foreach infoElement [dom::getElements $serverElement] {
switch [dom::getTagName $infoElement] {
command {
lappend commandList [list \
[dom::getAttribute $infoElement name] \
[dom::getText $infoElement] \
[dom::getAttribute $infoElement icon]]
} httpd {
set httpd [dom::getText $infoElement]
} configurationFiles {
set configurationFiles [dom::getText $infoElement]
} serverRoot {
set serverRoot [dom::getText $infoElement]
}
}
}
if ![file exists $configurationFiles] {
puts "Configuration file $configurationFiles could not be found. \
Server ignored"
break
}
if ![file exists $serverRoot] {
puts "directory $serverRoot could not be found. \
Server ignored"
break
}
# Apache module manager
apache_create_plugin -commandList $commandList \
-serverRoot $serverRoot \
-configurationFiles $configurationFiles \
-httpd $httpd -serverDescription $serverDescription\
-moduledirectory $options(-moduledirectory)\
-namespace $options(-namespace) -rootNode $apacheRootNode
}
}
proc apache_info {} {
array set info [list description [mesg::get apache_description]]
array set info {name {apache}}
array set info {version {1.0}}
array set info {icon apache}
return [array get info]
}
proc apache_create_plugin {args} {
# We are going to create plugins for different Apache installations
# To speed up the process, we can share some information between plugins,
# specially if they belong to the same Apache version, etc.
# If the location of the module definition is the same, it is safe to assume
# they are the same version
# There are some problems, by now do not share
# We can reuse:
# directiveDefinition
# ppDefinition
# parser
# dumper
#
# Cannot reuse:
# confDoc
array set options $args
set confDoc [confDocument ::#auto]
set dirDef [dirDefinition ::#auto ]
xuiB addCreator directiveInclude \
[includeCreator ::#auto $dirDef]
set ppdef [pPDefinition ::#auto ]
set ppM [ppManager ::#auto ]
set myPg [apachePlugIn ::#auto ]
set nm [nodeManagement ::#auto $options(-namespace) $myPg]
set apModuleManager [apacheModuleManager ::#auto]
$myPg configure -serverDescription $options(-serverDescription) \
-rootNode $options(-rootNode)
foreach command $options(-commandList) {
foreach {name execCommand icon} $command break;
$myPg addNewManagementCommand $name $execCommand $icon
}
$myPg configure -httpd $options(-httpd)
$myPg configure -configurationFiles $options(-configurationFiles)
$myPg configure -serverRoot $options(-serverRoot)
set ap [apacheParser ::#auto $dirDef $confDoc]
$ap configure -moduleManager $apModuleManager
set apacheDump [apachePrettyDumper ::#auto]
$apacheDump configure -moduleManager $apModuleManager
#set apacheDump [apacheDumper ::#auto]
foreach module [glob [file join $options(-moduledirectory) modules *]] {
# TO-DO replace this to see if moduleDescription exists
# catch is for Raven, CVS
splash::add "Loading Apache module [file tail $module]"
catch { mesg::processMesgCatalogDir [file join $module messages] }
#puts $kk
catch { addModule [file join $module moduleDescription.xml] \
$dirDef $ppdef $apModuleManager $ap $apacheDump } kk
#puts "$module $kk"
foreach module $::apacheplugin::disabledModules {
$apModuleManager disableModule $module
}
}
$ap configure -mainConfFile $options(-configurationFiles)
$ap configure -includeroot $options(-serverRoot)
if [catch {$ap init} kk] {
MessageDlg .d -message "Error parsing config file.\n$kk" -title Error -type ok -icon error
exit
}
$myPg configure -moduleManager $apModuleManager
$myPg configure -namespace $options(-namespace) -nodeManagement $nm \
-confDoc $confDoc -ppManager $ppM -ppDef $ppdef \
-dumper $apacheDump
$myPg _registerWithNamespace
$myPg init
}