%{ /******************************************************************************* * Copyright (c) 2007, Perforce Software, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE * SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *******************************************************************************/ /******************************************************************************* * Config file parser for p4dctl ******************************************************************************/ #include <stdio.h> #include <string.h> #include "parsesupp.h" #include "config.h" #include "server.h" #define YYDEBUG 1 int yylex(); %} %union { int ival; char * sval; void * pval; } %type <pval> varlist %type <pval> variable %type <pval> environment %type <pval> server_def %type <pval> server_spec %type <ival> server_type %type <sval> server_name %type <pval> setting %type <pval> settinglist %type <sval> settingname %type <sval> var %type <sval> value %type <sval> word %token <sval> WORD STRING NUMBER PATH %token EXECUTE ENVIRONMENT OWNER ENABLED ARGS UMASK PRETTYNAMES PREFIX %token P4D P4P P4BROKER P4FTP P4WEB P4DTG OTHER %% config: block | config block | /* Empty config is legal */ ; block: environment { AddEnviron( $1 ); } | settinglist { AddSettings( $1 ); } | server_def ; environment: ENVIRONMENT '{' varlist '}' { $$ = $3; } ; varlist: variable { $$ = $1; } | varlist variable { $$ = AddVar( $1, $2 ); } ; server_def: server_type server_name '{' server_spec '}' { $$ = MakeServer( $2, $1, $4 ); } ; server_type: P4D { $$ = SERVER_P4D; } | P4P { $$ = SERVER_P4P; } | P4BROKER { $$ = SERVER_P4BROKER; } | P4FTP { $$ = SERVER_P4FTP; } | P4WEB { $$ = SERVER_P4WEB; } | P4DTG { $$ = SERVER_P4DTG; } | OTHER { $$ = SERVER_OTHER; } ; server_name: word ; /* * Server specs consist of one optional environment block * and a series of settings in any order */ server_spec: environment settinglist { $$ = MakeServerSpec( $2, $1 ); } | settinglist environment { $$ = MakeServerSpec( $1, $2 ); } | settinglist environment settinglist { $$ = MakeServerSpec( $1, $2 ); AddServerSettings( $$, $3 ); } | settinglist { $$ = MakeServerSpec( $1, NULL);} ; /* * Non-empty setting lists not permitted */ settinglist: setting { $$ = $1; } | settinglist setting { $$ = AddVar( $1, $2 ); } ; setting: settingname '=' value { $$ = MakeVar( $1, $3); } | settingname value { yyerror( "Missing '='" ); } | word { char e[256]; snprintf( e, 256, "Unknown setting: %s", $1); yyerror( e ); } ; settingname: EXECUTE { $$ = strdup("Execute"); } | OWNER { $$ = strdup("Owner"); } | ENABLED { $$ = strdup("Enabled"); } | ARGS { $$ = strdup("Args"); } | UMASK { $$ = strdup("Umask"); } | PREFIX { $$ = strdup("Prefix" ); } | PRETTYNAMES { $$ = strdup("PrettyNames"); } ; variable: var '=' value { $$ = MakeVar( $1, $3 ); } ; var: word { $$ = $1; } ; value: word | STRING | PATH | NUMBER ; word: WORD
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16543 | Matt Attaway | Update P4DCTL with code from 15.2 and reorg files | ||
//guest/perforce_software/p4dctl/src/configparse.y | |||||
#2 | 10658 | Jason Gibson |
Update P4DCTL from internal Perforce tree. Note that this change does not bring the internal Jam files and deletes the existing builds, leaving that as a future task. Changes include: ################################################################################ Added support for a -o option which allows command line arguments to be passed directly to the service being started. ################################################################################ Support for P4DTG in P4DCTL. Example config: p4dtg test { Execute = /usr/local/share/p4dtg-2010.2.452775/p4dtg-repl Owner = perforce Environment { P4DTGROOT = /p4/dtg P4DTGMAPPING = local } } ################################################################################ Move p4dctl's default configuration file (and the only one that is considered safe to use) to '/etc/perforce/p4dctl.conf', and also move the directory that gets included by default to '/etc/perforce/p4dctl.conf.d'. ################################################################################ Make p4dctl provide LANG and LC_ALL environment variables to child processes. These both default to 'C'. They can be overridden in either global or server-specific environment blocks, but given that 2014.2 relies on LANG, it's better if that is set than missing. ################################################################################ Make p4dctl status exit with a code of 1 if any of the servers that it attempts to check are not running. For automation support ################################################################################ Change syntax of p4dctl config files so as to more clearly differentiate between 'settings' that p4dctl understands and environment variables to be set for the child processes. The old style syntax looked like this: p4d main { Owner = perforce Execute = /usr/local/bin/p4d P4ROOT = /home/perforce/p4-main P4JOURNAL = journal P4PORT = 1666 PATH = /bin:/usr/bin:/usr/local/bin } Where the only thing that differentiated the two was a convention on the use of case. Anything p4dctl didn't understand would be set as an environment variable. Now, we're separating the environment into a dedicated block, so p4dctl can flag up early if it encounters settings it doesn't know about. The new syntax looks like this: p4d main { Owner = perforce Execute = /usr/local/bin/p4d Environment { P4ROOT = /home/perforce/p4-main P4JOURNAL = journal P4PORT = 1666 PATH = /bin:/usr/bin:/usr/local/bin } } ################################################################################ A new command in p4dctl that allows you to query the environment for any configured server. For example: list all p4d's with their Name, port and root: $ p4dctl env -a -t p4d Name P4PORT P4ROOT Name=p4d-master P4PORT=ssl:1666 P4ROOT=/var/lib/perforce/p4d-master Find the P4ROOT of a known Perforce server and set P4ROOT in your environment: $ eval `p4dctl env -t p4d p4d-master P4ROOT` ################################################################################ Manpages for p4dctl and its config file. ################################################################################ Add 'list' command to p4dctl. Lists configured servers visible to the current user. Lists useful information about all the standard Perforce Server types. |
||
#1 | 8907 | Matt Attaway |
Branch Tony Smith's p4dctl tool into perforce_software area p4dctl is a tool that helps admins to manage multiple Perforce servers. This tool is used by the Perforce Linux packages to help manage servers. |
||
//guest/tony_smith/perforce/p4dctl/src/configparse.y | |||||
#5 | 8326 | Tony Smith |
Some significant updates to p4dctl. 1. Support for interacting with SSL enabled servers 2. New command 'list' to list configured servers p4dctl [ options ] list [ -t type ] -a p4dctl [ options ] list [ -t type ] servername 3. New command 'env' to allow you to fetch arbitrary settings from a configured server in a form suitable for use with 'eval'. p4dctl [ options ] env [ -t type ] -a var [ var... ] p4dctl [ options ] env [ -t type ] servername var [ var... ] 4. Supply a new manpage for p4dctl |
||
#4 | 7581 | Tony Smith |
Clean up use of yytext, which was incorrect and causes problems with some breeds of yacc. yytext is for the lexer, yylval for the parser, and the twain shall only meet in the lexer code. Thus configlex.l ensures that yytext is strdup'd into yylval.sval before we hand it over to the parser. Fix for bug reported by Mark Allender |
||
#3 | 7179 | Tony Smith |
Fix bug introduced in previous change. In my attempt to sort out the declaration of yytext, I declared it as an array rather than a pointer, and that could cause crashes. I also added support for debugging the parser in the course of fixing this and that's a useful thing to have anyway. Updated linux26x86 binary |
||
#2 | 7177 | Tony Smith |
Update p4dctl to build with 2008.2 API. No major changes needed, mostly jam stuff. The big change is to include all the rules from the sample Jamrules included in the Perforce API since that's the Jamrules used to build the API. This ensures that we're using the right compiler/linker flags on every platform. I also made sure that when lex & yacc are installed, and the grammar is compiled as part of the build, that the source tree is updated with the pre-compiled grammar. Makes it easy to maintain. Lastly, I updated the binary while I was there. |
||
#1 | 5945 | Tony Smith |
Release p4dctl, a program for starting/stopping Perforce services on Unix operating systems. Similar to, and developed in concert with, Sven Erik Knop's p4dcfg. For example: p4dctl start -a Can start multiple P4D, P4P, P4Web, or P4FTP servers in one easy command line. It can be executed by root, or by the 'owners' of the configured services and it maintains pidfiles no matter who uses it (so they remain accurate). An init script using p4dctl will typically just use: p4dctl start -a p4dctl stop -a p4dctl restart -a And check the exit status. |