bash script questions.

General support questions
Post Reply
supertight
Posts: 171
Joined: 2017/02/07 21:47:51

bash script questions.

Post by supertight » 2018/01/23 03:30:37

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.

bertalanimre
Posts: 140
Joined: 2015/06/02 13:04:03

Re: bash script questions.

Post by bertalanimre » 2018/01/23 12:50:21

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.

User avatar
TrevorH
Forum Moderator
Posts: 23637
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: bash script questions.

Post by TrevorH » 2018/01/23 13:26:43

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.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: bash script questions.

Post by supertight » 2018/01/24 00:21:24

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.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: bash script questions.

Post by supertight » 2018/01/24 00:27:07

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?

aeugenegray
Posts: 3
Joined: 2018/06/05 21:11:35

Re: bash script questions.

Post by aeugenegray » 2018/06/05 21:17:04

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.

aeugenegray
Posts: 3
Joined: 2018/06/05 21:11:35

Re: bash script questions.

Post by aeugenegray » 2018/06/05 21:20:32

Additionally I have this already built for anyone having this issue specifically related to xmr-stak.

https://github.com/aeugenegray/stak.git
Last edited by aeugenegray on 2018/06/07 06:41:33, edited 1 time in total.

User avatar
jlehtone
Posts: 2005
Joined: 2007/12/11 08:17:33
Location: Finland

Re: bash script questions.

Post by jlehtone » 2018/06/06 07:35:06

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.

aeugenegray
Posts: 3
Joined: 2018/06/05 21:11:35

Re: bash script questions.

Post by aeugenegray » 2018/06/07 01:13:51

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.

Post Reply