shell打包脚本(go)

#!/bin/bash
version="0.9"
main_file="monitor.go"
target_dir="./outputdir/"
target_file=""
include_resource="eagle.properties log.properties start.sh stop.sh"
rm -rf $target_dir*
if [ ! -x "$target_dir" ]; then 
	mkdir  -p "$target_dir" 
fi 
if [ -z $target_file ];then
	target_file=${main_file%".go"*}
fi
build_command="go build -o $target_dir$target_file $main_file"
echo $build_command
$build_command
cp -r $include_resource $target_dir
cd $target_dir
tar zcvf $target_file-$version.tar.gz *
cd -
#!/bin/bash
current_path=`pwd`
case "`uname`" in
    Linux)
		bin_abs_path=$(readlink -f $(dirname $0))
		;;
	*)
		bin_abs_path=`cd $(dirname $0); pwd`
		;;
esac

if [ -f $bin_abs_path/pid ] ; then
	echo "found pid:`cat $bin_abs_path/pid` , Please run stop.sh first ,then startup.sh" 2>&2
    exit 1
fi
nohup $bin_abs_path/monitor  1>>$bin_abs_path/nohup.out 2>&1 & 
echo $! > $bin_abs_path/pid 
echo "start successfully!"

  

#!/bin/bash
current_path=`pwd`
case "`uname`" in
    Linux)
		bin_abs_path=$(readlink -f $(dirname $0))
		;;
	*)
		bin_abs_path=`cd $(dirname $0); pwd`
		;;
esac
echo $bin_abs_path
if [ -f $bin_abs_path/pid ] ; then
	kill  `cat $bin_abs_path/pid`
	echo "stop successfully!"
else 
	echo "not found $bin_abs_path/pid!"
fi
rm $bin_abs_path/pid 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值