#!/bin/bash

FILE="fogvdn_PEAR_1900_X64_LINUX_524.tar.gz"

if [ "1$1" != "1" ]; then
  FILE="fogvdn_$1.tar.gz"
fi

if [ ! -f ${FILE} ]; then
  res=`wget http://47.52.153.245/test/${FILE}`
fi

if [ -f ${FILE} ]; then
  install_res=`tar -C / -zxvf ${FILE}`
  launch_res=`/etc/init.d/xc_cdn.sh restart`
  check_res=`ps -ef | grep pear_ | grep root`
  # echo ${check_res}
  if [[ -z ${check_res} ]]; then
    echo "install failed"
    exit 1
  fi
  echo "success"
else 
  echo "download failed"
fi
