【问题标题】:How to execute "make; make install" inside a bash script?如何在 bash 脚本中执行“make; make install”?
【发布时间】:2019-08-18 19:51:46
【问题描述】:

我需要在 bash 脚本中自动安装 NRPE 代理。如何在远程目录中“制作;制作安装”?到目前为止的代码如下:

#!/bin/bash

for f in *.tar.gz
do
    tar zxf "$f" -C /home/$USER/
done

sudo useradd -s /sbin/nologin -M nagios

/home/$USER/nagios-plugins-2.2.1/configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib64/

所以在“配置”部分结束后,我需要执行“make; make install”。另外,有没有办法优化当前脚本?

【问题讨论】:

  • 记得检查已执行命令的状态并正确进行
  • 修复了“当前用户”。真的不知道为什么我首先添加它。
  • @Khanna111 你能详细说明一下吗?
  • 希望任何 tar 文件中都没有 .ssh/authorized_keys 文件。
  • @eckes 我为 NRPE 安装文件使用专用文件夹

标签: bash scripting gnu-make configure nagios


【解决方案1】:

这可能对Khanna111's hint 有所帮助:

cd /home/$USER/nagios-plugins-2.2.1 || exit 1
configure <options> && make && sudo make install

【讨论】:

  • 所以如果我在脚本中“cd”,它将从它更改到的目录中运行?
  • 是的,无论您使用哪种操作系统。
猜你喜欢
  • 1970-01-01
  • 2017-06-16
  • 1970-01-01
  • 1970-01-01
  • 2018-04-18
  • 1970-01-01
  • 2011-02-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多