X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FHP%2Fbin%2Fadd_postnote;fp=clients%2FHP%2Fbin%2Fadd_postnote;h=483231e74b3fe220dc52541fa1d21d644dd52ba9;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/HP/bin/add_postnote b/clients/HP/bin/add_postnote new file mode 100644 index 0000000..483231e --- /dev/null +++ b/clients/HP/bin/add_postnote @@ -0,0 +1,182 @@ +#!/bin/ksh +################################################################################ +# +# File: add_postnote +# RCS: $Header: add_postnote,v 1.1 97/05/27 15:35:32 defaria Exp $ +# Description: This script adds a new person to the postnote addressbook +# Author: Andrew DeFaria, California Language Labs +# Created: Mon May 19 15:56:06 PDT 1997 +# Modified: +# Language: Korn Shell +# +# (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved. +# +################################################################################ +# Set me to command name +me=$(basename $0) + +# Set adm_base +adm_base=${adm_base:-$HOME/adm} + +# Set adm_fpath +adm_fpath=${adm_fpath:-$adm_base/functions} + +# Source functions +. $adm_fpath/common + +function usage { + print -u2 "Usage: $me -username -fullname " + print -u2 "\t-phone -hostname " + print -u2 "\t-displayname " + exit 1 +} # usage + +function add_to_postnote { + cd $postnote_dir + check_out_file=$postnote_addressbook + co -q -l $check_out_file + + if [ $? -ne 0 ]; then + error "Unable to checkout $check_out_file" + exit $? + fi + + trap cancel_checkout INT ERR + + print "S:$fullname = Phone: $phonenumber = +($hostname,$displayname:0,$username@cup.hp.com,F,$xterm)" >> $check_out_file + + if [ $? -ne 0 ]; then + error "Unable to add entry to $check_out_file" + exit $? + fi + + ci -u -q -m"Added $fullname" $check_out_file + if [ $? -ne 0 ]; then + error "Unable to check in $check_out_file!" + exit $? + fi + + trap INT ERR + + cd $OLDPWD +} # add_to_postnote + +function cancel_checkout { + info "Canceling checkout" + rcs -q -u $check_out_file + chmod -w $check_out_file + co -q $check_out_file + exit 1 +} # cancel_checkout + +# Find AppServer's data directory +if [ -d /net/bismol/app/data ]; then + appserver_data=/net/bismol/app/data +elif [ -d /net/hpclbis/app/data ]; then + appserver_data=/net/hpclbis/app/data +elif [ -d /nfs/bismol/app/data ]; then + appserver_data=/nfs/bismol/app/data +elif [ -d /nfs/hpclbis/app/data ]; then + appserver_data=/nfs/hpclbis/app/data +elif [ -d /nfs/hpclbis/root/app/data ]; then + appserver_data=/nfs/hpclbis/root/app/data +else + error "Internal error: Unable to ascertain appserver_data!" + exit 1 +fi + +postnote_dir=$appserver_data +postnote_addressbook=$postnote_dir/pn_addressbook +username= +fullname= +phonenumber="????" +hostname= +displayserver= +xterm= +check_out_file= + +while [ $# -ge 1 ]; do + case "$1" in + -usage) + usage + ;; + + -username) + if [ $# -le 1 ]; then + error "Username not specified!" + usage + fi + shift + username="$1" + ;; + + -fullname) + if [ $# -le 1 ]; then + error "Full name not specified!" + usage + fi + shift + fullname="$1" + ;; + -phone) + if [ $# -le 1 ]; then + error "Phone not specified!" + usage + fi + shift + phonenumber="$1" + ;; + + -hostname) + if [ $# -le 1 ]; then + error "Hostname not specified!" + usage + fi + shift + hostname="$1" + ;; + + -displayname) + if [ $# -le 1 ]; then + error "Displayname not specified!" + usage + fi + shift + displayname="$1" + ;; + + *) + error "Unknown parameter encounter: \"$1\"" + usage + ;; + esac + shift +done + +if [ "_$username" = "_" -o \ + "_$fullname" = "_" -o \ + "_$hostname" = "_" ]; then + error "Missing parameter" + usage +fi + +if [ "_$displayname" = "_" ]; then + displayname=$hostname:0.0 +elif [ "$displayname" != "$hostname" ]; then + xterm="T" +else + xterm="F" +fi + +add_to_postnote + +if [ $? -eq 0 ]; then + info "$fullname has been added to PostNote addressbook" + if [ "$xterm" = "T" ]; then + info "X Terminal Server: $hostname; X Terminal Display Name: +$displayname" + fi +else + error "Problems encountered trying to create PostNote entry for $fullname" +fi