[Lxr-commits] CVS: lxr/scripts ContextMgr.pm, 1.2, 1.3 configure-lxr.pl, 1.11, 1.12 recreatedb.pl,
Brought to you by:
ajlittoz
From: Andre-Littoz <ajl...@us...> - 2013-01-22 16:59:55
|
Update of /cvsroot/lxr/lxr/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8775/scripts Modified Files: ContextMgr.pm configure-lxr.pl recreatedb.pl Log Message: scripts/configure-lxr.pl, recreatedb.pl, ContextMgr.pm: manage some web server context and configuration Index: ContextMgr.pm =================================================================== RCS file: /cvsroot/lxr/lxr/scripts/ContextMgr.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ContextMgr.pm 21 Jan 2013 10:49:36 -0000 1.2 +++ ContextMgr.pm 22 Jan 2013 16:59:52 -0000 1.3 @@ -49,6 +49,7 @@ &contextSave &contextTrees &contextDB + &contextServer ); # Single/multiple operation @@ -106,24 +107,80 @@ print "Delete or rename file $ctxtfile to remove lock.\n"; exit 1; } - if ($context_created != $context_version) { - print "${VTred}ERROR:${VTnorm} saved context file probably too old!\n"; + if ($context_created > $context_version) { + print "${VTyellow}WARNING:${VTnorm} saved context file created with newer version!\n"; print "Recorded state version = $context_created while expecting version = $context_version\n"; - print "It is wise to 'quit' now and add manually the new tree or reconfigure from scratch.\n"; - print "You can however try to restore the initial context at your own risk.\n"; - print "\n"; - print "${VTyellow}WARNING:${VTnorm} inconsistent answers can lead to LXR malfunction.\n"; + if ($context_version != $context_created - 1) { + print "${VTred}ERROR:${VTnorm}Contexts are too different to continue.\n"; + exit 1; + } + print "Context are maintained compatible as much as possible.\n"; + print "You may try to continue at your own risk.\n"; print "\n"; if ('q' eq get_user_choice - ( 'Do you want to quit or manually restore context?' + ( 'Do you want to quit or tentatively continue?' , 1 - , [ 'quit', 'restore' ] - , [ 'q', 'r' ] + , [ 'quit', 'continue' ] + , [ 'q', 'c' ] ) ) { exit 1; } - $reloadstatus = 1; - }; + } + if ($context_created < $context_version) { + print "${VTred}ERROR:${VTnorm} saved context file too old!\n"; + print "Recorded state version = $context_created while expecting version = $context_version\n"; + if ($context_version == $context_created + 1) { + print "It is possible to upgrade the context (without saving it),\n"; + print "but without any guarantee.\n"; + print "Note also that templates may have changed and\n"; + print "no longer be compatible with your configuration files.\n"; + print "\n"; + print "${VTyellow}WARNING:${VTnorm} inconsistent answers can lead to LXR malfunction.\n"; + print "\n"; + if ('q' eq get_user_choice + ( 'Do you want to quit or try to upgrade context?' + , 1 + , [ 'quit', 'upgrade' ] + , [ 'q', 'u' ] + ) ) { + exit 1; + } + print "\n"; + print "Previous configuration was made for:\n"; + print "- "; + if ('m' eq $cardinality) { + print "multiple trees"; + } else { + print "single tree"; + } + print "\n"; + print "- "; + if ('t' eq $dbpolicy) { + print "per tree"; + } else { + print "global"; + } + print " database\n"; + print "\n"; + contextServer (2); + print "\n"; + } else { + print "It is wise to 'quit' now and add manually the new tree or reconfigure from scratch.\n"; + print "You can however try to restore the initial context at your own risk.\n"; + print "\n"; + print "${VTyellow}WARNING:${VTnorm} inconsistent answers can lead to LXR malfunction.\n"; + print "\n"; + if ('q' eq get_user_choice + ( 'Do you want to quit or manually restore context?' + , 1 + , [ 'quit', 'restore' ] + , [ 'q', 'r' ] + ) ) { + exit 1; + } + $reloadstatus = 1; + } + } if ($dbpolicy eq 't') { print "Your DB engine was: ${VTbold}"; @@ -215,7 +272,7 @@ if ($nodbprefix) { print DEST "\$nodbprefix = 1;\n"; } else { - print DEST "\$dbprefix = '$dbprefix'\n"; + print DEST "\$dbprefix = '$dbprefix';\n"; } # Set added in version 2 print DEST "\$servertype = '$servertype';\n"; @@ -388,4 +445,120 @@ } +############################################################## +# +# Describe web server context +# +############################################################## + +sub contextServer { + my ($verbose) = @_; + + if ($verbose > 1) { + print "LXR can be configured as the default server (the only service in your computer),\n"; + print "a section of this default server or an independent server (with its own\n"; + print "host name).\n"; + print "Refer to the ${VTbold}User's Manual${VTnorm} for a description of the differences.\n"; + } + + $servertype = get_user_choice + ( 'Web server type?' + , 1 + , [ "1.default\n" + , "2.section in default\n" + , "3.indepedent\n" + , "4.section in indepedent\n" + ] + , [ 'D', 'DS', 'I', 'IS' ] + ); + if ($verbose) { + print "The computer hosting the server is described by an URL.\n"; + print "The form is scheme://host_name:port\n"; + } + if ($verbose > 1) { + print "where:\n"; + print " - scheme is either http or https (http: can be omitted),\n"; + print " - host_name can be given as an IP address such as 123.45.67.89\n"; + print " or a domain name like localhost or lxr.url.example,\n"; + print " - port may be omitted if standard for the scheme.\n"; + print "The following question asks for a primary URL. Later, you'll have\n"; + print "the opportunity to give aliases to this primary URL.\n"; + } + my $primaryhost; + while (!defined($primaryhost)) { + $primaryhost = get_user_choice + ( '--- Host name or IP?' + , ('D' eq substr($servertype, 0, 1)) ? -1 : -2 + , [ ] + , ('D' eq substr($servertype, 0, 1)) + ? [ '//localhost' ] + : [ ] + ); + $primaryhost =~ m!^(https?:)?(//[^:]+)(?::(\d+))?!; + $scheme = $1; + $hostname = $2; + $port = $3; + $scheme = undef if 'http:' eq $scheme; + $port = 80 if !defined($1) && !defined($3); + $port = 443 if 'https:' eq $1 && !defined($3); + if (!defined($hostname)) { + print "${VTred}ERROR:${VTnorm} invalid host name or scheme, try again ...\n"; + $primaryhost = undef; + next; + } + if ( 'I' eq substr($servertype, 0, 1) + && ( '//localhost' eq $hostname + || '//127.0.0.1' eq $hostname + ) + ) { + print "You are configuring for an independent web server and you named it ${hostname},\n"; + print "which is the common name for the default server\n"; + if ( 'y' eq get_user_choice + ( 'Do you want to change its name?' + , 1 + , [ 'yes', 'no' ] + , [ 'y', 'n' ] + ) + ) { + $primaryhost = undef; + } + } + } + + + $virtrootbase = ''; + if (1 < length($servertype)) { + $virtrootbase = get_user_choice + ( 'URL section name for LXR in your server?' + , -1 + , [ ] + , [ '/lxr' ] + ); + } + + if ('m' eq $cardinality) { + if (1 < $verbose) { + print "The built-in method to manage several trees with a single instance of LXR is to include\n"; + print "a designation of the tree in the URL at the end of the section name.\n"; + print "This sequence after host name is called \"virtual root\".\n"; + print "Supposing one of your trees is to be referred as \"my-tree\", an URL to list the content\n"; + print "of the default version directory would presently be:\n"; + print " ${VTyellow}${primaryhost}${virtrootbase}/${VTnorm}${VTbold}my-tree${VTyellow}/source${VTnorm}\n"; + print "with virtual root equal to ${VTyellow}${virtrootbase}/my-tree${VTnorm}\n"; + print "\n"; + } + $virtrootpolicy = 'b'; # 'b' for built-in + if ('n' eq get_user_choice + ( 'Use built-in multiple trees management with tree designation at end of virtual root?' + , 1 + , [ 'yes', 'no' ] + , [ 'y', 'n' ] + ) + ) { + $virtrootpolicy = 'c'; # 'c' for custom + } + } +} + + 1; Index: configure-lxr.pl =================================================================== RCS file: /cvsroot/lxr/lxr/scripts/configure-lxr.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- configure-lxr.pl 22 Jan 2013 11:20:25 -0000 1.11 +++ configure-lxr.pl 22 Jan 2013 16:59:52 -0000 1.12 @@ -69,6 +69,7 @@ my $confdir = 'custom.d'; my $rootdir = `pwd`; chomp($rootdir); +my ($scriptdir) = $0 =~ m!([^/]+)/[^/]+$!; my $tmpldir = 'templates'; my $verbose; my $confout; @@ -153,7 +154,7 @@ . " ${VTred}$rootdir${VTnorm} does not exist!\n"; $error = 1; } -if (! -d $rootdir.'/scripts') { +if (! -d $rootdir.'/'.$scriptdir) { print "${VTred}ERROR:${VTnorm} ${VTred}$rootdir${VTnorm} does not look " . "like an LXR root directory (scripts directory not found)!\n"; $error = 1; @@ -251,122 +252,21 @@ print "${VTyellow}***${VTnorm} ${VTred}L${VTblue}X${VTgreen}R${VTnorm} web server configuration ${VTyellow}***${VTnorm}\n"; print "\n"; } - if ($verbose > 1) { - print "LXR can be configured as the default server (the only service in your computer),\n"; - print "a section of this default server or an independent server (with its own\n"; - print "host name).\n"; - print "Refer to the ${VTbold}User's Manual${VTnorm} for a description of the differences.\n"; - } - - $servertype = get_user_choice - ( 'Web server type?' - , 1 - , [ "1.default\n" - , "2.section in default\n" - , "3.indepedent\n" - , "4.section in indepedent\n" - ] - , [ 'D', 'DS', 'I', 'IS' ] - ); - if ($verbose) { - print "The computer hosting the server is described by an URL.\n"; - print "The form is scheme://host_name:port\n"; - } - if ($verbose > 1) { - print "where:\n"; - print " - scheme is either http or https (http: can be omitted),\n"; - print " - host_name can be given as an IP address such as 123.45.67.89\n"; - print " or a domain name like localhost or lxr.url.example,\n"; - print " - port may be omitted if standard for the scheme.\n"; - print "The following question asks for a primary URL. Later, you'll have\n"; - print "the opportunity to give aliases to this primary URL.\n"; - } - my $primaryhost; - while (!defined($primaryhost)) { - $primaryhost = get_user_choice - ( '--- Host name or IP?' - , ('D' eq substr($servertype, 0, 1)) ? -1 : -2 - , [ ] - , ('D' eq substr($servertype, 0, 1)) - ? [ '//localhost' ] - : [ ] - ); - $primaryhost =~ m!^(https?:)?(//[^:]+)(?::(\d+))?!; - $scheme = $1; - $hostname = $2; - $port = $3; - $scheme = undef if 'http:' eq $scheme; - $port = 80 if !defined($1) && !defined($3); - $port = 443 if 'https:' eq $1 && !defined($3); - if (!defined($hostname)) { - print "${VTred}ERROR:${VTnorm} invalid host name or scheme, try again ...\n"; - $primaryhost = undef; - next; - } - if ( 'I' eq substr($servertype, 0, 1) - && ( '//localhost' eq $hostname - || '//127.0.0.1' eq $hostname - ) - ) { - print "You are configuring for an independent web server and you named it ${hostname},\n"; - print "which is the common name for the default server\n"; - if ( 'y' eq get_user_choice - ( 'Do you want to change its name?' - , 1 - , [ 'yes', 'no' ] - , [ 'y', 'n' ] - ) - ) { - $primaryhost = undef; - } - } - } - - - $virtrootbase = ''; - if (1 < length($servertype)) { - $virtrootbase = get_user_choice - ( 'URL section name for LXR in your server?' - , -1 - , [ ] - , [ '/lxr' ] - ); - } - - if ('m' eq $cardinality) { - if (1 < $verbose) { - print "The built-in method to manage several trees with a single instance of LXR is to include\n"; - print "a designation of the tree in the URL at the end of the section name.\n"; - print "This sequence after host name is called \"virtual root\".\n"; - print "Supposing one of your trees is to be referred as \"my-tree\", an URL to list the content\n"; - print "of the default version directory would presently be:\n"; - print " ${VTyellow}${primaryhost}${virtrootbase}/${VTnorm}${VTbold}my-tree${VTyellow}/source${VTnorm}\n"; - print "with virtual root equal to ${VTyellow}${virtrootbase}/my-tree${VTnorm}\n"; - print "\n"; - } - $virtrootpolicy = 'b'; # 'b' for built-in - if ('n' eq get_user_choice - ( 'Use built-in multiple trees management with tree designation at end of virtual root?' + contextServer ($verbose); + if ('c' == $virtrootpolicy) { + print "${VTyellow}Reminder:${VTnorm} do not forget to implement your management in the following files:\n"; + print "- ${confdir}/${VTbold}apache-lxrserver.conf${VTnorm} if using Apache,\n"; + print "- ${confdir}/${VTbold}lighttpd-lxrserver.conf${VTnorm} if using lighttpd,\n"; + print "- ${confdir}/${VTbold}${confout}${VTnorm} for parameter 'treeextract'.\n"; + print "It is wise to thoroughly read the Web server chapter in the User's Manual.\n"; + if ('s' eq get_user_choice + ( 'Continue or stop?' , 1 - , [ 'yes', 'no' ] - , [ 'y', 'n' ] + , [ 'continue', 'stop' ] + , [ 'c', 's' ] ) ) { - print "${VTyellow}Reminder:${VTnorm} do not forget to implement your management in the following files:\n"; - print "- custom.d/${VTbold}apache-lxrserver.conf${VTnorm} if using Apache,\n"; - print "- custom.d/${VTbold}lighttpd-lxrserver.conf${VTnorm} if using lighttpd,\n"; - print "- custom.d/${VTbold}${confout}${VTnorm} for parameter 'treeextract'.\n"; - print "It is wise to thoroughly read the Web server chapter in the User's Manual.\n"; - if ('s' eq get_user_choice - ( 'Continue or stop?' - , 1 - , [ 'continue', 'stop' ] - , [ 'c', 's' ] - ) - ) { - exit 0; - } - $virtrootpolicy = 'c'; # 'c' for custom + exit 0; } } } @@ -828,9 +728,10 @@ # We suppose configure-lxr.pl has correct permissions, otherwise we # can't bootstrap. chmod 0775, 'diff', 'genxref', 'ident', 'search', 'showconfig', 'source'; -chmod 0775, 'scripts/kernel-vars-grab.sh'; -chmod 0775, 'scripts/set-lxr-version.sh'; -chmod 0775, 'scripts/lighttps-init'; +chmod 0775, "${scriptdir}/kernel-vars-grab.sh"; +chmod 0775, "${scriptdir}/set-lxr-version.sh"; +chmod 0775, "${scriptdir}/recreatedb.pl"; +chmod 0775, "${scriptdir}/lighttpd-init"; if ($verbose) { print "configuration saved in ${VTbold}$confdir/$confout${VTnorm}\n"; Index: recreatedb.pl =================================================================== RCS file: /cvsroot/lxr/lxr/scripts/recreatedb.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- recreatedb.pl 21 Jan 2013 10:49:36 -0000 1.6 +++ recreatedb.pl 22 Jan 2013 16:59:52 -0000 1.7 @@ -23,7 +23,7 @@ # $Id$ use strict; -use lib 'lib', 'scripts'; +use lib 'lib', do { $0 =~ m{(.*)/}; "$1" }; use Fcntl; use Getopt::Long; use IO::Handle; @@ -75,6 +75,7 @@ my $confdir = 'custom.d'; my $rootdir = `pwd`; chomp($rootdir); +my ($scriptdir) = $0 =~ m!([^/]+)/[^/]+$!; my $tmpldir = 'templates'; my $verbose; my $scriptout = 'initdb.sh'; @@ -161,7 +162,7 @@ . " ${VTred}$rootdir${VTnorm} does not exist!\n"; $error = 1; } -if (! -d $rootdir.'/scripts') { +if (! -d "$rootdir/$scriptdir") { print "${VTred}ERROR:${VTnorm} ${VTred}$rootdir${VTnorm} does not look " . "like an LXR root directory (scripts directory not found)!\n"; $error = 1; |