#!/bin/sh # Copyright (c) 1996, by Sun Microsystems, Inc. # #pragma ident "@(#)ab2cd 1.47 99/06/08 SMI" # # Dependency: # AB2 Document # document has to live under a directory call common. # It will be best (faster) to live under /cdrom/*/*/common/Product # If the common directory is not on the second level, find is used # to look for common directory from /cdrom on. # # AnswerBook2 Server # SUNWab2{r,s,u} can live anywhere after cd mount point. # However is is best (faster) to live in /cdrom/*/*/ARC/Product, # where cdrom is the mount point; # * can be any name; # ARC = sparc or i386. # If the packages live somewhere else, it will find SUNWab2u from # /cdrom on (which may take long time). # # Usage: # ab2cd [-v] [start] [-s] [-d path-to-cd-mount-point] [-p port] # ab2cd stop # # ab2cd (by itself) # run the server from CD assuming /cdrom is the mount point for # AnswerBook2 product # # options # -s scan for locally installed collections and update the database # for the server running from CD # -d specify cd mount point (default /cdrom) # -p specify a port run run on (default 8888) # # ab2cd -v # display ab2cd version # # ab2cd stop # kill the server running from CD and clean up the tmp space # # # Task # error -- command syntax error # start -- start server # stop -- stop server # bad_path -- an invalid path was specified # bad_port -- port out of range # Routine for handling the error condition caused by calling a function # if the return status of a function is >= 2 # then report the error and exit # # Note that function return value of 1 is not an error condition # handle_error() { # save status of the function call if [ $1 -ge 2 ] then msg_fail="`gettext 'ab2cd failed (Error code %s).'`" msg_warning="`gettext 'ab2cd encounters minor problem (Error code %s).'`" case $1 in 2) # Standard Unix command is not available printf "\n${msg_fail}\n" "$1" exit ;; 3) # Can not obtain process id of AnswerBook2 server printf "\n${msg_fail}\n" "$1" exit ;; 4) # AnswerBook2 server software not found at path printf "\n${msg_fail}\n" "$1" msg="`gettext 'AnswerBook2 server software not found at path %s.'`" printf "\n${msg}\n" $CDROOT exit ;; 5) # Architecture not supported printf "\n${msg_fail}\n" "$1" msg="`gettext 'Architecture not supported : %s'`" printf "\n${msg}\n" $ARC exit ;; 6) # Can not find AnswerBook2 document printf "\n${msg_fail}\n" "$1" ;; 7) # msg="Can not get server port number" printf "\n${msg_fail}\n" "$1" exit ;; 8) # Can not find server config path printf "\n${msg_fail}\n" "$1" exit ;; 9) # can not see package database printf "\n${msg}\n" "$1" exit ;; 10) # problem with socat creation printf "\n${msg_warning}\n" "$1" ;; 11) # problem with adding help collection printf "\n${msg_warning}\n" "$1" ;; 12) # problem with adding collection printf "\n${msg_warning}\n" "$1" ;; 13) # problem with scan function printf "\n${msg_warning}\n" "$1" ;; *) # Unknown error printf "\n${msg}\n" "$1" exit ;; esac fi } # Check if the server is running from ab2cd # # return true (0) if server is running # return 1 if not running # return > 2 if error in function # # Unit tested 2/25/99 # # is_ab2cd_running() { # is there a ab2cd image? if test -d $CDTMP && test -f /tmp/ab2cd_config; then # is the ab2cd server running PID=`cat ${CDTMP}/${AB2_LOG}/pid.log | /usr/bin/fgrep http | /usr/bin/awk '{print $1}'` # check to see if we get PID if [ ! -z "$PID" ] ; then ACTIVE=`/usr/bin/ps -e | /usr/bin/fgrep ${PID}` else # can not get pid # possibility: id log file does not exist # standard unix command not available # indicate error condition return 3 fi if [ -z "$ACTIVE" ] ; then # some how the server is dead # There is no AnswerBook2 server running from %s. # possibility: standard unix command not available, fgrep, ps # # indicate error condition return 2 else return 0 fi else # indicate server not running # this is not an error condition return 1 fi } # Check if any ab2 server is running # # return true (1) if ab2 server is running # return 1 if not running # is_ab2_running () { # Is there a server running other than from ab2cd? PID=`/usr/bin/ps -e | /usr/bin/fgrep dwhttpd | /usr/bin/awk '{print $1}'` if [ ! -z "$PID" ] then # Server running return 0 else # server not running return 1 fi } # get the running server config path from ps output # get_config_path() { # get the server config path from ps LINE=`/usr/bin/ps -ef | /usr/bin/grep dwhttpd | /usr/bin/grep -v grep | head -1` # ps from 2.5 and 2.6 has different output NUM_W=`echo $LINE | /usr/bin/wc -w` if (test $NUM_W = 9) then PPATH=`echo $LINE | /usr/bin/awk '{print $9}'` else if (test $NUM_W = 10) then PPATH=`echo $LINE | /usr/bin/awk '{print $10}'` fi fi if [ ! -z "$PPATH" ] then CUR_DWCFG=${PPATH}/config/dwhttpd.cfg if [ -f $CUR_DWCFG ] then return 0 else unset CUR_DWCFG return 8 fi else return 8 fi } # get the current port used by the server started from ab2cd # AB2CD_PORT hold the current port of the server running from ab2cd # get_ab2cd_port () { unset AB2CD_PORT if test -d $CDTMP && test -f /tmp/ab2cd_config ; then # get process ID PID=`cat ${CDTMP}/${AB2_LOG}/pid.log | /usr/bin/fgrep http | /usr/bin/awk '{print $1}'` ACTIVE=`/usr/bin/ps -e | /usr/bin/fgrep ${PID}` if [ ! -z "$ACTIVE" ] ; then tmp_port=`/usr/bin/grep "set ServerPort" ${CDTMP}/${DATA_CONFIG}/dwhttpd.cfg | /usr/bin/awk '{print $3}'` if [ ! -z "$tmp_port" ]; then AB2CD_PORT=${tmp_port} return 0 else AB2CD_PORT="????" return 7 fi fi fi } # get the current port used by the AB2 server # AB2_PORT hold the current port of the running server # get_port() { CUR_DWCFG=$1 if [ -f $CUR_DWCFG ] then # Looking for port number this server uses PORT=`/usr/bin/cat ${CUR_DWCFG} | /usr/bin/fgrep "set ServerPort" | /usr/bin/awk '{print $3}'` if [ -z "$PORT" ] then return 7 else CURRENT_PORT=$PORT return 0 fi fi } # function to handle the condition where server is running # handle_running_server() { # get the server configuarion file get_config_path status=$? if [ $status -eq 0 ] then # we got the server configuration file successfully # Now get the server port get_port $CUR_DWCFG status=$? if [ $status -eq 0 ] then if (test "$CURRENT_PORT" = "$NEW_PORT") then msg2="`gettext 'An AnswerBook2 server is running already on this system as %s:%s.'`" printf "\n${msg2}\n" "${HOSTNAME}" "${NEW_PORT}" msg2="`gettext 'Please shut down the current server before running the %s command.'`" printf "\n${msg2}\n" "${command}" exit 1 else msg2="`gettext 'An AnswerBook2 server is running already on this system as %s:%s.'`" printf "\n${msg2}" "${HOSTNAME}" "${CURRENT_PORT}" msg2="`gettext 'Attempt to start another server at port %s ...'`" printf "\n${msg2}\n" "${NEW_PORT}" fi else # A server already running but can not get port number msg2="`gettext 'An AnswerBook2 server is running already on this system.'`" printf "\n${msg2}\n" exit 1 fi else # problem with obtaining server configuration file msg2="`gettext 'An AnswerBook2 server is running already on this system.'`" printf "\n${msg2}\n" exit 1 fi } # This function find the location where AnswerBook2 server packages (SUNWab2u) # live on the CD layout and set CDROM to point to it # # # CDROOT should be defined # It is defaulted to /cdrom or can be specified by -d flag when running ab2cd # # return 4 if can not find AnswerBook2 # get_server_loc() { if [ -d ${CDROOT} ] then # first look into a fix location to save time if [ -d ${CDROOT}/*/*/${ARC}/Product ] then # find path to SUNWab2u, get the right architecture version # use sed to chop off /SUNWab2u CDROM=`/usr/bin/ls -d ${CDROOT}/*/*/${ARC}/Product/SUNWab2u | head -1 | sed 's/\/SUNWab2u//g'` fi # Did we find it yet? if [ -z "$CDROM" ] then # use find to locate; this can take a long time CDROM=`/usr/bin/find ${CDROOT} -name SUNWab2u | /usr/bin/grep ${ARC} | sed 's/\/SUNWab2u//g'` if [ -z "$CDROM" ] then # can not find AnswerBook2 server packages #msg="`gettext 'AnswerBook2 server software not found at path %s.'`" #printf "\n${msg}\n" "${CDROOT}" return 4 fi fi fi } # set up some fix path used in AnswerBook2 product # Change this only when AnswerBook2 product changes # predefine_path() { DATA_CONFIG=data/config DWEB=lib/ab2/dweb DWEB_DATA=$DWEB/data DWEB_LIB=$DWEB/sunos5/lib DWEB_BIN=$DWEB/sunos5/bin # AB2 libraries path AB2_LIB=lib/ab2/lib # AB2 binaries path AB2_BIN=lib/ab2/bin # AB2 help doc/icons fixed location path AB2_DOC=lib/ab2/data/docs # log file location LOG=log/ab2 AB2_LOG=$LOG/logs AB2_CATALOG=$LOG/catalog } # setting up various paths # set_up_path() { # get location to AnswerBook2 server on cd layout get_server_loc status=$? if [ $status -ne 0 ] then handle_error $status fi #### set up path #### CDLIB=${CDROM}/SUNWab2u/reloc/$DWEB_LIB # original map.txt file MAPTXT=${CDROM}/SUNWab2s/reloc # Legacy database AB1DB=$CDTMP/$AB2_CATALOG/ab1_cardcatalog # AB2 database AB2DB=$CDTMP/$DATA_CONFIG/ab2_collections.template # local socat file AB2SOCAT=$CDTMP/$AB2_CATALOG/local.socat CDDATA=$CDROM/SUNWab2u/reloc/$DWEB_DATA if [ ! -d "$CDDATA" ] then # msg2="`gettext 'AnswerBook2 server software not found at path %s.'`" # printf "\n${msg2}\n" "${CDDATA}" return 4 fi CDVAR=$CDROM/SUNWab2r/reloc/var if [ ! -d "$CDVAR" ] then # msg2="`gettext 'AnswerBook2 server software not found at path %s.'`" # printf "\n${msg2}\n" "${CDVAR}" return 4 fi # AB2 binary location AB2UsrDir=$CDROM/SUNWab2u/reloc if [ ! -d "$AB2UsrDir" ] then # msg2="`gettext 'AnswerBook2 server software not found at path %s.'`" # printf "\n${msg2}\n" "${AB2UsrDir}" return 4 fi #this dir will contain binary AB2BIN=$AB2UsrDir/$DWEB_BIN # CDROM : this dir will contain ./config AB2CFG=$CDTMP/data } # Setting up the environment variable for the server to run with. # Use before starting up the server # set_up_environment() { # DWeb wants a magic env var, EBT_REGISTRY ER=$AB2UsrDir/$DWEB_DATA/ebtcom.txt PRELOAD=$AB2UsrDir/$AB2_LIB/libfmanage.so export ER # temporary workaround for dynaweb lib's dependency on LD_LIBRARY_PATH if [ ! "$LD_LIBRARY_PATH" ] then LD_LIBP=$AB2UsrDir/$AB2_LIB:$AB2UsrDir/$DWEB_LIB:/usr/dt/lib:/usr/openwin/lib:/usr/lib else LD_LIBP=$AB2UsrDir/$AB2_LIB:$AB2UsrDir/$DWEB_LIB:$LD_LIBRARY_PATH fi export LD_LIBP if [ ! "$LANG" ] then LNG=C else LNG=$LANG fi export LNG } # Create log files under /tmp # set_up_log_file() { # copy the whole log dir from CD layout image to temp place cd $CDTMP cp -r $CDVAR/log . # make sure group is writable chmod -R g+w $CDTMP/$AB2_LOG chmod -R g+w $CDTMP/$AB2_CATALOG } # Create file system in /tmp for the server # set_up_system_file() { # set up /data image rm -rf $CDTMP mkdir $CDTMP mkdir $CDTMP/data # link all files from CD layout to temp cd $CDTMP/data ln -s $CDDATA/* . # We have link in all the directory/files. # Now for files that need to have a hard copy in /tmp # remove the links and copy it to /tmp # Need to have a copy of ebtrc rm -f ebtrc # at some point of the realease ebtrc is dropped # so make sure it exists before we copy it if [ -f $CDDATA/ebtrc ] ; then cp $CDDATA/ebtrc . fi # Need to have a copy of /ents/map.txt rm -fr ents cp -r $CDDATA/ents . rm -fr config mkdir config cd $CDTMP/$DATA_CONFIG ln -s $CDDATA/config/* . # ab2cd need a copy of the following files # added 3/9/99 # get a copy of ab2_options.template to disbale admin link FILE_LIST="admin_passwd dwhttpd.cfg nsapi.cfg ab2_main.template ab2_collections.template ab2_print.template ab2_init.template ab2_admin.template ab2_options.template" for i in ${FILE_LIST}; do rm -rf $i cp $CDDATA/config/${i} . done # empty out ab1 database rm -f ab2_collections.template . # create an empty AB2 database echo "dwCollectionList {" >> ab2_collections.template echo "}" >> ab2_collections.template chmod g+w ${FILE_LIST} # added 3/9/99 remove admin template rm -f ab2_admin.template } # Modify the configuration files for server to run under /tmp. # For any configuration files that have path pointing to AB2 server # need to be updated to point to the server on cd layout. # modify_files() { # update dwhttpd.cfg awk '{print} ; /dwhttpd.cfg/{printf "set CDROM %s\nset CDTMP %s\n", TEST1, TEST2}' TEST1=$CDROM TEST2=$CDTMP $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:set AB2RootDir.*:set AB2RootDir $CDROM/SUNWab2r/reloc:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:set AB2VarDir.*:set AB2VarDir $CDTMP:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:set AB2UsrDir.*:set AB2UsrDir $CDROM/SUNWab2u/reloc:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:set AB2ShareDir.*:set AB2ShareDir $CDROM/SUNWab2s/reloc:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:PidLog.*:PidLog $CDTMP/'${AB2_LOG}'/pid.log:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:MainLog.*:MainLog $CDTMP/'${AB2_LOG}'/main-$ServerPort.log:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ # added 3/10/99 # Don't log access to save space in /tmp #/usr/bin/sed -e 's:AccessLog.*:AccessLog $CDTMP/'${AB2_LOG}'/access-$ServerPort.log:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:AccessLog.*:AccessLog /dev/null:' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:ErrorLog.*:ErrorLog $CDTMP/'${AB2_LOG}'/errors-$ServerPort.log:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ /usr/bin/sed -e 's:ObjectFile.*:ObjectFile $CDTMP/'${DATA_CONFIG}'/nsapi.cfg:g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ # change port if (test "$NEW_PORT" != "8888") then /usr/bin/sed -e 's:8888.*:'${NEW_PORT}':g' < $CDTMP/$DATA_CONFIG/dwhttpd.cfg > /tmp/dwhttpd.cfg.$$ cp /tmp/dwhttpd.cfg.$$ $CDTMP/$DATA_CONFIG/dwhttpd.cfg rm -rf /tmp/dwhttpd.cfg.$$ fi # update nsapi # Define CDROM/CDTMP variable awk '{print} ; / nsapi/{printf "set CDROM %s\nset CDTMP %s\n", TEST1, TEST2}' TEST1=$CDROM TEST2=$CDTMP $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # Define where is the SUNWab2r package live /usr/bin/sed -e 's:set AB2RootDir.*:set AB2RootDir $CDROM/SUNWab2r/reloc:g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # Define where the log live /usr/bin/sed -e 's:set AB2VarDir.*:set AB2VarDir $CDTMP:g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # Define where the SUNWab2u (server binary) package live /usr/bin/sed -e 's:set AB2UsrDir.*:set AB2UsrDir $CDROM/SUNWab2u/reloc:g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # Define where the SUNWab2s package (style sheet) live /usr/bin/sed -e 's:set AB2ShareDir.*:set AB2ShareDir $CDROM/SUNWab2s/reloc:g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # Define where the server look for configuration info /usr/bin/sed -e 's:data-dir.*:data-dir="$CDTMP/data" \\:g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ # change port if (test "$NEW_PORT" != "8888") then /usr/bin/sed -e 's:8888.*:'${NEW_PORT}':g' < $CDTMP/$DATA_CONFIG/nsapi.cfg > /tmp/nsapi.cfg.$$ cp /tmp/nsapi.cfg.$$ $CDTMP/$DATA_CONFIG/nsapi.cfg rm -rf /tmp/nsapi.cfg.$$ fi # Define ab2_main.template /usr/bin/sed -e 's:.*set SourceDir.*:set SourceDir "'${AB2UsrDir}'/'${DWEB}'/'${DATA_CONFIG}'":' -e 's:.*ab2_collections.*:source "'${CDTMP}'/'${DATA_CONFIG}'/ab2_collections.template":' -e 's:.*ab2_print.*:source "'${CDTMP}'/'${DATA_CONFIG}'/ab2_print.template":' < $CDTMP/$DATA_CONFIG/ab2_main.template > /tmp/ab2_main.template.$$ cp /tmp/ab2_main.template.$$ $CDTMP/$DATA_CONFIG/ab2_main.template rm -rf /tmp/ab2_main.template.$$ # Added 3/9/99 # remove ab2_admin.template /usr/bin/sed -e '/ab2_admin.template/d' < $CDTMP/$DATA_CONFIG/ab2_main.template > /tmp/ab2_main.template.$$ cp /tmp/ab2_main.template.$$ $CDTMP/$DATA_CONFIG/ab2_main.template rm -rf /tmp/ab2_main.template.$$ # update map.txt file /usr/bin/sed -e 's:/usr:'${MAPTXT}':g' < ${CDTMP}/data/ents/map.txt > /tmp/map.txt.$$ cp /tmp/map.txt.$$ ${CDTMP}/data/ents/map.txt rm -f /tmp/map.txt.$$ # update ebtrc if [ -f $CDTMP/data/ebtrc ] ; then /usr/bin/sed -e 's:/usr/'${DWEB}':'$CDTMP':' $CDTMP/data/ebtrc > /tmp/ebtrc.$$ cp /tmp/ebtrc.$$ $CDTMP/data/ebtrc rm -rf /tmp/ebtrc.$$ /usr/bin/sed -e 's:LIBRARY_PATH.*:LIBRARY_PATH '$CDLIB':' $CDTMP/data/ebtrc > /tmp/ebtrc.$$ cp /tmp/ebtrc.$$ $CDTMP/data/ebtrc rm -rf /tmp/ebtrc.$$ fi EBTRC=$CDTMP/data/ebtrc # update ab2_print.template /usr/bin/sed -e 's:\[dwGet Ab2UsrPath\]/dweb/data/ebtrc:'$CDTMP/data/ebtrc':' $CDTMP/$DATA_CONFIG/ab2_print.template > /tmp/ab2_print.template.$$ cp /tmp/ab2_print.template.$$ $CDTMP/$DATA_CONFIG/ab2_print.template rm -f /tmp/ab2_print.template.$$ # lastest AB2 does not use ebtrc /usr/bin/sed -e 's:-data_dir \[dwGet Ab2UsrPath\]/dweb/data:-data_dir '$CDTMP/data':' $CDTMP/$DATA_CONFIG/ab2_print.template > /tmp/ab2_print.template.$$ cp /tmp/ab2_print.template.$$ $CDTMP/$DATA_CONFIG/ab2_print.template rm -f /tmp/ab2_print.template.$$ # update ab2_admin.template # remove 3/9/99 #/usr/bin/sed -e 's:\[dwGet Ab2UsrPath\]/dweb/data/config/admin_passwd:'$CDTMP/data/config/admin_passwd':' $CDTMP/$DATA_CONFIG/ab2_admin.template > /tmp/ab2_admin.template.$$ #cp /tmp/ab2_admin.template.$$ $CDTMP/$DATA_CONFIG/ab2_admin.template #rm -f /tmp/ab2_admin.template.$$ # 3/9/99 # Gray out link to admin /usr/bin/sed -e 's::\"\$\[dwGet\$\[dwGetParam Ab2DisplayName\] \$\[dwGet ab2_msg2\]:g' $CDTMP/$DATA_CONFIG/ab2_options.template > /tmp/ab2_options.template.$$ cp /tmp/ab2_options.template.$$ $CDTMP/$DATA_CONFIG/ab2_options.template rm -f /tmp/ab2_options.template.$$ } # start up the server start_up() { # Setting up the environment variables for the server to run with. set_up_environment # set up AB2 running environment LD_PRELOAD=$PRELOAD export LD_PRELOAD LANG=C export LANG AB2_ORIG_LANG=$LNG export AB2_ORIG_LANG LD_LIBRARY_PATH=$LD_LIBP export LD_LIBRARY_PATH EBT_REGISTRY=$ER export EBT_REGISTRY cd $AB2BIN $AB2BIN/dwhttpd $AB2CFG # reset LANG LANG=$AB2_ORIG_LANG export LANG } # kill the process running from ab2cd # stop_server() { if test -d $CDTMP ; then # is the ab2cd server running # added 4/6/99, interrupt caused this message to appear # "cannot open /tmp/.ab2/log/ab2/logs/pid.log" if [ -f ${CDTMP}/${AB2_LOG}/pid.log ] then PID=`cat ${CDTMP}/${AB2_LOG}/pid.log | /usr/bin/fgrep http | /usr/bin/awk '{print $1}'` if [ ! -z "$PID" ] then /usr/bin/kill ${PID} 1>/dev/null 2>&1 fi fi fi } invoke_browser() { # This a hack to find the browser, there got to be a better way! # browser name browser_type= # browser path browser= env_path=`which dummy` for i in ${env_path}; do if [ -x $i/hotjava ]; then browser=$i/hotjava browser_type="HotJava" hotjava="$i/hotjava" # for now use netscape as the default # so we don't break out here, so netscape can be searched # break fi if [ -x $i/netscape ]; then browser=$i/netscape browser_type="Netscape" break fi done # Did we find any browser? if [ ! -z "$browser" ] ; then msg2="`gettext 'Do you want to start %s now? [y,n]'`" printf "${msg2} \c" "${browser_type}" read answer if (test "$answer" = "y") || (test "$answer" = "Y") || (test "$answer" = "yes") || (test "$answer" = "YES") then echo "" msg="`gettext 'Starting browser with URL %s ....'`" printf "\n${msg}\n" $1 $browser $1 & fi fi } ############################ Parse argument ###################### # Note that we can not just print out error messages and exits here # because we need to know where the localized messages live. # Another word, the routine (set_up_message) to set up message environment can # not be called before this because the message path can depend on the user # input. # # NOTE : messages is layout on CD as follows: # ../.ab2cd_msgs/{ARC}/{LOCALE}/LC_MESSAGES/ab2cd.mo parse_arg() { case $# in 0) # No argument specified # No options is enter, this is same as a request to start server from ab2cd # using the default setting Task="start" ;; 1) # Only one argument specified # This is the case like # ab2cd start ; ab2cd stop; ab2cd restart; ab2cd -s case $1 in # stop|start|restart) stop|start) Task=$1 ;; -s) Task="start" Option="scan" ;; -v) Task="version" ;; *) Task="error" ;; esac ;; 2|3|4|5|6) # options + arguments within range #default Task to start Task="start" # number of argument num_arg=$# # keep track of number of arg being parse # if this number does not match num_arg at the end # then there is an error count=0 case $1 in # start|stop|restart) start|stop) count=`expr $count + 1` Task=$1 shift ;; *) # if this is not a option, then this is an error dash=`echo ${1} | /usr/bin/cut -c1` if (test "$dash" != "-") then Task="error" fi ;; esac while getopts sd:p: WHICH_OPTION do case $WHICH_OPTION in s) count=`expr $count + 1` # only start can have this option # if (test "$Task" = "stop") || (test "$Task" = "restart") if (test "$Task" = "stop") then Task="error" else Option="scan" fi ;; d) count=`expr $count + 1` # only start can have this option # if (test "Task" = "stop") || (test "Task" = "restart") if (test "Task" = "stop") then Task="error" else # check to make sure that the argument does not contain an # option; for some reason getopts() does not catch this??? dash=`echo ${OPTARG} | /usr/bin/grep "^-"` if [ ! -z "$dash" ] ; then Task="error" else count=`expr $count + 1` CDROOT=$OPTARG # is the path a directory?? if [ ! -d $CDROOT ] then Task="bad_path" else # we don't want the path end with / tmp_path=$CDROOT/ two_slash=`echo ${tmp_path} | /usr/bin/grep "//"` if [ ! -z "$two_slash" ] then # chop of / NEW_CDROOT=`echo ${tmp_path} | /usr/bin/sed 's:\/\/::g` if [ -d $NEW_CDROOT ] then CDROOT=$NEW_CDROOT fi fi fi fi fi ;; p) count=`expr $count + 1` # only start can have this option # if (test "Task" = "stop") || (test "Task" = "restart") if (test "Task" = "stop") then Task="error" else # check to make sure that the argument does not contain an # option; for some reason getopts() does not catch this??? dash=`echo ${OPTARG} | /usr/bin/grep "^-"` if [ ! -z "$dash" ] ; then Task="error" else count=`expr $count + 1` NEW_PORT=$OPTARG ID=`id | /usr/bin/awk '{print $1}'` if ( test "$ID" != "uid=0(root)" ) then if (test $NEW_PORT -lt 1024) then msg="`gettext 'You need to use port number greater than 1024.'`" printf "${msg}\n" exit fi fi fi fi ;; *) Task="error" ;; esac done if (test $count -ne $num_arg) then Task="error" fi ;; *) # options + arguments out of range Task="error" ;; esac } # find the message file on cd layout # set up the environmnet pick messages from cd layout # set_up_message() { ##################### Get message file location ###################### unset MSGPATH # find where the messages for ab2cd live if [ -d ${CDROOT} ] then # check the second level first LIST=`/usr/bin/ls ${CDROOT}` for i in ${LIST}; do # don't want symbolic link if [ ! -h ${CDROOT}/${i} ] then # second level name LEVEL2=${i} if [ -d ${CDROOT}/${i}/.ab2cd_msgs/${ARC} ] then MSGPATH=${CDROOT}/${i}/.ab2cd_msgs/${ARC} break fi fi done # if not in second level use find command (this can take long depend # on the content of the CD if [ -z "$MSGPATH" ] then # indicate ab2cd is in progress echo "......................................................." echo " " msgdir=`/usr/bin/find ${CDROOT} -name .ab2cd_msgs` if [ ! -z "$msgdir" ] then # overwrite MSGPATH MSGPATH=${msgdir}/${ARC} fi fi fi # set up messages location # gettext uses these environment variable to retrieve text string from message # database (ab2cd.mo) TEXTDOMAIN=ab2cd TEXTDOMAINDIR=$MSGPATH NLSPATH=${MSGPATH}/%L/LC_MESSAGES/%N export TEXTDOMAIN export TEXTDOMAINDIR export NLSPATH } ######### get Lang and determine the encoding ####### # variables used by iconv to convert messages from UTF-8 format to the # client encoding. # encoding : iconv -t (to encoding) # utf8_encoding : iconv -f (from encoding, should be "UTF-8" except # for korean) # UTF8 : indicate if client lang is in UTF-8, in this case no iconv need # to be called on the message # determine_encoding() { lg=`echo $LANG` utf8_encoding=UTF-8 # if LANG is not define, use C if [ -z "$lg" ] then encoding=8859-1 else case $lg in C) encoding=8859-1 ;; en_*) encoding=8859-1 ;; es) encoding=8859-1 ;; es_*) encoding=8859-1 ;; fr) encoding=8859-1 ;; fr_*) encoding=8859-1 ;; it) encoding=8859-1 ;; it_*) encoding=8859-1 ;; sv) encoding=8859-1 ;; sv_*) encoding=8859-1 ;; de) encoding=8859-1 ;; de_*) encoding=8859-1 ;; ja) encoding=eucJP ;; japanese) encoding=eucJP ;; ja_JP.PCK) encoding=SJIS ;; ko) encoding=ko_KR-euc utf8_encoding=ko_KR-UTF-8 ;; zh) encoding=zh_CN.euc ;; zh_TW) encoding=zh_TW-euc ;; zh_TW.BIG5) encoding=zh_TW-big5 ;; *[Uu][Tt][Ff]-8*) UTF8="TRUE" ;; *) msg=`gettext '%s does not support the locale %s.'` printf "\n${msg}\n" "${command}" "${lg}" msg2=`gettext '%s supports these locales: %s.'` printf "\n${msg2}\n" "${command}" "C, en_*, es, es_*, fr, fr_*, it, it_*, sv, sv_*, de, de_*, ja, japanese, ja_JP.PCK, ko, zh, zh_TW, zh_TW.BIG5, all UTF8 (*[Uu][Tt][Ff]-8*)" exit 1 ;; esac fi } # Check unsupported architecture # arc_check() { if test "$ARC" != "sparc" && test "$ARC" != "i386" ; then msg="`gettext 'Architecture not supported : %s'`" printf "\n${msg}\n" "${ARC}" return 5 fi } # Get doc location # set_doc_location() { # look into standard location if [ -d ${CDROOT}/*/*/common ] ; then CDDOCPATH=`/usr/bin/ls -d ${CDROOT}/*/*/common/Product | head -1` fi # if not found, use find if [ -z "$CDDOCPATH" ] ; then CDDOCPATH=`/usr/bin/find ${CDROOT} -name Product | /usr/bin/grep common` fi # check path to the doc on CD if [ ! -d "$CDDOCPATH" ]; then return 6 fi } # add help collection # add_help_collection() { # install help collection # get the locale HELP_LANG=`/usr/bin/ls ${AB2UsrDir}/${AB2_DOC}/Help/` # for each locale printf "\n" for i in ${HELP_LANG}; do # make sure that it is a collection structure if test -d ${AB2UsrDir}/${AB2_DOC}/Help/$i/Help/books && test -f ${AB2UsrDir}/${AB2_DOC}/Help/$i/Help/booklist.txt ; then # go ahead and add this help collection # install help collection only when it is not there HELP_EXIST=`/usr/bin/fgrep Help_${i} ${AB2UsrDir}/${DWEB}/$DATA_CONFIG/ab2_collections.template` if [ -z "$HELP_EXIST" ] then # echo "Installing help in ${i} locale ..." # msg2="`gettext 'AnswerBook2 Help collection in %s locale'`" # printf "${msg2}\n" "${i}" # save original copy OLD_AB2DB=/tmp/old_ab2_collections.template.$$ # added get 10/27/98; get title from collinfo file unset COL_TITLE COL_TITLE=`/usr/bin/fgrep title ${AB2UsrDir}/${AB2_DOC}/Help/$i/Help/collinfo | /usr/bin/cut -d'"' -f2,2` #COL_TITLE="AnswerBook2 Help collection in ${i} locale" unset COL_ENCODING COL_ENCODING=`/usr/bin/fgrep encoding ${AB2UsrDir}/${AB2_DOC}/Help/$i/Help/collinfo | /usr/bin/awk '{print $2}'` unset TO_ENCODING # we don't want to install non-english title collection # when iconv is not present if (test "$ICONV" = "TRUE") || (test -z "${COL_ENCODING}") then msg2="`gettext 'Adding AnswerBook2 Help collection in %s locale'`" printf "${msg2}\n" "${i}" if [ ! -z "${COL_ENCODING}" ] then if [ "${COL_ENCODING}" = "ko_KR-euc" ] then TO_ENCODING="ko_KR-UTF-8" else TO_ENCODING="UTF-8" fi if [ ! -z "${COL_TITLE}" ] then unset NEW_TITLE NEW_TITLE=`echo ${COL_TITLE} | iconv -f ${COL_ENCODING} -t ${TO_ENCODING}` #NEW_TITLE=`echo ${COL_TITLE}` fi fi awk '{print} ; /dwCollectionList {/{printf " %s dwCollection\n", HELP_NAME}' HELP_NAME=Help_${i} ${AB2DB} > ${OLD_AB2DB} echo "dwSetParam Help_${i} {" >> ${OLD_AB2DB} echo " location ${AB2UsrDir}/${AB2_DOC}/Help/${i}/Help" >> ${OLD_AB2DB} if [ ! -z "$NEW_TITLE" ] then #echo " encoding UTF-8" >> ${OLD_AB2DB} #echo " from_encoding ${COL_ENCODING}" >> ${OLD_AB2DB} echo " title \"${NEW_TITLE}\"" >> ${OLD_AB2DB} else if [ ! -z "${COL_TITLE}" ] ; then echo " title \"${COL_TITLE}\"" >> ${OLD_AB2DB} else echo " title \"Help\"" >> ${OLD_AB2DB} fi fi echo " type EbtCollection" >> ${OLD_AB2DB} echo "}" >> ${OLD_AB2DB} cp ${OLD_AB2DB} ${AB2DB} rm -f ${OLD_AB2DB} else # no iconv installed and the collection has encoding msg2="`gettext 'Ignoring AnswerBook2 Help Collection in %s locale because the locale is not supported on this server.'`" printf "${msg2}\n" "${i}" fi fi fi done } # # This routine should be called to the final update of collection database # calls after scan() # sort_collection() { if [ ! -f /tmp/ab2_sort.$$ ] then return 1 fi OLD_AB2DB=/tmp/old_ab2_collections.template.$$ # sort collection list in reverse order # later the list is added as a stack to the database SORTED_LIST=`/usr/bin/sort -r /tmp/ab2_sort.$$ | /usr/bin/cut -d: -f2,3 | /usr/bin/cut -d: -f2,3` # add collection to database for i in ${SORTED_LIST} ; do # push each collection to the top of the list awk '{print} ; /dwCollectionList {/{printf " %s dwCollection\n", NAME}' NAME=${i} ${AB2DB} > ${OLD_AB2DB} cp ${OLD_AB2DB} ${AB2DB} rm -f ${OLD_AB2DB} done rm -f /tmp/ab2_sort.$$ # do legacy here # list of sorted ids CHECK="TRUE" TMP_AB1_SORTED=/tmp/ab1_sorted_card.$$ # Note that if list only has one then it will return nothing SORTED_LIST=`/usr/bin/sort $AB1_SORT | /usr/bin/cut -d\^ -f2` for i in ${SORTED_LIST} ; do # get the data for specified collection LINE=`/usr/bin/grep $i $AB1_SORT` TITLE=`echo $LINE | /usr/bin/cut -d\^ -f1` TOC=`echo $LINE | /usr/bin/cut -d\^ -f3` PS=`echo $LINE | /usr/bin/cut -d\^ -f4` INDEX=`echo $LINE | /usr/bin/cut -d\^ -f5` if test -d $TOC && test -d $PS && test -d $INDEX && test ! -z "$i" && test ! -z "$TITLE"; then echo ":id=${i}: \\" >> $TMP_AB1_SORTED echo ":title=$TITLE: \\" >> $TMP_AB1_SORTED echo ":tocpath=$TOC: \\" >> $TMP_AB1_SORTED echo ":pspath=$PS: \\" >> $TMP_AB1_SORTED echo ":indexpath=$INDEX:" >> $TMP_AB1_SORTED else CHECK="FALSE" fi done # TMP_AB1_SORTED is empty only when there is nothing to sort if (test "$CHECK" = "TRUE") && (test -f $TMP_AB1_SORTED) then # update database with newly sorted list cp $TMP_AB1_SORTED $AB1DB rm -f $TMP_AB1_SORTED fi rm -f $AB1_SORT } # # add_collection() { # Add AB2 collections AB2COL=`/usr/bin/ls -d ${CDDOCPATH}/*/reloc/AB2INSTALLDIR` rm -f /tmp/collinfo.$$ printf "\n" for i in ${AB2COL}; do if [ ! -f ${i}/ents/map.txt ] then unset COL_NAME unset COL_TITLE unset COL_PKG_TITLE unset NEW_TITLE unset COL_TYPE unset TO_ENCODING /usr/bin/sed -e 's:<>:'${i}':g' < ${i}/collinfo > /tmp/collinfo.$$ # get collection name NUM=`cat /tmp/collinfo.$$| /usr/bin/fgrep dwSetParam | /usr/bin/wc -w` if (test $NUM = 3) then COL_NAME=`cat /tmp/collinfo.$$| /usr/bin/fgrep dwSetParam | /usr/bin/awk '{print $2}'` fi # get collection type NUM=`cat /tmp/collinfo.$$| /usr/bin/fgrep type | /usr/bin/wc -w` if (test $NUM = 2) then COL_TYPE=`cat /tmp/collinfo.$$| /usr/bin/fgrep type | /usr/bin/awk '{print $2}'` fi unset COL_PKG__TITLE COL_PKG_TITLE=`/usr/bin/pkgparam -f ${i}/../../pkginfo NAME` # added get 10/27/98; get title from collinfo file COL_TITLE=`/usr/bin/fgrep title ${i}/collinfo | /usr/bin/cut -d'"' -f2,2` # COL_TITLE=`/usr/bin/pkgparam -f ${i}/../../pkginfo NAME` unset COL_ENCODING COL_ENCODING=`/usr/bin/fgrep encoding ${i}/collinfo | /usr/bin/awk '{print $2}'` unset TO_ENCODING # we don't want to install non-english title collection # when iconv is not present if (test "$ICONV" = "TRUE") || (test -z "${COL_ENCODING}") then if [ ! -z "${COL_ENCODING}" ] then if [ "${COL_ENCODING}" = "ko_KR-euc" ] then TO_ENCODING="ko_KR-UTF-8" else TO_ENCODING="UTF-8" fi if [ ! -z "${COL_TITLE}" ] then unset NEW_TITLE NEW_TITLE=`echo ${COL_TITLE} | iconv -f ${COL_ENCODING} -t ${TO_ENCODING}` #NEW_TITLE=`echo ${COL_TITLE}` fi fi rm -f /tmp/collinfo.$$ if test ! -z "$COL_NAME" && test ! -z "$COL_PKG_TITLE" && test ! -z "$COL_TYPE" ; then # save original copy OLD_AB2DB=/tmp/old_ab2_collections.template.$$ #awk '{print} ; /dwCollectionList {/{printf " %s dwCollection\n", NAME}' NAME=${COL_NAME} ${AB2DB} > ${OLD_AB2DB} cp ${AB2DB} ${OLD_AB2DB} echo "dwSetParam ${COL_NAME} {" >> ${OLD_AB2DB} echo " location ${i}" >> ${OLD_AB2DB} if [ ! -z "$NEW_TITLE" ] then printf "${COL_TITLE}\n" echo "${COL_TITLE} : ${COL_NAME} " >> /tmp/ab2_sort.$$ #echo " encoding UTF-8" >> ${OLD_AB2DB} #echo " from_encoding $COL_ENCODING" >> ${OLD_AB2DB} echo " title \"${NEW_TITLE}\"" >> ${OLD_AB2DB} else if [ ! -z "$COL_TITLE" ] then echo "${COL_TITLE} : ${COL_NAME} " >> /tmp/ab2_sort.$$ printf "${COL_TITLE}\n" echo " title \"${COL_TITLE}\"" >> ${OLD_AB2DB} else echo "${COL_PKG_TITLE} : ${COL_NAME} " >> /tmp/ab2_sort.$$ printf "${COL_PKG_TITLE}\n" echo " title \"${COL_PKG_TITLE}\"" >> ${OLD_AB2DB} fi fi echo " type ${COL_TYPE}" >> ${OLD_AB2DB} echo "}" >> ${OLD_AB2DB} cp ${OLD_AB2DB} ${AB2DB} rm -f ${OLD_AB2DB} fi else # no iconv installed and the collection has encoding msg2="`gettext 'Ignoring %s collection.'`" printf "${msg2}\n" "${COL_TITLE}" fi fi done # install legacy collection TMP_AB1DB=/tmp/ab_cardcatalog.$$ AB1_SORT=/tmp/ab1_sort.$$ rm -f ${AB1_SORT} rm -f ${TMP_AB1DB} ABCOL=`/usr/bin/ls ${CDDOCPATH}` for i in ${ABCOL}; do if [ -d ${CDDOCPATH}/${i}/reloc ] then CAT=`/usr/bin/pkgparam -f ${CDDOCPATH}/${i}/pkginfo CATEGORY` if (test "$CAT" != "application,AnswerBook2") then VER=`/usr/bin/pkgparam -f ${CDDOCPATH}/${i}/pkginfo PRODVERS` VER=`echo $VER | /usr/bin/tr "." "_"` TITLE=`/usr/bin/pkgparam -f ${CDDOCPATH}/${i}/pkginfo NAME` printf "${TITLE}\n" # detect japanese legacy collection if [ -f ${CDDOCPATH}/${i}/reloc/ContentsDBDEST/SUNWabj_${VER}.ind ] then TMP_ID="SUNWabj_${VER}" # echo ":id=SUNWabj_${VER}: \\" >> ${TMP_AB1DB} else TMP_ID="SUNWab_${VER}" # echo ":id=SUNWab_${VER}: \\" >> ${TMP_AB1DB} fi echo ":id=$TMP_ID: \\" >> ${TMP_AB1DB} echo ":version=: \\" >> ${TMP_AB1DB} echo ":title=${TITLE}: \\" >> ${TMP_AB1DB} echo ":tocpath=${CDDOCPATH}/${i}/reloc/ContentsDBDEST: \\" >> ${TMP_AB1DB} echo ":pspath=${CDDOCPATH}/${i}/reloc/PostScriptDEST: \\" >> ${TMP_AB1DB} echo ":indexpath=${CDDOCPATH}/${i}/reloc/IndexDEST:" >> ${TMP_AB1DB} # eval $INSTALL_AB1 MERGE_AB1DB="cat ${AB1DB} ${TMP_AB1DB} > /tmp/ab2_merge.$$" eval $MERGE_AB1DB # output this to a file for later sorting echo "${TITLE}^$TMP_ID^${CDDOCPATH}/${i}/reloc/ContentsDBDEST^${CDDOCPATH}/${i}/reloc/PostScriptDEST^${CDDOCPATH}/${i}/reloc/IndexDEST" >> ${AB1_SORT} cp /tmp/ab2_merge.$$ ${AB1DB} rm -f /tmp/ab2_merge.$$ rm -f ${TMP_AB1DB} fi fi done } # make sure that we have all the unix commands # needed to run ab2cd # command_check() { if test -x /usr/bin/fgrep && test -x /usr/bin/grep && test -x /usr/bin/awk && test -x /usr/bin/find && test -x /usr/bin/ls && test -x /usr/bin/ps && test -x /usr/bin/cut && test -x /usr/bin/sed && test -x /usr/bin/kill && test -x /usr/bin/pkgparam && test -x /usr/bin/uname && test -x /usr/bin/sort && test -x /usr/bin/cp && test -x /usr/bin/wc; then # we are OK return 0 else # problem return 2 fi } # Routine to clean up files created by ab2cd # and stop the server if any that is running # clean_up() { # shut down server if needed stop_server # Remove files cd /tmp rm -rf $CDTMP rm -f /tmp/ab2cd_config rm -f /tmp/ab2.socat.cache rm -f /tmp/collinfo.* rm -f /tmp/col_list.* rm -f /tmp/ab2_sort.* rm -f /tmp/lines.* rm -f /tmp/local.socat.* rm -f /tmp/old_ab2_collections.template.* rm -f /tmp/ab1_sorted_card.* rm -f /tmp/ab1_sort.* rm -f /tmp/tmpfile.* rm -f /tmp/dwhttpd.cfg.* rm -f /tmp/nsapi.cfg.* rm -f /tmp/ab2_main.template.* rm -f /tmp/map.txt.* rm -f /tmp/ebtrc.* rm -f /tmp/ab2_print.template.* rm -f /tmp/ab2_admin.template.* rm -f /tmp/ab2_options.template.* rm -f /tmp/ab_cardcatalog.* rm -f /tmp/ab2_merge.* exit 0 } # get Ab2 doc package list from pkg database # Note that this list might contain non AB2 doc package # get_ab2_list () { if [ -d /var/sadm/pkg ]; then AB2_LIST_PKG=`/usr/bin/fgrep collinfo /var/sadm/install/contents | awk '{print $10} ' | /usr/bin/grep -v SUNWab2u` return 0 else return 8 fi } # get AB1 doc package from pkg database # Note that this list might contain non AB1 doc package get_ab1_list () { AB1_LIST_PKG=`/usr/bin/pkginfo | /usr/bin/grep -i answerbook | /usr/bin/grep -v SUNWab2u | /usr/bin/grep -v SUNWab2s | /usr/bin/grep -v SUNWab2r | /usr/bin/awk '{print $2}'` } # given the pkg name # find and set the collinfo file # get_collinfo () { if (test $# -ne 1) then return 1 fi BASE=`/usr/bin/pkgparam $1 COLL_PARENTDIR` unset COLLINFO if test ! -z "$BASE" then # basedir/pkgname/collinfo if [ -f ${BASE}/$1/collinfo ] ; then COLLINFO=${BASE}/$1/collinfo fi # if still not found if test -z "$COLLINFO" then # basedir/answerbooks if [ -d ${BASE}/answerbooks ]; then LIST_LANG=`/usr/bin/ls ${BASE}/answerbooks` fi for LG in ${LIST_LANG}; do OS="solaris_2.6 solaris_2.7" for x in ${OS}; do if [ -f ${BASE}/answerbooks/${LG}/${x}/$1/collinfo ] then COLLINFO=${BASE}/answerbooks/${LG}/${x}/$1/collinfo break fi done if test ! -z "$COLLINFO" then break fi done fi # if still not found ! if test -z "$COLLINFO" then # the hard way!!!! if [ -f /var/sadm/install/contents ] then DATA=`/usr/bin/grep ${pkgname} /var/sadm/install/contents | /usr/bin/grep collinfo | awk '{printf $1}'` COLLINFO=`echo $DATA` fi fi fi # check to see if we get collinfo if test -z "$COLLINFO" then # can not find collinfo return 1 fi } # get ab_cardcatalog get_abcardcatalog () { if (test $# -ne 1) then return 1 fi unset BASE unset ABHOME unset ABCARDCATALOG BASE=`/usr/bin/pkgparam $1 BASEDIR` ABHOME=`/usr/bin/pkgparam $1 ABHOME` if test ! -z "$ABHOME" then if [ -f $ABHOME/ab_cardcatalog ] ; then ABCARDCATALOG=$ABHOME/ab_cardcatalog return else if test ! -z "$BASE" then if [ -f $BASE/$ABHOME/ab_cardcatalog ] ; then ABCARDCATALOG=$BASE/$ABHOME/ab_cardcatalog return else if [ -f $BASE/ab_cardcatalog ] ; then ABCARDCATALOG=$BASE/ab_cardcatalog return fi fi fi fi fi # can not find ab1_cardcatalog file return 1 } # is the package a AB2 doc package is_AB2 () { if (test $# -ne 1) then return 1 fi unset ISAB2 ISAB2=`/usr/bin/pkgparam $1 CATEGORY | /usr/bin/grep -i answerbook2` if test ! -z "$ISAB2" then return 0 else return 1 fi } # is the package a AB1 doc package is_AB1 () { if (test $# -ne 1) then return 1 fi unset ISAB1 ISAB1=`/usr/bin/pkgparam $1 PostScriptDEST` if test ! -z "$ISAB1" then return 0 else return 1 fi } # get ab1 collection id from ab2_cardcatalog file get_ab1_collid () { if (test $# -ne 1) then return 1 fi unset AB1_ID # AB1_ID=`/usr/bin/pkgparam $1 PRODVERS | /usr/bin/sed 's/\./_/g'` AB1_ID=`/usr/bin/pkgparam $1 VERSION | /usr/bin/cut -d. -f1,2 | /usr/bin/sed 's/\./_/g'` if test $? -ne 0 ; then # can not get ID return 1 fi if [ -z "$AB1_ID" ] then # can not get ID return 1 fi } # Get rid of comments from a file # filter_comment() { if (test $# -ne 1) then return 1 fi `/usr/bin/grep -v "^#" < $1 > /tmp/tmpfile.$$` cp /tmp/tmpfile.$$ $1 'rm' -r /tmp/tmpfile.$$ } # bug in legcy handling # If the legacy data is in one line format, the printing will not work. # This function break the legacy data into multiple lines format # # The new legacy data is stored in the specified file # make_cardcatalog () { # Need to specify the one-line legacy cardcatalog file # The output file to save the multiple-lines format if (test $# -ne 2) then return 1 fi in_data=$1 out_data=$2 # filter out comments filter_comment $in_data status=$? if [ $status -ne 0 ] then handle_error $status fi # there are at most 6 fields for legacy data but we added 4 # more fields in case there are colons (allow at most 4) in the title # unset TITLE # temporay variables unset TMP_ID unset TMP_TITLE unset TMP_TOC unset TMP_INDEX unset TMP_PS i=1 while (test $i -le 10) do # Get each field, the key, value LINE=`/usr/bin/cut -d: -f${i} < $in_data` key=`echo $LINE | /usr/bin/cut -d= -f1` value=`echo $LINE | /usr/bin/cut -d= -f2` # Does the field contain the word id? match=`echo $key | /usr/bin/grep "id"` if [ ! -z "$match" ] then TMP_ID=$value echo ":id=$value: \\" >> $out_data else # Does the field contain the word title? match=`echo $key | /usr/bin/grep "title"` if [ ! -z "$match" ] then # check to see if the \ is at the end of the title # which indicate that a colon exists slash=`echo $value | /usr/bin/grep "\\$"` if [ ! -z "$slash" ] then # save the title in case it contain colon TITLE="$value" # need to get the next field i=`expr $i + 1` DONE="FALSE" while (test "$DONE" = "FALSE") do LINE=`/usr/bin/cut -d: -f${i} < $in_data` KEY_toc=`echo $LINE | /usr/bin/grep tocpath=` KEY_ps=`echo $LINE | /usr/bin/grep pspath=` KEY_index=`echo $LINE | /usr/bin/grep indexpath=` KEY_id=`echo $LINE | /usr/bin/grep id=` KEY_ver=`echo $LINE | /usr/bin/grep version=` if (test ! -z "$KEY_toc") || (test ! -z "$KEY_ps") || (test ! -z "$KEY_index") || (test ! -z "$KEY_id") || (test ! -z "$KEY_ver") then # done with title DONE="TRUE" # reset fields number i=`expr $i - 1` break else # cat the title together LINE=`/usr/bin/cut -d: -f${i} < $in_data` TITLE="$TITLE:$LINE" i=`expr $i + 1` fi done echo ":title=$TITLE: \\" >> $out_data TMP_TITLE=$TITLE else # no colon in the title echo ":title=$value: \\" >> $out_data TMP_TITLE=$value fi else match=`echo $key | /usr/bin/grep "tocpath"` if [ ! -z "$match" ] then echo ":tocpath=$value: \\" >> $out_data TMP_TOC=$value else match=`echo $key | /usr/bin/grep "pspath"` if [ ! -z "$match" ] then echo ":pspath=$value: \\" >>$out_data TMP_PS=$value else match=`echo $key | /usr/bin/grep "indexpath"` if [ ! -z "$match" ] then echo ":indexpath=$value: " >> $out_data TMP_INDEX=$value fi fi fi fi fi i=`expr $i + 1` done echo "${TMP_TITLE}^${TMP_ID}^${TMP_TOC}^${TMP_PS}^${TMP_INDEX}" >> $AB1_SORT } # add ab1 doc collection add_ab1 () { if (test $# -ne 1) then return 1 fi get_abcardcatalog $1 if test $? -ne 0 ; then # echo Failed to get ab_cardcatalog return 1 fi get_ab1_collid $1 if test $? -ne 0 ; then # echo Failed to get ab2 id return 1 fi unset exist exist=`/usr/bin/grep $AB1_ID ${AB1DB}` if test -z "$exist" then cp $ABCARDCATALOG /tmp/card.$$ make_cardcatalog /tmp/card.$$ /tmp/strip.card.$$ status=$? if [ $status -ne 0 ] then handle_error $status fi cat $AB1DB /tmp/strip.card.$$ > $TMP_DB1 cp ${TMP_DB1} ${AB1DB} rm -f /tmp/card.$$ rm -f /tmp/strip.card.$$ rm -f ${TMP_DB1} msg="`gettext 'Added %s.'`" printf "$msg\n" "$1" else msg="`gettext 'Duplicate %s.'`" printf "$msg\n" "$1" fi } # pass in collinfo file and pkg name # add_ab2 () { if (test $# -ne 1) then return 1 fi package_name=$1 # get collinfo file get_collinfo $1 # check function return status if test $? -ne 0 ; then # can not get collinfo file return 1 fi collinfo_file=$COLLINFO # get collection id, COL_ID get_col_id $collinfo_file # check function return status if test $? -ne 0 ; then # can not get collection id return 1 fi unset $exist if [ ! -z "$COL_ID" ] then exist=`/usr/bin/grep $COL_ID $AB2DB` fi if test -z "$exist" then # get collection type, COL_TYPE get_col_type $collinfo_file # check function return status if test $? -ne 0 ; then # can not get collection type return 1 fi # get collection location, COL_LOC get_col_loc $collinfo_file # check function return status if test $? -ne 0 ; then # can not get collection location return 1 fi # get collection title COL_TITLE=`/usr/bin/pkgparam $package_name NAME` if test ! -z "$COL_ID" && test ! -z "$COL_TITLE" && test ! -z "$COL_TYPE" && test ! -z "$COL_LOC" ; then # Delay writting to dwCollection as it need to be sorted # awk '{print} ; /dwCollectionList {/{printf " %s dwCollection\n", NAME}' NAME=${COL_ID} ${AB2DB} > ${TMP_DB} cp ${AB2DB} ${TMP_DB} # write to sorted list in a file # this file is used to sort the collection in sort_collection() echo "${COL_TITLE} : ${COL_ID} " >> /tmp/ab2_sort.$$ echo "dwSetParam ${COL_ID} {" >> ${TMP_DB} echo " location ${COL_LOC}" >> ${TMP_DB} echo " title \"${COL_TITLE}\"" >> ${TMP_DB} echo " type ${COL_TYPE}" >> ${TMP_DB} echo "}" >> ${TMP_DB} cp ${TMP_DB} ${AB2DB} rm -f ${TMP_DB} msg="`gettext 'Added %s.'`" printf "\n${msg}\n" "$COL_TITLE" fi else msg="`gettext 'Duplicate %s.'`" printf "\n${msg}\n" "$1" fi } # get collection id from collinfo file get_col_id () { if (test $# -ne 1) then return 1 fi unset COL_ID NUM=`cat $1 | /usr/bin/fgrep dwSetParam | /usr/bin/wc -w` if (test $NUM = 3) then COL_ID=`cat $1| /usr/bin/fgrep dwSetParam | /usr/bin/awk '{print $2}'` fi if test ! -z "$COL_ID" then return else return 1 fi } # get collection type from collinfo file # $1 = pkgname get_col_type () { if (test $# -ne 1) then return 1 fi unset COL_TYPE NUM=`cat $1 | /usr/bin/fgrep type | /usr/bin/wc -w` if (test $NUM = 2) then COL_TYPE=`cat $1| /usr/bin/fgrep type | /usr/bin/awk '{print $2}'` fi if test ! -z "$COL_TYPE" then return else return 1 fi } # get collection location from collinfo file #$1 = pkgname get_col_loc () { if (test $# -ne 1) then return 1 fi unset COL_LOC NUM=`cat $1 | /usr/bin/fgrep location | /usr/bin/wc -w` if (test $NUM = 2) then COL_LOC=`cat $1| /usr/bin/fgrep location | /usr/bin/awk '{print $2}'` fi if test ! -z "$COL_LOC" then return else return 1 fi } # This script extracts/creates FPI of both SGML and legacy book # from collections defined in ab2_collections.template and ab1_cardcatalog. # The FPI will be stored in local.socat # create_socat() { # store list of collection in tmp file TMP_LIST=/tmp/col_list.$$ # backup the socat file /usr/bin/cp $AB2SOCAT $AB2SOCAT.bak # working socat file TMP_FILE=/tmp/local.socat.$$ # get a list of AB2 collections awk '$1 != "dwCollectionList" && /dwCollection/{printf "%s\n", $1}' ${AB2DB} > ${TMP_LIST} # number of AB2 collection NUM=`more ${TMP_LIST} | /usr/bin/wc -l` NUM=`expr $NUM + 1` i=1 rm -f ${TMP_FILE} # go thru each collection while (test $i -lt $NUM) do # obtain collection name (id) according to the position COL_NAME=`/usr/bin/sed -n -e ''${i}'p' ${TMP_LIST}` # Find the section that description the collection (lines numbers) # should be dwSetParam col_id { ... } LINE_START=`/usr/bin/awk '$1 == "dwSetParam" && /'${COL_NAME}' {/ {print NR}' ${AB2DB}` LINE_END=`expr $LINE_START + 4` # etract that section into a file `/usr/bin/sed -n -e ''${LINE_START}','${LINE_END}'p' < ${AB2DB} > /tmp/lines.$$` # get the collection location LOCATION=`/usr/bin/awk '$1 == "location" {print $2}' /tmp/lines.$$` SOCAT_PATH=${LOCATION}/socat if [ -f $SOCAT_PATH ] then # get each fpi for the collection NUM_SOCAT=`more ${SOCAT_PATH} | /usr/bin/wc -l` NUM_SOCAT=`expr $NUM_SOCAT + 1` j=1 while (test $j -lt $NUM_SOCAT) do FPI=`sed -n -e ''${j}'p' ${SOCAT_PATH} | awk '{printf "%s %s %s %s\n", $1, $2, $3, $4}'` BK_NAME=`sed -n -e ''${j}'p' ${SOCAT_PATH} | awk '{print $2}'` PATH_TO_BOOK=${LOCATION}/books/${BK_NAME} if [ -d $PATH_TO_BOOK ] then # echo $FPI echo "PUBLIC ${FPI} \"${PATH_TO_BOOK}\"" >> ${TMP_FILE} fi j=`expr $j + 1` done fi i=`expr $i + 1` done rm -f ${TMP_LIST} # handle legacy collection # number of AB1 collection NUM=`/usr/bin/awk '/:id=/{print}' ${AB1DB} | /usr/bin/wc -l` NUM=`expr $NUM + 1` i=1 start=1 # go thru each collection while (test $i -lt $NUM) do end=`expr $start + 5` `/usr/bin/sed -n -e ''${start}','${end}'p' < ${AB1DB} > ${TMP_LIST}` unset TOC unset TOCPATH unset PSPATH TOC=`/usr/bin/awk '/:id=/' ${TMP_LIST} | /usr/bin/cut -f2 -d '=' | /usr/bin/cut -f1 -d ':'` if test "$TOC" = "SUNWab_10_6" || test "$TOC" = "SUNWab_17_4" || test "$TOC" = "SUNWab_123_1" || test "$TOC" = "SUNWab_124_1" || test "$TOC" = "SUNWab_67_2" || test "$TOC" = "SUNWab_39_1" || test "$TOC" = "SUNWab_72_2" || test "$TOC" = "SUNWab_43_5"; then TOCPATH=`awk '/:tocpath=/' ${TMP_LIST} | /usr/bin/cut -f2 -d '=' | /usr/bin/cut -f1 -d ':'` PSPATH=`awk '/:pspath=/' ${TMP_LIST} | /usr/bin/cut -f2 -d '=' | /usr/bin/cut -f1 -d ':'` LIST=`/usr/bin/ls ${PSPATH}` for j in ${LIST}; do unset BK_NAME unset FPI unset TITLE BK_NAME=${j} BOOKPATH="${TOCPATH}/${BK_NAME}" COVERPATH="${PSPATH}/${BK_NAME}/Cover" FPI=`/usr/bin/awk '/FPI/{printf"%s %s %s %s", $2, $3, $4, $5}' $COVERPATH` TITLE=`/usr/bin/awk '/SOCAT/{printf"%s %s %s %s", $2, $3, $4, $5}' $COVERPATH | /usr/bin/cut -f2- -d '"' | /usr/bin/cut -f1 -d '"'` if test ! -z "$FPI" && test ! -z "$TOC" ; then echo "PUBLIC ${FPI} \"${BOOKPATH}\"" >> ${TMP_FILE} fi done fi i=`expr $i + 1` start=`expr $end + 1` done cp ${TMP_FILE} ${AB2SOCAT} rm -f ${TMP_FILE} rm -f ${TMP_LIST} rm -f /tmp/lines.$$ } # # added 3/4/99 (bug ) # Routine to scan/add locally installed collection # # TODO : block no non-english collection tile collection # scan() { # temporary databases TMP_DB1=/tmp/ab1db.$$ TMP_DB=/tmp/ab2db.$$ get_ab2_list # check function return status if test $? -ne 0 ; then # echo Failed to get AB2 list return 8 fi for pkgname in ${AB2_LIST_PKG}; do if (is_AB2 $pkgname) then add_ab2 $pkgname fi done get_ab1_list # check function return status if test $? -ne 0 ; then # echo Failed to get AB1 list return 1 fi for pkgname in ${AB1_LIST_PKG}; do if (is_AB1 $pkgname) then add_ab1 $pkgname # echo $pkgname fi done } # initialize function for ab2cd # init() { # Trap for signal trap "clean_up" 1 2 3 9 14 15 # Global variable # versin of this ab2cd VERSION="2.0" # CDROOT = cdrom mount point, default /cdrom CDROOT="/cdrom" # temporary location for log file, databases, config files and password CDTMP=/tmp/.ab2 NEW_PORT="8888" command=$0 # usage message USAGE="${command} [start] [-s] [-d path-to-cd-mount-point] [-p port] ${command} -v ${command} stop" # get machine name, architecture HOSTNAME=`/usr/bin/uname -n` ARC=`uname -p` # set up fixed path predefine_path } # Function to detect if iconv packages are install # AnswerBook2 depend on these packages # Set the value of ICONV # is_iconv_install() { unset ICONV if test -f /var/sadm/pkg/SUNWciu8/pkginfo && test -f /var/sadm/pkg/SUNWhiu8/pkginfo && test -f /var/sadm/pkg/SUNWjiu8/pkginfo && test -f /var/sadm/pkg/SUNWkiu8/pkginfo && test -f /var/sadm/pkg/SUNWuiu8/pkginfo ; then # true ICONV=TRUE return 0 else ICONV=FALSE return 1 fi } # # find out what path did the server start from # check_path() { is_ab2cd_running status=$? if [ $status -eq 0 ] then # server is running if [ -f /tmp/ab2cd_config ] then tmp_cdroot=`cat /tmp/ab2cd_config | /usr/bin/fgrep CDROOT | /usr/bin/awk '{print $2}'` if [ ! -z "$tmp_cdroot" ] then if [ -d $tmp_cdroot ] then CDROOT=$tmp_cdroot fi fi fi fi } # treat this as main() # ab2cd_start() { # set up signal, global variables, etc ... init status=$? if [ $status -ne 0 ] then handle_error $status fi # parse the command line parse_arg $1 $2 $3 $4 $5 $6 status=$? if [ $status -ne 0 ] then handle_error $status fi # Maybe the server already started and calling stop/restart # find out what path did the server start from check_path # Where to pick up localized messages set_up_message status=$? if [ $status -ne 0 ] then handle_error $status fi # make sure all the standard unix command are available command_check status=$? if [ $status -ne 0 ] then handle_error $status fi # Now we are ready to do the task # Task is defined at parse_arg() function above based on user input case $Task in 'version') echo "ab2cd ${VERSION}" ;; # 'restart') # # determine if a server is running (as a result of calling ab2cd) # is_ab2cd_running # status=$? # if [ $status -eq 0 ] # then # # server is running # # # stop the running server (the one started by ab2cd) # stop_server # status=$? # if [ $status -ne 0 ] # then # # trap error here # handle_error $status # fi # # # get server path and set up other paths ab2cd will use # set_up_path # status=$? # if [ $status -ne 0 ] # then # # trap error here # handle_error $status # fi # # # ready to start the server again # start_up # status=$? # if [ $status -ne 0 ] # then # # trap error here # handle_error $status # fi # else # if [ $status -eq 1 ] # then # msg2="`gettext 'There is no AnswerBook2 server running from %s.'`" # printf "\n${msg2}\n" "${command}" # exit 1 # else # handle_error $status # fi # fi # ;; 'start') ################ Start Document Server #################### # check architecture arc_check status=$? if [ $status -ne 0 ] then handle_error $status fi # set up paths etc ... set_up_path status=$? if [ $status -ne 0 ] then handle_error $status fi # find and set the location to documentation on cd layout set_doc_location status=$? if [ $status -ne 0 ] then handle_error $status fi # check for iconv packages is_iconv_install if [ $? -ne 0 ] then msg="`gettext 'Warning : AnswerBook2 requires the following iconv packages to be installed before running ab2cd:'`" printf "${msg}\n" printf "SUNWciu8 SUNWhiu8 SUNWjiu8 SUNWkiu8 SUNWuiu8\n\n" printf "`gettext 'If you continue running ab2cd, multiple-byte characters might not display correctly and collections with non-English titles will not be viewable with this server.'`" printf "\n" msg="`gettext 'Do you want to continue? [y,n]'`" printf "${msg}" read answer if (test "$answer" = "y") || (test "$answer" = "Y") || (test "$answer" = "yes") || (test "$answer" = "YES") then msg="`gettext 'Continue ...'`" else clean_up fi fi # check for existing server is_ab2cd_running status=$? if [ $status -eq 0 ] then # server (cd) is running msg="`gettext 'An AnswerBook2 server is running already from %s as %s:%s.'`" get_ab2cd_port if [ ! -z "$AB2CD_PORT" ]; then printf "\n${msg}\n" "${command}" "${HOSTNAME}" "${AB2CD_PORT}" fi exit 0 fi is_ab2_running status=$? if [ $status -eq 0 ] then # ab2 server is running # call routine to hanle this situation # If not using the same port, go ahead and start the server handle_running_server fi # set up files under /tmp set_up_system_file status=$? if [ $status -ne 0 ] then handle_error $status fi # make modification to files under /tmp modify_files status=$? if [ $status -ne 0 ] then handle_error $status fi # set up log files under /tmp set_up_log_file status=$? if [ $status -ne 0 ] then handle_error $status fi # this is for admin cgi to obtain the server configuration path rm -f /tmp/ab2cd_config echo "${AB2CFG}" > /tmp/ab2cd_config echo "CDROOT ${CDROOT}" >> /tmp/ab2cd_config # Installing collection on CD msg2="`gettext 'Scanning for collections and attempting to start AnswerBook2 server from CD.'`" printf "\n${msg2}\n" msg2="`gettext 'Please wait ...'`" printf "\n${msg2}\n" LC_CTYPE=C export LC_CTYPE add_help_collection status=$? if [ $status -ne 0 ] then handle_error 11 fi add_collection status=$? if [ $status -ne 0 ] then handle_error 12 fi if ( test "$Option" = "scan" ) then msg2="`gettext 'Detecting local collections ...'`" printf "\n${msg2}\n" scan status=$? if [ $status -ne 0 ] then handle_error 13 fi fi # sort AB1/AB2 collections and update the database sort_collection status=$? if [ $status -ne 0 ] then handle_error 10 fi create_socat status=$? if [ $status -ne 0 ] then handle_error 10 fi # DynaWeb requires pwd == bin dir, save & restore pwd # echo "starting server ..." msg2="`gettext 'Starting AnswerBook2 server from CD ...'`" printf "\n${msg2}\n" start_up if (test "$ACTIVE_SERVER" = "STANDARD") then rm -rf $CDTMP rm -f /tmp/ab2cd_config fi echo "" msg2=`gettext 'To read documents from the CD, open a browser with the URL:'` printf "\n${msg2}\n" printf "http://%s:%s\n\n" "${HOSTNAME}" "${NEW_PORT}" invoke_browser http://${HOSTNAME}:${NEW_PORT} echo "" msg2="`gettext 'After you are finished reading documents from the CD, stop the server using:'`" printf "${msg2}\n" printf "%s stop\n\n" $command ;; 'stop') ################ Stop Document Server #################### # set up predefined paths set_up_path #status=$? #if [ $status -ne 0 ] #then # handle_error $status #fi # is there a ab2cd image? if test -d $CDTMP && test -f /tmp/ab2cd_config ; then if [ -f ${CDTMP}/${AB2_LOG}/pid.log ] then # is the ab2cd server running PID=`cat ${CDTMP}/${AB2_LOG}/pid.log | /usr/bin/fgrep http | /usr/bin/awk '{print $1}'` ACTIVE=`/usr/bin/ps -e | /usr/bin/fgrep ${PID}` if [ -z "$ACTIVE" ] ; then # some how the server is dead msg2="`gettext 'There is no AnswerBook2 server running from %s.'`" printf "\n${msg2}\n" "${command}" clean_up exit 1 else msg2="`gettext 'Stopping AnswerBook2 server from ab2cd ...'`" printf "\n${msg2}\n" echo " " msg2=`gettext 'If you have shut down your regular AnswerBook2 server in order to run %s, use \"ab2admin -o start\" to restart your regular AnswerBook2 server.'` printf "${msg2}\n" "${command}" clean_up fi else # can not find the process id log file exit 1 fi else # How about the case where $CDTMP was remove but process still running? msg2="`gettext 'There is no AnswerBook2 server running from %s.'`" printf "\n${msg2}\n" "${command}" exit 1 fi ;; 'bad_path') ################ Bad specified cdrom mount point #################### msg2="`gettext 'AnswerBook2 server software not found at path %s.'`" printf "\n${msg2}\n" "${CDROOT}" msg2="`gettext 'Usage : %s'`" printf "\n${msg2}\n" "${USAGE}" ;; 'error') ################ Argument Syntax Error #################### msg2="`gettext 'Usage : %s'`" printf "\n${msg2} %s\n" "${USAGE}" ;; *) ################ Any thing else #################### msg2="`gettext 'Usage : %s'`" printf "\n${msg2} %s\n" "${USAGE}" ;; esac exit 0 } ab2cd_start $1 $2 $3 $4 $5 $6