Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / switch_rgy
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         switch_rgy
5 # Description:  A script to switch the registry host from one machine to
6 #               another.
7 # Author:       Andrew DeFaria, California Language Labs
8 # Created:      Wed Jan 15 16:52:22 PST 1997
9 # Modified:     Wed Jan 15 16:52:22 PST 1997 (Andrew DeFaria) defaria@cup.hp.com
10 # Language:     Korn Shell
11 #
12 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
13 #
14 ################################################################################
15 me=$(basename $0)
16
17 function usage {
18   print "Usage: $me: <new ClearCase Registry Server>"
19   exit 1
20 } # usage
21
22 if [ $(id -u) -ne 0 ]; then
23   print -u2 "$me: Error: Must be root to execute this command!"
24   usage
25 fi
26
27 # Get parameters
28 if [ $# -ne 1 ]; then
29   usage;
30 else
31   new_registry_server="$1"
32 fi
33
34 registry_host_file=/usr/adm/atria/rgy/rgy_hosts.conf
35
36 if [ -f $registry_host_file ]; then
37   old_registry_server=$(cat $registry_host_file)
38   if [ "$old_registry_server" = "$new_registry_server" ]; then
39     print -u2 "$me: The registry server is already $new_registry_server"
40     print -u2 "$me: Nothing changed!"
41     exit
42   fi
43   cp $registry_host_file $registry_host_file.old
44   print $new_registry_server > $registry_host_file
45   print "$me: Switched registry server from $old_registry_server \c"
46   print "to $new_registry_server."
47   print "$me: Saved old registry setting in $registry_host_file.old"
48 fi