Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2019
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 8.87 KB | None | 0 0
  1. leha@laptop:~/Downloads/anyconnect-linux64-4.4.03034/nvm$ cat ./nvm_install.sh
  2. #!/bin/sh
  3. #
  4.  
  5. BASH_BASE_SIZE=0x00000000
  6. CISCO_AC_TIMESTAMP=0x0000000000000000
  7. CISCO_AC_OBJNAME=1234567890123456789012345678901234567890123456789012345678901234
  8. # BASH_BASE_SIZE=0x00000000 is required for signing
  9. # CISCO_AC_TIMESTAMP is also required for signing
  10. # comment is after BASH_BASE_SIZE or else sign tool will find the comment
  11.  
  12. TARROOT="nvm"
  13. INSTPREFIX=/opt/cisco/anyconnect
  14. BINDIR=${INSTPREFIX}/bin
  15. LIBDIR=${INSTPREFIX}/lib
  16. NVMDIR=${INSTPREFIX}/NVM
  17. TMPNVMDIR=${INSTPREFIX}/NVM.tmp
  18. PLUGINDIR=${BINDIR}/plugins
  19. UNINST=${BINDIR}/nvm_uninstall.sh
  20. VPNUNINSTALLSCRIPT=${BINDIR}/vpn_uninstall.sh
  21. INSTALL=install
  22. MARKER=$((`grep -an "[B]EGIN\ ARCHIVE" $0 | cut -d ":" -f 1` + 1))
  23. MARKER_END=$((`grep -an "[E]ND\ ARCHIVE" $0 | cut -d ":" -f 1` - 1))
  24. LOGFNAME=`date "+anyconnect-linux64-4.4.03034-nvm-install-%H%M%S%d%m%Y.log"`
  25. CLIENTNAME="Cisco AnyConnect Network Visibility Client"
  26. VPNMANIFEST="/opt/cisco/anyconnect/ACManifestVPN.xml"
  27. KDFSRCTARFILE="ac_kdf_src.tar.gz"
  28.  
  29. echo "Installing ${CLIENTNAME}..."
  30. echo "Installing ${CLIENTNAME}..." > /tmp/${LOGFNAME}
  31. echo `whoami` "invoked $0 from " `pwd` " at " `date` >> /tmp/${LOGFNAME}
  32.  
  33. #Set a trap so that the log file is moved to ${INSTPREFIX}/. in any exit path
  34. trap 'mv /tmp/${LOGFNAME} ${INSTPREFIX}/.' EXIT
  35.  
  36. # Make sure we are root
  37. if [ `id | sed -e 's/(.*//'` != "uid=0" ]; then
  38.   echo "Sorry, you need super user privileges to run this script."
  39.   exit 1
  40. fi
  41.  
  42. # NVM requires VPN to be installed. We check the presence of the vpn uninstall script to check if it is installed.
  43. if [ ! -f ${VPNUNINSTALLSCRIPT} ]; then
  44.     echo "VPN should be installed before NVM installation. Install VPN to proceed."
  45.     echo "Exiting now."
  46.     exit 1
  47. fi
  48.  
  49. ## The web-based installer used for VPN client installation and upgrades does
  50. ## not have the license.txt in the current directory, intentionally skipping
  51. ## the license agreement. Bug CSCtc45589 has been filed for this behavior.  
  52. if [ -f "license.txt" ]; then
  53.     cat ./license.txt
  54.     echo
  55.     echo -n "Do you accept the terms in the license agreement? [y/n] "
  56.     read LICENSEAGREEMENT
  57.     while :
  58.     do
  59.       case ${LICENSEAGREEMENT} in
  60.            [Yy][Ee][Ss])
  61.                    echo "You have accepted the license agreement."
  62.                    echo "Please wait while ${CLIENTNAME} is being installed..."
  63.                    break
  64.                    ;;
  65.            [Yy])
  66.                    echo "You have accepted the license agreement."
  67.                    echo "Please wait while ${CLIENTNAME} is being installed..."
  68.                    break
  69.                    ;;
  70.            [Nn][Oo])
  71.                    echo "The installation was cancelled because you did not accept the license agreement."
  72.                    exit 1
  73.                    ;;
  74.            [Nn])
  75.                    echo "The installation was cancelled because you did not accept the license agreement."
  76.                    exit 1
  77.                    ;;
  78.            *)    
  79.                    echo "Please enter either \"y\" or \"n\"."
  80.                    read LICENSEAGREEMENT
  81.                    ;;
  82.       esac
  83.     done
  84. fi
  85. if [ "`basename $0`" != "nvm_install.sh" ]; then
  86.   if which mktemp >/dev/null 2>&1; then
  87.     TEMPDIR=`mktemp -d /tmp/nvm.XXXXXX`
  88.     RMTEMP="yes"
  89.   else
  90.     TEMPDIR="/tmp"
  91.     RMTEMP="no"
  92.   fi
  93. else
  94.   TEMPDIR="."
  95. fi
  96.  
  97. # In upgrades, build_ac_ko.sh & kdf src tar file should be deleted from NVM dir,
  98. # before moving NVM files to temp dir.
  99. if [ -f ${NVMDIR}/${KDFSRCTARFILE} ]; then
  100.   echo "rm -f ${NVMDIR}/${KDFSRCTARFILE}" >> /tmp/${LOGFNAME}
  101.   rm -f ${NVMDIR}/${KDFSRCTARFILE} >> /tmp/${LOGFNAME} 2>&1
  102. fi
  103.  
  104. if [ -f ${NVMDIR}/build_ac_ko.sh ]; then
  105.   echo "rm -f ${NVMDIR}/build_ac_ko.sh" >> /tmp/${LOGFNAME}
  106.   rm -f ${NVMDIR}/build_ac_ko.sh >> /tmp/${LOGFNAME} 2>&1
  107. fi
  108.  
  109. # In upgrades, NVM files will be copied to a temp directory and moved back
  110. if [ -d ${NVMDIR} ]; then
  111.   echo "mv -f ${NVMDIR} ${TMPNVMDIR}" >> /tmp/${LOGFNAME}
  112.   mv -f ${NVMDIR} ${TMPNVMDIR} >> /tmp/${LOGFNAME} 2>&1
  113. fi
  114.  
  115. #
  116. # Check for and uninstall any previous version.
  117. #
  118. if [ -x "${UNINST}" ]; then
  119.   echo "Removing previous installation..."
  120.   echo "Removing previous installation: ${UNINST}" >> /tmp/${LOGFNAME}
  121.   if ! ${UNINST}; then
  122.     echo "Error removing previous installation!  Continuing..."
  123.     echo "Error removing previous installation!  Continuing..." >> /tmp/${LOGFNAME}
  124.   fi
  125. fi
  126.  
  127. if [ "${TEMPDIR}" != "." ]; then
  128.   TARNAME=`date +%N`
  129.   TARFILE=${TEMPDIR}/nvminst${TARNAME}.tgz
  130.  
  131.   echo "Extracting installation files to ${TARFILE}..."
  132.   echo "Extracting installation files to ${TARFILE}..." >> /tmp/${LOGFNAME}
  133.   # "head --bytes=-1" used to remove '\n' prior to MARKER_END
  134.   head -n ${MARKER_END} $0 | tail -n +${MARKER} | head --bytes=-1 2>> /tmp/${LOGFNAME} > ${TARFILE} || exit 1
  135.  
  136.   echo "Unarchiving installation files to ${TEMPDIR}..."
  137.   echo "Unarchiving installation files to ${TEMPDIR}..." >> /tmp/${LOGFNAME}
  138.   tar xvzf ${TARFILE} -C ${TEMPDIR} >> /tmp/${LOGFNAME} 2>&1 || exit 1
  139.  
  140.   rm -f ${TARFILE}
  141.  
  142.   NEWTEMP="${TEMPDIR}/${TARROOT}"
  143. else
  144.   NEWTEMP="."
  145. fi
  146.  
  147. # version of NVM being installed has to be same as installed VPN version
  148.  
  149. if [ -f "${NEWTEMP}/ACManifestNVM.xml" ] && [ -f ${VPNMANIFEST} ]; then
  150.     VPNVERSION=$(sed -n '/VPNCore/{ s/<file .*version="//; s/".*$//; p; }' ${VPNMANIFEST})
  151.     NVMVERSION=$(sed -n '/NVM/{ s/<file .*version="//; s/".*$//; p; }' "${NEWTEMP}/ACManifestNVM.xml")
  152.  
  153.     if [ ${VPNVERSION} != ${NVMVERSION} ]; then
  154.         echo "Version ${NVMVERSION} of the Cisco AnyConnect VPN is required to install this package."
  155.         echo "Version ${NVMVERSION} of the Cisco AnyConnect VPN is required to install this package." >> /tmp/${LOGFNAME}
  156.         echo "Exiting now."
  157.         echo "Exiting now." >> /tmp/${LOGFNAME}
  158.         exit 1
  159.     fi
  160. fi
  161.  
  162. # build KDF first, if .ko doesn't exist.
  163. cd ${NEWTEMP}
  164. ACKDFKO="ac_kdf.ko"
  165. if [ ! -f "${ACKDFKO}" ]; then
  166.    echo "Starting to build AnyConnect Kernel Module..."
  167.    echo "./build_ac_ko.sh build `pwd`" >> /tmp/${LOGFNAME}
  168.    ./build_ac_ko.sh build `pwd` >> /tmp/${LOGFNAME} 2>&1
  169.    if [ $? != 0 ]; then
  170.        echo "Failed to build AnyConnect Kernel module."
  171.        echo "Exiting now."
  172.        exit 1
  173.    else
  174.        echo "AnyConnect Kernel module built successfully."
  175.    fi
  176. fi
  177.  
  178. # Return to previous directory.
  179. cd -
  180.  
  181. # Make sure destination directories exist
  182. # Since vpn installer creates these directories need to revisit
  183.  
  184. echo "Installing "${BINDIR} >> /tmp/${LOGFNAME}
  185. ${INSTALL} -d ${BINDIR} || exit 1
  186. echo "Installing "${LIBDIR} >> /tmp/${LOGFNAME}
  187. ${INSTALL} -d ${LIBDIR} || exit 1
  188. echo "Installing "${NVMDIR} >> /tmp/${LOGFNAME}
  189. ${INSTALL} -d ${NVMDIR} || exit 1
  190. echo "Installing "${PLUGINDIR} >> /tmp/${LOGFNAME}
  191. ${INSTALL} -d ${PLUGINDIR} || exit 1
  192.  
  193. # Copy KDF source & build_ac_kdf_ko.sh to NVM dir.
  194. if [ -d ${NVMDIR} ]; then
  195.    echo "cp -af ${NEWTEMP}/${KDFSRCTARFILE} ${NVMDIR}" >> /tmp/${LOGFNAME}
  196.    cp -af ${NEWTEMP}/${KDFSRCTARFILE} ${NVMDIR} >> /tmp/${LOGFNAME}
  197.  
  198.    echo "cp -af ${NEWTEMP}/build_ac_kdf_ko.sh ${NVMDIR}" >> /tmp/${LOGFNAME}
  199.    cp -af ${NEWTEMP}/build_ac_ko.sh ${NVMDIR} >> /tmp/${LOGFNAME}
  200. fi
  201.  
  202. echo "Installing "${NEWTEMP}/nvm_uninstall.sh >> /tmp/${LOGFNAME}
  203. ${INSTALL} -o root -m 755 ${NEWTEMP}/nvm_uninstall.sh ${BINDIR} || exit 1
  204.  
  205. echo "Installing "${NEWTEMP}/acnvmagent >> /tmp/${LOGFNAME}
  206. ${INSTALL} -o root -m 755 ${NEWTEMP}/acnvmagent ${BINDIR} || exit 1
  207.  
  208. echo "Installing "${NEWTEMP}/${ACKDFKO} >> /tmp/${LOGFNAME}
  209. ${INSTALL} -o root -m 755 ${NEWTEMP}/${ACKDFKO} ${BINDIR} || exit 1
  210.  
  211. echo "Installing "${NEWTEMP}/libsock_fltr_api.so >> /tmp/${LOGFNAME}
  212. ${INSTALL} -o root -m 755 ${NEWTEMP}/libsock_fltr_api.so ${LIBDIR} || exit 1
  213.  
  214. echo "Installing "${NEWTEMP}/plugins/libacnvmctrl.so >> /tmp/${LOGFNAME}
  215. ${INSTALL} -o root -m 755 ${NEWTEMP}/plugins/libacnvmctrl.so ${PLUGINDIR} || exit 1
  216.  
  217. if [ -f "${NEWTEMP}/ACManifestNVM.xml" ]; then
  218.  echo "Installing "${NEWTEMP}/ACManifestNVM.xml >> /tmp/${LOGFNAME}
  219.  ${INSTALL} -o root -m 444 ${NEWTEMP}/ACManifestNVM.xml ${INSTPREFIX} || exit 1
  220. else
  221.  echo "${NEWTEMP}/ACManifestNVM.xml does not exist. It will not be installed."
  222. fi
  223.  
  224. # Generate/update the VPNManifest.dat file
  225. if [ -f ${BINDIR}/manifesttool ]; then 
  226.  ${BINDIR}/manifesttool -i ${INSTPREFIX} ${INSTPREFIX}/ACManifestNVM.xml
  227. fi
  228.  
  229. if [ "${RMTEMP}" = "yes" ]; then
  230.  echo rm -rf ${TEMPDIR} >> /tmp/${LOGFNAME}
  231.  rm -rf ${TEMPDIR}
  232. fi
  233.  
  234. # In upgrades, we restore the NVM directory from the temp dir
  235. if [ -d ${TMPNVMDIR} ]; then
  236.  echo "Moving NVM config files back to NVM directory" >> /tmp/${LOGFNAME}
  237.  mkdir -p ${NVMDIR}
  238.  tar cf - -C ${TMPNVMDIR} . | (cd ${NVMDIR}; tar xf -) >> /tmp/${LOGFNAME} 2>&1
  239.  rm -rf ${TMPNVMDIR}
  240. fi
  241.  
  242.  
  243. echo "${CLIENTNAME} is installed successfully."
  244. echo "${CLIENTNAME} is installed successfully." >> /tmp/${LOGFNAME}
  245.  
  246. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement