Page 1 of 1

bash script questions.

Posted: 2018/01/23 03:30:37
by supertight
I have a few commands I need to run after most installs. I wanted to setup a little script that would speed things up.

This is the set of commands.

Code: Select all

scl enable devtoolset-4 bash
cmake3 /home/xmr-stak
make /home/xmr-stak/install
I used vim and set the commands into xmr.install.sh with chmod +x
I think, but I'm not sure, the cmake3 command on line 3 isn't correct. Same with make install on line 4.

Code: Select all

#! /bin/bash
scl enable devtoolset-4 bash
cmake3 /home/xmr-stak
make install /home/xmr-stak/
I know I need something else so It all compiles and installs into the correct path. I don't know what that is. I also would like if the whole thing was verbose. Any help in the correct direction would be awesome. Thanks for reading.

Re: bash script questions.

Posted: 2018/01/23 12:50:21
by bertalanimre
What kind of install do you want to run these scripts after? Minimal probably doesn't have the required packages installed that are needed.

What I would do is as the 1st line, I would just install the dev-tools. Then I guess your other commands would run safe and sound too.

Add before your scl line:

Code: Select all

sudo yum group install "Development Tools"
If it still doesn't work, try:

Code: Select all

sudo yum groupinstall "Development Tools"
Also, shouldn't you add sudo before each line? Just asking. It is not always enough if you run the script file as sudo you know.

Re: bash script questions.

Posted: 2018/01/23 13:26:43
by TrevorH
Ideally what you'd do is learn about packaging and create your own rpm containing your app. If you distribute this in the way that you are now you'll end up with a development environment on all the boxes you install it on. With a package you'll have that on your build machine and nowhere else.

Re: bash script questions.

Posted: 2018/01/24 00:21:24
by supertight
bertalanimre wrote:What kind of install do you want to run these scripts after? Minimal probably doesn't have the required packages installed that are needed.

What I would do is as the 1st line, I would just install the dev-tools. Then I guess your other commands would run safe and sound too.

Add before your scl line:

Code: Select all

sudo yum group install "Development Tools"
If it still doesn't work, try:

Code: Select all

sudo yum groupinstall "Development Tools"
Also, shouldn't you add sudo before each line? Just asking. It is not always enough if you run the script file as sudo you know.

The kickstart file used for install already has all the items required for the commands listed. Thank you.

Re: bash script questions.

Posted: 2018/01/24 00:27:07
by supertight
TrevorH wrote:Ideally what you'd do is learn about packaging and create your own rpm containing your app. If you distribute this in the way that you are now you'll end up with a development environment on all the boxes you install it on. With a package you'll have that on your build machine and nowhere else.

I didn't know that was a possibility and I can work on that. I need a short term patch for now while I learn packaging. I have the kickstart file setup to provide all the proper dev packages on install.

The script as written does nothing. What should I add to it?

thanks for reading.

**EDIT**
A recommendation for packaging tutorial?

Re: bash script questions.

Posted: 2018/06/05 21:17:04
by aeugenegray
I found a work around for enabling scl's that require a bash command. I'm using devtoolset-4 here just because thats what I was using when I figured it out. Great for running in scripts.

echo 'source /opt/rh/devtoolset-4/enable' >> ~/.bashrc - (obviously adds it to .bashrc)
source ~/.bashrc - (reloads .bashrc without a reboot)

Hope its helpful to someone out there.

Re: bash script questions.

Posted: 2018/06/05 21:20:32
by aeugenegray
Additionally I have this already built for anyone having this issue specifically related to xmr-stak.

https://github.com/aeugenegray/stak.git

Re: bash script questions.

Posted: 2018/06/06 07:35:06
by jlehtone
supertight wrote:
2018/01/23 03:30:37
This is the set of commands.

Code: Select all

scl enable devtoolset-4 bash
cmake3 /home/xmr-stak
make /home/xmr-stak/install
I used vim and set the commands into xmr.install.sh with chmod +x
I think, but I'm not sure, the cmake3 command on line 3 isn't correct. Same with make install on line 4.
Yes, you do have an issue there.

Line 1 executes bash in devtoolset-4 environment. (Why the 4? That is old by now.)
In the script, once the bash completes,
Line 2 executes cmake3 in system default environment.
Line 3 executes make in system default environment.

If you do want to run SCL version of cmake3 and make, then you either make that bash run the commands,
or

Code: Select all

scl enable devtoolset-4 cmake3 /home/xmr-stak
scl enable devtoolset-4 make /home/xmr-stak/install

Edit:
Sourcing SCL environment in .bashrc can turn fatal.
For one, prepending to PATH will reoccur on every shell instance, not just in the login shell.

More importantly, you will always hide system default versions for your user. That might be tolerable with devtoolset, but imagine the consequences of enabling, say rh-python36. The 'yum' requires python 2.7. It does run /usr/bin/python, which is 2.7, but the rh-python36 prepends python 3.6's path to mess things up.

Re: bash script questions.

Posted: 2018/06/07 01:13:51
by aeugenegray
Edit:
Sourcing SCL environment in .bashrc can turn fatal.
For one, prepending to PATH will reoccur on every shell instance, not just in the login shell.

More importantly, you will always hide system default versions for your user. That might be tolerable with devtoolset, but imagine the consequences of enabling, say rh-python36. The 'yum' requires python 2.7. It does run /usr/bin/python, which is 2.7, but the rh-python36 prepends python 3.6's path to mess things up.
I think (at least in my case) that this is intended for disposable servers. Really the only real need I can see for enabling an scl in a single bash session.