main.sh
#!/bin/sh CDIR=`pwd` INSTALLDIR=$CDIR/IVFireService if [ -d "$INSTALLDIR" ]; then echo "${INSTALLDIR} is exists" cd "$INSTALLDIR" echo "cd ${INSTALLDIR}" echo "$(pwd)" echo "sudo ./ServiceUninstall.sh" sudo ./ServiceUninstall.sh cd .. echo "cd .." rm -rf "$INSTALLDIR" echo "rm -rf ${INSTALLDIR}" fi #********************************************************* ARCHIVE=`awk '/^__ARCHIVE_BOUNDARY__/ { print NR + 1; exit 0; }' $0` #可执行脚本和压缩包的分界线 tail -n +$ARCHIVE $0 > IVFireService.tar.gz #生成压缩包 tar -zxvf IVFireService.tar.gz sudo rm IVFireService.tar.gz cd ${INSTALLDIR} pwd sudo chmod 777 *.sh sudo ./ServiceInstall.sh exit 0 __ARCHIVE_BOUNDARY__
make_run.sh
#!/bin/bash cur_date="ver1.b.`date +%Y.%m.%d`" # echo ${cur_date} value=`cat /etc/issue` array=(${value// / }) SystemVersion="${array[0]}_${array[1]}_${array[2]}_$(arch)" echo ${SystemVersion} gzFileName="IVFireService.${cur_date}.tar.gz" runfile="IVFireService_${SystemVersion}.${cur_date}.run" tar -zcvf ${gzFileName} IVFireService cat main.sh ${gzFileName} >${runfile} sudo chmod +x ${runfile} rm ${gzFileName}