Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #************************************************************
- # Company: SonicWALL Ltd. *
- # *
- # Description: script cdpinstall.sh *
- # *
- # Author: root *
- # *
- # Version: 1.1 *
- # *
- # Modifier: Jowis, 2011/07/04 *
- #************************************************************
- VERSION=""
- VERSION_OLD=""
- VERSION_NEW=""
- SRCDIR=`(cd \`dirname $0 \`; pwd )`
- SRCPKG=$SRCDIR/cdpagent.tar.gz
- TMPDIR=/sbin/cdp/install
- SYSLIBDIR=/usr/lib
- INSTALLDIR=/sbin
- ACCESSTYPE="root"
- ACCESSMODE="744"
- CDPAUTOUPDATE=cdpautoupdate
- CDPAGENTSERVICE=cdpagentservice
- CDPAGENTPROXY=cdpagentproxy
- CDPAGENTCONF=config.xml
- PIDOF=pidof
- MODE="interactive"
- AutoUpdateFlag="false"
- LOGFILE="/var/log/cdp/cdpinstall.log"
- argument=""
- commands=""
- SERVERIP=""
- function die()
- {
- echo $@ | tee -a ${LOGFILE}
- exit 1
- }
- usage()
- {
- echo "Usage: cdpinstall.sh [command] [option]"
- echo ' "command:"'
- echo ' "cdpinstall.sh -i" to install ( full installation)'
- echo ' "cdpinstall.sh -u" to uninstall'
- echo ' "cdpinstall.sh -d" to install CDP Agent Service only'
- echo ' "cdpinstall.sh -v|--version" output version info'
- echo ' "option:"'
- echo ' "-y|-Y" Automatically insert "yes" when querying yes/no during installation'
- echo ' "--access=all" Allow every user to access the CDP Agent Tool besides root user'
- echo ' "--serverip=ipAddr" Set the default server to connect, eg: --serverip=10.10.10.10'
- exit 1
- }
- confirm()
- {
- #auto update case, return true
- if [ "$MODE" = "non-interactive" ]; then
- return 0
- fi
- #other case, interactive mode, ask for confirm
- local yorn
- while true;
- do
- echo -n $1
- read yorn
- [ "$yorn" == "" ] && yorn=$2
- case $yorn in
- [nN])
- return 1;;
- [yY])
- return 0;;
- esac
- done
- }
- setinstallpath()
- {
- if [ "$ACCESSTYPE" = "all" ]; then
- INSTALLDIR=/usr/bin
- TMPDIR=/usr/bin/cdp/install
- ACCESSMODE="755"
- fi
- }
- distinfo()
- {
- [ -e /etc/mandrake-release ] && { DIST=mandrake; return; }
- [ -e /etc/redhat-release ] && { DIST=redhat; return; }
- [ -e /etc/SuSE-release ] && { DIST=suse; return; }
- [ -e /etc/debian_version ] && { DIST=debian; return; }
- [ -e /etc/turbolinux-release ] && { DIST=turbo; return; }
- [ -e /etc/mach_init.d ] && { DIST=mac; return; }
- local issue=/etc/issue
- if [ -e $issue ]; then
- grep -i debian $issue && { DIST=debian; return; }
- grep -i "red *hat" $issue && { DIST=redhat; return; }
- grep -i "suse\|s\.u\.s\.e" $issue && { DIST=suse; return; }
- grep -i "caldera" $issue && { DIST=caldera; return; }
- fi
- die "Your Linux distribution is not currently supported by the CDP Agent Tool!"
- }
- get_old_pkg_version()
- {
- if [ -s /etc/cdp/version ]; then
- read VERSION_OLD </etc/cdp/version
- fi
- }
- get_new_pkg_version()
- {
- tar xzf $SRCPKG version >/dev/null
- if [ $? -ne 0 ]; then
- echo "Get version of the new pkg, Could not find version file in source pkg!" | tee -a ${LOGFILE}
- else
- if [ -s $SRCDIR/version ]; then
- read VERSION_NEW <$SRCDIR/version
- rm -f $SRCDIR/version
- else
- echo "Get version of the new pkg, No version info in version file!" | tee -a ${LOGFILE}
- fi
- fi
- }
- get_installed_version()
- {
- if [ -s /etc/cdp/version ]; then
- read VERSION </etc/cdp/version
- return 0
- fi
- return 1
- }
- lib_config_install()
- {
- cp -f $SRCDIR/cdpinstall.sh $INSTALLDIR/cdp
- #here is modified by Jowis to update serverList info in config.xml, begin
- local serverInfo=" <serverList ip=\"$SERVERIP\" port=\"1000\" isdefault=\"1\" name=\"\" id=\"\" key=\"\" />"
- local tempInfo="<serverList ip=\"$SERVERIP\" port=\"1000\" isdefault=\"1\" name=\"\" id=\"\" key=\"\" />"
- #just show the default server ip here if you have set
- [ -n "$SERVERIP" ] && echo "lib_config_install, default server info: $tempInfo" | tee -a ${LOGFILE}
- #you input the option --serverip=x.x.x.x when you execute this script
- if [ -e /etc/cdp/config.xml ] && [ -f /etc/cdp/config.xml ]; then
- cat /etc/cdp/config.xml | grep "<serverList*\>" >temp
- #there is a server list in /etc/cdp/config.xml
- if [ -s temp ]; then
- if [ -n "$SERVERIP" ]; then
- if grep "<serverList ip=\"$SERVERIP\"*\>" temp >/dev/null 2>&1 ; then
- sed -i 's/isdefault="1"/isdefault="0"/g' temp
- sed -i "/ip=\"$SERVERIP\"/ s/isdefault=\"0\"/isdefault=\"1\"/" temp
- else
- sed -i 's/isdefault="1"/isdefault="0"/g' temp
- sed -i "1i\ $serverInfo" temp
- fi
- fi
- #no server list in /etc/cdp/config.xml
- else
- if [ -n "$SERVERIP" ]; then
- echo " $serverInfo" >>temp
- fi
- fi
- #add new server list to config.xml
- chmod 644 $TMPDIR/config.xml
- sed -i '/<AgentConfig*/ r temp' $TMPDIR/config.xml
- rm -rf temp
- #you do not input the --serverip option, do following
- elif [ -n "$SERVERIP" ]; then
- chmod 644 $TMPDIR/config.xml
- sed -i "/<AgentConfig*/ a\ $serverInfo" $TMPDIR/config.xml
- fi
- #here is modified by Jowis to update serverList in config.xml, end
- cp $TMPDIR/config.xml /etc/cdp/config.xml && chmod 777 /etc/cdp/config.xml
- cp $TMPDIR/version /etc/cdp/version
- cp $TMPDIR/lib/* /usr/lib/cdp/. && chmod 644 /usr/lib/cdp/*
- cp $TMPDIR/lib/libbotan-1.10.so.0 /usr/lib/libbotan-1.10.so.0 && chmod 644 /usr/lib/libbotan-1.10.so.0
- }
- check_src()
- {
- echo "Verifying install package..." | tee -a ${LOGFILE}
- [ -f $SRCPKG ] || die "Installation failed. $SRCPKG is missing!"
- local f
- local missing=
- for f in config.xml pidof shm_cleanup snwlget tput AdobeAIRInstaller.bin autoupdate.sh functions vars watchdog.sh patchnow version cdpagentservice cdpdaemon.redhat cdpdaemon.suse cdpdaemon.debian cdpagentd cdpagentproxyd cdpagentproxy cdpcli CDPAgentTool.desktop FlexAgentApp32.png;
- do
- tar tzf $SRCPKG $f > /dev/null || missing="$missing $f"
- done
- [ "$missing" == "" ] ||
- die "Installation failed. The following source file(s) can't be found:$missing"
- }
- check_running()
- {
- if ps -Ao comm | grep cdpagenttool > /dev/null; then
- confirm "The CDPAgentTool is running. Do you want to stop it? [y/n]" ||
- die "Installation aborted."
- pid=`ps -C cdpagenttool -o pid,args | grep cdpagenttool | awk '{print $1}'`
- kill -TERM $pid && echo "Stop CDPAgentTool Success" | tee -a ${LOGFILE}
- fi
- if ps -Ao comm | grep cdpagentproxy > /dev/null; then
- confirm "The CDPAgentProxy process is running. Do you want to stop it? [y/n]" ||
- die "Installation aborted."
- /etc/init.d/cdpagentproxyd stop | tee -a ${LOGFILE}
- fi
- if ps -Ao comm | grep cdpagentservice > /dev/null; then
- confirm "The CDPBackupService process is running. Do you want to stop it? [y/n]" ||
- die " Installation aborted."
- /etc/init.d/cdpagentd stop | tee -a ${LOGFILE}
- fi
- }
- check_installed()
- {
- echo "Checking for previous installation..." | tee -a ${LOGFILE}
- local instscript=
- if [ -f /usr/bin/cdp/cdpinstall.sh ]; then
- instscript=/usr/bin/cdp/cdpinstall.sh
- elif [ -f /sbin/cdp/cdpinstall.sh ]; then
- instscript=/sbin/cdp/cdpinstall.sh
- #no cdpagent installed in you computer, we will return here
- else
- check_running
- return
- fi
- #check installed pkg version
- get_old_pkg_version
- get_new_pkg_version
- if [ "$VERSION_OLD" != "$VERSION_NEW" ]; then
- echo "You currently have version '$VERSION_OLD' installed." | tee -a ${LOGFILE}
- else
- echo "The current version '$VERSION_NEW' is already installed." | tee -a ${LOGFILE}
- fi
- confirm "Would you like to uninstall the current version and proceed with the install? [y/n] " ||
- die "No install actions performed. The current version must be uninstalled first. "
- uninstall
- }
- prep_install()
- {
- echo "Preparing to install CDP Tools..." | tee -a ${LOGFILE}
- rm -f /etc/cdp/version
- rm -rf $INSTALLDIR/cdp
- rm -rf /usr/lib/cdp
- mkdir -p $INSTALLDIR/cdp 2>&1 | tee -a ${LOGFILE}
- mkdir -p $INSTALLDIR/cdp/watchdog 2>&1 | tee -a ${LOGFILE}
- mkdir -p $INSTALLDIR/cdp/watchdog/download 2>&1 | tee -a ${LOGFILE}
- mkdir -p $INSTALLDIR/cdp/watchdog/update 2>&1 | tee -a ${LOGFILE}
- mkdir -p /etc/cdp 2>&1 | tee -a ${LOGFILE}
- mkdir -p /usr/bin/cdp 2>&1 | tee -a ${LOGFILE}
- mkdir -p /usr/lib/cdp 2>&1 | tee -a ${LOGFILE}
- mkdir -p /var/log/cdp 2>&1 | tee -a ${LOGFILE}
- chmod a+rwx /var/log/cdp
- chmod a+w /etc/cdp
- mkdir -p $TMPDIR 2>&1 | tee -a ${LOGFILE}
- cd $TMPDIR
- tar zxf $SRCPKG >/dev/null 2>&1 | tee -a ${LOGFILE}
- lib_config_install
- }
- install_daemon()
- {
- echo "Installing CDP Agent Daemons..." | tee -a ${LOGFILE}
- cp $TMPDIR/$CDPAUTOUPDATE $INSTALLDIR/cdp/cdpautoupdate && chmod 744 $INSTALLDIR/cdp/cdpautoupdate
- cp $TMPDIR/autoupdate.sh $INSTALLDIR/cdp/autoupdate.sh && chmod 744 $INSTALLDIR/cdp/autoupdate.sh
- cp $TMPDIR/$CDPAGENTSERVICE $INSTALLDIR/cdp/cdpagentservice && chmod 744 $INSTALLDIR/cdp/cdpagentservice
- cp $TMPDIR/$CDPAGENTPROXY $INSTALLDIR/cdp/$CDPAGENTPROXY && chmod $ACCESSMODE $INSTALLDIR/cdp/$CDPAGENTPROXY
- cp $TMPDIR/watchdog.sh $INSTALLDIR/cdp/watchdog/watchdog.sh && chmod 744 $INSTALLDIR/cdp/watchdog/watchdog.sh
- cp $TMPDIR/functions $INSTALLDIR/cdp/watchdog/functions && chmod 744 $INSTALLDIR/cdp/watchdog/functions
- cp $TMPDIR/patchnow $INSTALLDIR/cdp/watchdog/patchnow && chmod 744 $INSTALLDIR/cdp/watchdog/patchnow
- cp $TMPDIR/version $INSTALLDIR/cdp/watchdog/version && chmod 744 $INSTALLDIR/cdp/watchdog/version
- cp $TMPDIR/vars $INSTALLDIR/cdp/watchdog/vars && chmod 744 $INSTALLDIR/cdp/watchdog/vars
- cp $TMPDIR/shm_cleanup $INSTALLDIR/cdp/shm_cleanup && chmod 744 $INSTALLDIR/cdp/shm_cleanup
- case $DIST in
- redhat | mandrake | turbo | caldera)
- cp $TMPDIR/cdpdaemon.redhat $INSTALLDIR/cdp/cdpdaemon && chmod 744 $INSTALLDIR/cdp/cdpdaemon
- cp $TMPDIR/cdpagentd /etc/rc.d/init.d/cdpagentd && chmod 744 /etc/rc.d/init.d/cdpagentd
- cp $TMPDIR/cdpagentproxyd /etc/rc.d/init.d/cdpagentproxyd && chmod 744 /etc/rc.d/init.d/cdpagentproxyd
- for level in 3 4 5;
- do
- ln -sf /etc/rc.d/init.d/cdpagentd /etc/rc.d/rc${level}.d/S99cdpagentd;
- ln -sf /etc/rc.d/init.d/cdpagentproxyd /etc/rc.d/rc${level}.d/S99cdpagentproxyd;
- done
- for level in 1 2 6;
- do
- ln -sf /etc/rc.d/init.d/cdpagentd /etc/rc.d/rc${level}.d/K99cdpagentd;
- ln -sf /etc/rc.d/init.d/cdpagentproxyd /etc/rc.d/rc${level}.d/K99cdpagentproxyd;
- done
- /etc/rc.d/init.d/cdpagentd start | tee -a ${LOGFILE}
- /etc/rc.d/init.d/cdpagentproxyd start | tee -a ${LOGFILE}
- ;;
- suse)
- cp $TMPDIR/cdpdaemon.suse $INSTALLDIR/cdp/cdpdaemon && chmod 744 $INSTALLDIR/cdp/cdpdaemon
- cp $TMPDIR/cdpagentd /etc/init.d/cdpagentd && chmod 744 /etc/init.d/cdpagentd
- cp $TMPDIR/cdpagentproxyd /etc/init.d/cdpagentproxyd && chmod 744 /etc/init.d/cdpagentproxyd
- for level in 3 4 5;
- do
- ln -sf /etc/init.d/cdpagentd /etc/init.d/rc${level}.d/S99cdpagentd;
- ln -sf /etc/init.d/cdpagentproxyd /etc/init.d/rc${level}.d/S99cdpagentproxyd;
- done
- for level in 1 2 6;
- do
- ln -sf /etc/init.d/cdpagentd /etc/init.d/rc${level}.d/K99cdpagentd;
- ln -sf /etc/init.d/cdpagentproxyd /etc/init.d/rc${level}.d/K99cdpagentproxyd;
- done
- /etc/init.d/cdpagentd start | tee -a ${LOGFILE}
- /etc/init.d/cdpagentproxyd start | tee -a ${LOGFILE}
- ;;
- debian)
- cp $TMPDIR/cdpdaemon.debian $INSTALLDIR/cdp/cdpdaemon && chmod 744 $INSTALLDIR/cdp/cdpdaemon
- cp $TMPDIR/cdpagentd /etc/init.d/cdpagentd && chmod 744 /etc/init.d/cdpagentd
- cp $TMPDIR/cdpagentproxyd /etc/init.d/cdpagentproxyd && chmod 744 /etc/init.d/cdpagentproxyd
- for level in 2 3 4 5;
- do
- ln -sf /etc/init.d/cdpagentd /etc/rc${level}.d/S99cdpagentd;
- ln -sf /etc/init.d/cdpagentproxyd /etc/rc${level}.d/S99cdpagentproxyd;
- done
- for level in 1 6 S;
- do
- ln -sf /etc/init.d/cdpagentd /etc/rc${level}.d/K99cdpagentd;
- ln -sf /etc/init.d/cdpagentproxyd /etc/rc${level}.d/K99cdpagentproxyd;
- done
- /etc/init.d/cdpagentd start | tee -a ${LOGFILE}
- /etc/init.d/cdpagentproxyd start | tee -a ${LOGFILE}
- ;;
- esac
- }
- install_utilities()
- {
- cp $TMPDIR/tput $INSTALLDIR/cdp/tput && chmod $ACCESSMODE $INSTALLDIR/cdp/tput
- cp $TMPDIR/pidof $INSTALLDIR/cdp/pidof && chmod $ACCESSMODE $INSTALLDIR/cdp/pidof
- cp $TMPDIR/snwlget $INSTALLDIR/cdp/snwlget && chmod $ACCESSMODE $INSTALLDIR/cdp/snwlget
- }
- install_agent_tool()
- {
- echo "Installing CDP Agent Tool..." | tee -a ${LOGFILE}
- #install Adobe AIR
- $TMPDIR/AdobeAIRInstaller.bin -silent -eulaAccepted | tee -a ${LOGFILE}
- if [ -s "/opt/Adobe AIR" ]; then
- cp -r $TMPDIR/CDPAgentTool $INSTALLDIR/cdp/ && chmod -R $ACCESSMODE $INSTALLDIR/cdp/CDPAgentTool
- else
- die "Adobe AIR Installation fails..."
- fi
- cp $TMPDIR/FlexAgentApp32.png $INSTALLDIR/cdp/FlexAgentApp32.png
- cp $TMPDIR/CDPAgentTool.desktop $INSTALLDIR/cdp/CDPAgentTool.desktop
- cp $TMPDIR/cdpcli $INSTALLDIR/cdp/cdpcli && chmod $ACCESSMODE $INSTALLDIR/cdp/cdpcli
- ln -s $INSTALLDIR/cdp/CDPAgentTool/bin/CDPAgentTool $INSTALLDIR/cdpagenttool && chmod $ACCESSMODE $INSTALLDIR/cdpagenttool
- #create desktop icon
- if [ "$ACCESSTYPE" = "all" ]; then
- #add agenttool icon to all users in /home
- for i in /home/*;
- do
- #avoid creating symbolic link in /home/lost+found if this dir exists
- [ "$i" == "/home/lost+found" ] && continue
- ln -sf $INSTALLDIR/cdp/CDPAgentTool.desktop $i/Desktop/CDPAgentTool.desktop && chmod 777 /$i/Desktop/CDPAgentTool.desktop
- done
- #add agenttool icon to root desktop
- if [ -d /root/Desktop ]; then
- ln -sf $INSTALLDIR/cdp/CDPAgentTool.desktop /root/Desktop/CDPAgentTool.desktop && chmod 744 /root/Desktop/CDPAgentTool.desktop
- fi
- else
- #access type is root, we need to modify the properties of desktop icon to avoid invalid command path
- sed -i 's/usr\/bin/sbin/g' $INSTALLDIR/cdp/CDPAgentTool.desktop
- ln -sf $INSTALLDIR/cdp/CDPAgentTool.desktop /root/Desktop/CDPAgentTool.desktop && chmod 744 /root/Desktop/CDPAgentTool.desktop
- fi
- }
- uninstall()
- {
- confirm "Are you sure you want to uninstall the CDP Agent Tool? [y/n]" || exit 1
- check_running
- echo "Uninstalling CDP Agent Tool..." | tee -a ${LOGFILE}
- # uninstall service
- case $DIST in
- redhat | mandrake | turbo | caldera)
- rm -f /etc/rc.d/init.d/cdpagentd /etc/rc.d/rc?.d/[SK]99cdpagentd
- rm -f /etc/rc.d/init.d/cdpagentdproxyd /etc/rc.d/rc?.d/[SK]99cdpagentproxyd
- ;;
- suse)
- rm -f /etc/init.d/cdpagentd /etc/init.d/rc?.d/[SK]99cdpagentd
- rm -f /etc/init.d/cdpagentproxyd /etc/init.d/rc?.d/[SK]99cdpagentproxyd
- ;;
- debian)
- rm -f /etc/init.d/cdpagentd /etc/rc?.d/[SK]99cdpagentd
- rm -f /etc/init.d/cdpagentproxyd /etc/rc?.d/[SK]99cdpagentproxyd
- ;;
- esac
- rm -f /etc/cdp/version
- rm -rf /usr/bin/cdp
- rm -rf /sbin/cdp
- rm -rf /usr/lib/cdp
- rm -f /usr/bin/cdpagenttool
- rm -f /sbin/cdpagenttool
- for i in /home/*;
- do
- rm -f $i/Desktop/CDPAgentTool.desktop;
- done
- [ -d /root/Desktop ] && rm -f /root/Desktop/CDPAgentTool.desktop
- }
- remove_tmpdir()
- {
- echo "Removing temporary directory..." | tee -a ${LOGFILE}
- rm -rf $TMPDIR
- }
- install_success()
- {
- get_installed_version
- echo "CDPAgentTool $VERSION has been installed successfully..." | tee -a ${LOGFILE}
- echo "Type \"cdpagenttool\" to start CDPAgentTool." | tee -a ${LOGFILE}
- echo "Or use the Desktop icon to start CDPAgentTool." | tee -a ${LOGFILE}
- }
- #here is added by Jowis, begin
- check_ipAddr()
- {
- local serverip=$1
- local ip_byte1=0
- local ip_byte2=0
- local ip_byte3=0
- local ip_byte4=0
- if [ -z "$serverip" ]; then
- echo "IP address is null, use a line like --serverip=10.10.10.10" | tee -a ${LOGFILE}
- return 1
- else
- temp_str=`echo $serverip | sed 's/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$//'`
- if [ -z "$temp_str" ]; then
- ip_byte1=`echo $serverip | cut -f 1 -d "."`
- ip_byte2=`echo $serverip | cut -f 2 -d "."`
- ip_byte3=`echo $serverip | cut -f 3 -d "."`
- ip_byte4=`echo $serverip | cut -f 4 -d "."`
- [ $ip_byte1 -le 255 ] && [ $ip_byte2 -le 255 ] && [ $ip_byte3 -le 255 ] && [ $ip_byte4 -le 255 ] && return 0
- return 1
- else
- return 1
- fi
- fi
- }
- check_log_file()
- {
- #check whether the log dir exists or not
- if [ ! -d /var/log/cdp ]; then
- mkdir -p /var/log/cdp
- fi
- #add current time to log file
- local curTime=`date +"Time: %F %T"`
- echo "$curTime execute cdpinstall.sh..." > ${LOGFILE}
- }
- parse_command()
- {
- #argument number is valid?
- [ $# -eq 0 ] && { echo "Failed, command parameter is null!" | tee -a ${LOGFILE}; usage; }
- [ $# -gt 4 ] && { echo "Failed, invalid parameter number!" | tee -a ${LOGFILE}; usage; }
- #retrieve command and options
- for loop in $*
- do
- case $1 in
- -i|-d|-a|-u|-v|--version)
- if [ -n "$commands" ] ; then
- echo "Failed, commands $commands and $1 can not used at the same time!" | tee -a ${LOGFILE}
- usage
- fi
- commands=$1
- shift;;
- --access=all)
- ACCESSTYPE="all"
- shift;;
- --serverip=*)
- SERVERIP=${1#"--serverip="}
- check_ipAddr "$SERVERIP" || { echo "Failed, invalid IP address!" | tee -a ${LOGFILE}; usage; }
- shift;;
- --autoUpdate)
- AutoUpdateFlag="true"
- MODE="non-interactive"
- shift;;
- -y|-Y)
- MODE="non-interactive"
- shift;;
- *)
- echo "Failed, invalid command or option: $1" | tee -a ${LOGFILE}
- usage;;
- esac
- done
- #has invalid command?
- [ "$commands" == "" ] && { echo "Failed, no command found!" | tee -a ${LOGFILE}; usage; }
- }
- get_last_used_options()
- {
- echo "You did not enter any input command parameters, Get the last used parameters from /etc/cdp/install_params if it exists" | tee -a ${LOGFILE}
- if [ -s /etc/cdp/install_params ]; then
- read argument </etc/cdp/install_params
- echo "Current command parameters will be set to \"$argument\"" | tee -a ${LOGFILE}
- else
- echo "File /etc/cdp/install_params does not exist, Please refer to the usage summary." | tee -a ${LOGFILE}
- fi
- }
- save_last_used_options()
- {
- #no need to save in case of get version or autoupdate
- [ "$commands" == "-v" ] && return
- [ "$commands" == "--version" ] && return
- [ "$commands" == "-u" ] && return
- [ "$AutoUpdateFlag" == "true" ] && return
- if [ ! -d /etc/cdp ]; then
- mkdir -p /etc/cdp
- fi
- #save commands and options to file
- echo "$argument" >/etc/cdp/install_params
- echo "Saving current command parameters to file /etc/cdp/install_params" | tee -a ${LOGFILE}
- }
- #here is added by Jowis, end
- ########################################################################
- #check whether we support current OS distribution or not
- distinfo
- #check and add current time to log
- check_log_file
- #if no input command and options, retrieve last used to $argument
- argument=$*
- [ $# -eq 0 ] && get_last_used_options
- #parse and do command and options checking
- parse_command $argument
- #save current command and options
- [ $# -ne 0 ] && save_last_used_options
- #set install path according to access type
- setinstallpath
- #exit 0
- #core installation procedure
- case $commands in
- -i)
- check_src
- check_installed
- prep_install
- install_utilities
- install_daemon
- install_agent_tool
- remove_tmpdir
- install_success
- ;;
- -u)
- uninstall
- ;;
- -d)
- check_src
- check_installed
- prep_install
- install_daemon
- remove_tmpdir
- ;;
- -a)
- check_src
- check_installed
- prep_install
- install_agent_tool
- remove_tmpdir
- ;;
- -v|--version)
- get_installed_version && echo $VERSION
- ;;
- *)
- usage
- ;;
- esac
- exit 0
- ######################################################################
Add Comment
Please, Sign In to add comment