head 1.3; access; symbols; locks; strict; comment @# @; 1.3 date 2003.07.07.15.17.21; author rse; state Exp; branches; next 1.2; 1.2 date 2003.07.07.15.16.17; author rse; state Exp; branches; next 1.1; 1.1 date 2003.07.07.15.14.29; author rse; state Exp; branches; next ; desc @@ 1.3 log @args were already shifted @ text @#!/bin/sh ## ## masterlock - CVS Master Lock Facility ## Copyright (c) 2003 Ralf S. Engelschall ## Copyright (c) 2003 The OSSP Project ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License ## as published by the Free Software Foundation; either version ## 2.0 of the License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ## USA, or contact Ralf S. Engelschall . ## if [ ".$CVSROOT" = . ]; then echo "masterlock:ERROR: \$CVSROOT not set" 1>&2 exit 1 fi cmd="$1" shift case "$cmd" in on ) # enable the master lock if [ -f $CVSROOT/CVSROOT/masterlock.active ]; then . $CVSROOT/CVSROOT/masterlock.active ( echo "cvs:masterlock:ERROR: master lock was already activated by user \"$user\" at $time" if [ ".$info" != . ]; then echo "cvs:masterlock:ERROR: with information \"$info\"" fi ) 1>&2 exit 1 fi user="$USER"; if [ ".$user" = . ]; then user="$LOGNAME" fi time="`date '+%d-%b-%Y %H:%M:%S'`" info="$1" echo "cvs:masterlock: activating master lock" 1>&2 ( echo "user=\"$user\"" echo "time=\"$time\"" echo "info=\"$info\"" ) >$CVSROOT/CVSROOT/masterlock.active ;; off ) # disable the master lock if [ -f $CVSROOT/CVSROOT/masterlock.active ]; then echo "cvs:masterlock: deactivating master lock" rm -f $CVSROOT/CVSROOT/masterlock.active else echo "cvs:masterlock: ERROR: no master lock currently activated" 1>&2 exit 1 fi ;; check ) # check the master lock if [ -f $CVSROOT/CVSROOT/masterlock.active ]; then . $CVSROOT/CVSROOT/masterlock.active ( echo "cvs:masterlock:ERROR: master lock currently activated by user \"$user\" since $time" if [ ".$info" != . ]; then echo "cvs:masterlock:ERROR: with information \"$info\"" fi ) 1>&2 exit 1 fi ;; * ) ( echo "cvs:masterlock:ERROR: invalid usage" echo "cvs:masterlock:USAGE: CVSROOT= masterlock on []" echo "cvs:masterlock:USAGE: CVSROOT= masterlock off" echo "cvs:masterlock:USAGE: CVSROOT= masterlock check" ) 1>&2 exit 1 ;; esac exit 0 @ 1.2 log @place it into CVSROOT subdir @ text @d47 1 a47 1 info="$2" @ 1.1 log @add brand-new master lock facility @ text @d33 2 a34 2 if [ -f $CVSROOT/masterlock.active ]; then . $CVSROOT/masterlock.active d52 1 a52 1 ) >$CVSROOT/masterlock.active d57 1 a57 1 if [ -f $CVSROOT/masterlock.active ]; then d59 1 a59 1 rm -f $CVSROOT/masterlock.active d68 2 a69 2 if [ -f $CVSROOT/masterlock.active ]; then . $CVSROOT/masterlock.active @