1、必须root用户执行2、检查是否有安装logger没有提示安装;3、判断某个文件是否存在存在/不存在赋值给不同变量4、如果某个变量的值为yes则强制重新安装make install forcenouid : $(shell id -u) ifneq($(uid),0) $(error you must br root to run this script) endif has_logger : $(shell which logger 2/dev/null) ifneq($(has_logger),) $(error logger not install,eg: yum install rsyslog -y) endif target_file : /etc/target_file.conf ifneq($(wildcard $(target_file )),) file_exists : no else file_exists : yes endif force : no installstart-install ifeq ($(force),yes) $(info force install service) ... make install-service else ifeq($(file_exists),yes) $(info service is exists,skip install) ... else $(info install service) ... make install-service endif install-service: cp -f /src/xxx.sh /etc/xxx.sh chmod x /etc/xxx.sh start-install echo start install service // 常用于隐藏那些本身输出信息就足够清晰的命令