Search code examples
bashscriptinggnu-makeconfigurenagios

How to execute "make; make install" inside a bash script?


I need to automate the installation of the NRPE agent inside a bash script. How do I "make; make install" in a remote directory? Here's the code so far:

#!/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/

So after the "configure" part ends I need to execute "make; make install". Also, is there any way to optimize the current script?


Solution

  • This might help with Khanna111's hint:

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