#!/bin/bash # script to update GNS3 apps apps=`cat <${gitlog} 2>&1 retval=$? gitstat=$(egrep 'Checking connectivity... done.' ${gitlog} | wc -l) pushd ${app} >/dev/null 2>&1 else pull=1 pushd ${app} >/dev/null 2>&1 git pull >${gitlog} 2>&1 retval=$? gitstat=$(egrep 'up-to-date' ${gitlog} | wc -l) fi else if [ ! -d ${app} ]; then echo "Skipping ${app} as there is no local repo..." else pushd ${app} >/dev/null 2>&1 fi # we are only running this to recompile the current source tree gitstat=1 retval=0 fi if [ ${gitstat} -ne 0 ] && [ ${recompile} -eq 0 ]; then echo "${app} up-to-date..." popd >/dev/null 2>&1 continue else echo "Compiling and installing ${app}..." fi if [ ${retval} -ne 0 ]; then echo "###############################################################" if [ ${clone} -eq 1 ]; then echo "# Errors encountered while cloning git repo for ${app}" elif [ ${pull} -eq 1 ]; then echo "# Errors encountered while updating git repo for ${app}" fi echo "###############################################################" popd >/dev/null 2>&1 continue else tmstmp="build-$(date '+%Y%m%d-%H%M%S')" movealong=0 case ${app} in vboxwrapper) retval=1 while [ ${retval} -ne 0 ]; do echo "### PYTHON2 ###" > ${tmstmp}.log sudo python2 setup.py install >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then popd >/dev/null 2>&1 echo "Failed python2 setup.py install for ${app}..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi ;; dynamips) [ -d build ] || mkdir build retval=1 while [ ${retval} -ne 0 ]; do echo "### CMAKE ###" > ${tmstmp}.log pushd build >/dev/null 2>&1 /bin/rm -rf * cmake .. >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then popd >/dev/null 2>&1 echo "Running cmake on Dynamips" echo "Failed cmake 5 times - intervention required..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi retval=1 while [ ${retval} -ne 0 ]; do echo "### MAKE ###" >> ${tmstmp}.log make >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed make for ${app}..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi retval=1 while [ ${retval} -ne 0 ]; do echo "### MAKE INSTALL ###" >> ${tmstmp}.log sudo make install >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed make install for ${app}..." movealong=1 break else sudo /sbin/setcap cap_net_raw,cap_net_admin=eip /usr/local/bin/dynamips fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi popd >/dev/null 2>&1 ;; iniparser) retval=1 while [ ${retval} -ne 0 ]; do echo "### CLEAN ###" > ${tmstmp}.log make clean >> ${tmstmp}.log 2>&1 echo "### MAKE ###" >> ${tmstmp}.log make >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed make install for ${app}..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi sudo cp -f libiniparser.* /usr/lib/ sudo cp -f src/iniparser.h /usr/local/include sudo cp -f src/dictionary.h /usr/local/include ;; iouyap) retval=1 while [ ${retval} -ne 0 ]; do echo "### MAKE ###" > ${tmstmp}.log make clean >> ${tmstmp}.log 2>&1 echo "### MAKE ###" >> ${tmstmp}.log make >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed make for ${app}..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi echo "### INSTALL ###" >> ${tmstmp}.log sudo make install >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed make install for ${app}..." movealong=1 fi if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue else chmod 755 iouyap sudo /bin/mv -f iouyap /usr/local/bin/ fi ;; gns3-gui|gns3-server) retval=1 while [ ${retval} -ne 0 ]; do echo "### PYTHON3 - ${app} ###" > ${tmstmp}.log sudo python3 setup.py install >> ${tmstmp}.log 2>&1 retval=$? if [ ${retval} -ne 0 ]; then echo "Failed python3 setup.py install for ${app}..." movealong=1 break fi done if [ ${movealong} -eq 1 ]; then popd >/dev/null 2>&1 continue fi ;; esac fi popd >/dev/null 2>&1 done