Koozali.org: home of the SME Server

[Solved]Enable the python 3.3 environment at boot time // Enable the postgresql9

Offline michelandre

  • *
  • 261
  • +0/-0
Hi all,

I would like to enable both Python-3.3 and PostgreSQL-9.2 environments at boot time.

Both use same variable: X_SCLS:

Code: [Select]
export X_SCLS="`scl enable python33 'echo $X_SCLS'`"

export X_SCLS="`scl enable postgresql92 'echo $X_SCLS'`"


So I think that the way to enable both environments is to combine them wiht a "," in the variable like:

Code: [Select]
export X_SCLS="`scl enable python33, scl enable postgresql92 'echo $X_SCLS'`"
Is that the proper way?

Thank you in advance,

Michel-André
« Last Edit: August 29, 2018, 01:35:25 AM by michelandre »

Offline ReetP

  • *
  • 3,722
  • +5/-0
Have a look at concatenating bash vars.

Something like this:

foo= "bar"
foo="$foo bar"

echo $foo

Should be

"bar bar"

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,722
  • +5/-0
If you follow this:

https://wiki.contribs.org/Software_Collections:Python

Then you should have a separate sh file in /etc/profile.d for each package so you can enable/disable individually.

In which case my comment above just needs refining but in principle is correct.

You should just concatenate any existing var with the new one so you don't destroy the existing version.... imagine you already have another SCL package installed.

The wiki page should probably be amended to reflect that.

E.g assume X_SCLS is already set and add to it rather than replace it.

I'll take more of a look tomorrow.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline michelandre

  • *
  • 261
  • +0/-0
Hi ReetP,

Finally I am using "rh-python36" and "rh-postgresql96" collections.

Code: [Select]
##### Get the Centos-6 key and build the repository.

# wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-6

# /sbin/e-smith/db yum_repositories set centos-sclo-rh repository  \
Name 'Centos - RH Software Collections'                            \
BaseURL 'http://mirror.centos.org/centos/6/sclo/x86_64/rh/'        \
EnableGroups no                                                    \
GPGCheck yes                                                       \
GPGKey file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6                \
Visible no                                                         \
status disabled

# signal-event yum-modify

# yum install -y --enablerepo=centos-sclo-rh rh-python36*

##### To exclued absolete postgresql packages

# db yum_repositories setprop base Exclude 'initscripts,libgsf,postgresql*'

# signal-event yum-modify

# yum install -y --enablerepo=centos-sclo-rh rh-postgresql96


I found a solution to enable both collections: http://appdev.oit.umn.edu/2015/02/11/scl/.
"rh-python36"

Code: [Select]
cat > /etc/profile.d/activer-rh-python36.sh <<'EOT'
#!/bin/bash
source /opt/rh/rh-python36/enable

if [[ "$X_SCLS" != *rh-python36* ]]; then
src="`scl enable rh-python36 'echo $X_SCLS'`"
pkgs=(${src// / })
uniq=($(printf "%s\n" "${pkgs[@]}" | sort -u));
export X_SCLS="${uniq[@]}"
fi
EOT

"rh-postgresql96"
Code: [Select]
cat > /etc/profile.d/activer-rh-postgresql96.sh <<'EOT'
#!/bin/bash
source /opt/rh/rh-postgresql96/enable

if [[ "$X_SCLS" != *rh-postgresql96* ]]; then
src="`scl enable rh-postgresql96 'echo $X_SCLS'`"
pkgs=(${src// / })
uniq=($(printf "%s\n" "${pkgs[@]}" | sort -u));
export X_SCLS="${uniq[@]}"
fi
EOT

To make it effective: logout and re-login.
Code: [Select]
# which python
/opt/rh/rh-python36/root/usr/bin/python

# python --version
Python 3.6.3

# which psql
/opt/rh/rh-postgresql96/root/usr/bin/psql

# psql --version
psql (PostgreSQL) 9.6.5

Michel-André


Offline ReetP

  • *
  • 3,722
  • +5/-0
Nice. They should at least go on the wiki.

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,722
  • +5/-0
As a follow up I had a quick look at this.

If you you look at some other .sh files in /etc/profile.d from other SCL pacjakes they are simpler, and I think as effective

[root@esmith profile.d]# cat scls-rh-java-common.sh

Code: [Select]
#!/bin/sh
source /opt/rh/rh-java-common/enable
export X_SCLS="`scl enable rh-java-common 'echo $X_SCLS'`"

[root@esmith profile.d]# cat scls-rh-python34.sh

Code: [Select]
#!/bin/sh
source /opt/rh/rh-python34/enable
export X_SCLS="`scl enable rh-python34 'echo $X_SCLS'`"

That is all you need I think. The wiki pages for python and postgresql are basically right - you just need to substitute the required version.

The key is only having one .sh file per application. Each can then be enabled or disabled as required.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline stephdl

  • *
  • 1,519
  • +0/-0
    • Linux et Geekeries
Nice. They should at least go on the wiki.

redhat provided a simplest solution, but not tested on SME

 https://access.redhat.com/solutions/527703
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!