#!/bin/sh # This script sets the Server entry in the client.conf file to the value of the first command-line parameter # newServer=`echo $1` if [ -z $newServer ] ; then echo echo 'Usage:' echo ' A server name is required. Please specify a new server name on the command line.' echo ' root privileges or sudo is required.' echo ' Example: "sudo resetserver.sh newnsname"' echo exit 0 fi # # # get ostype (darwin or anything else) case `uname -s` in *[Dd]arwin*) OSTYPE=Darwin ;; *) OSTYPE=other ;; esac # # # get path to the client.conf file from client.conf using aex-helper - works on unix, linux & mac conf_file=`aex-helper query config` echo 'Path to client.conf is: ' $conf_file # # show the current Server value. aex-helper is not dependent on the agent process running #curServer=`grep Server-1= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'` curServer=`aex-helper query ns` echo "Server was set to: " $curServer # # # set the new debug level and display the results and create a backup with 'prevserver' appended to the filename sedCmd="sed -i prevserver s/Server-1=$curServer/Server-1=$newServer/ $conf_file" #echo 'sedCmd is: ' $sedCmd res=`$sedCmd` # # echo "restarting altiris agent process..." installdir=`aex-helper query path` if [ $OSTYPE == 'Darwin' ] ; then rccmd=$installdir'/.bin/rcscript restart' echo $rccmd res=`$rccmd` else res=`/opt/altiris/notification/nsagent/bin/rcscript restart` fi echo $res # curServer=`aex-helper query ns` echo "Server is now set to: " $curServer #