Koozali.org: home of the SME Server

Obsolete Releases => SME 9.x Contribs => Topic started by: michelandre on August 23, 2018, 09:10:08 PM

Title: [Solved]Enable the python 3.3 environment at boot time // Enable the postgresql9
Post by: michelandre on August 23, 2018, 09:10:08 PM
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é
Title: Re: Enable the python 3.3 environment at boot time // Enable the postgresql92 enviro
Post by: ReetP on August 23, 2018, 09:40:30 PM
Have a look at concatenating bash vars.

Something like this:

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

echo $foo

Should be

"bar bar"

Title: Re: Enable the python 3.3 environment at boot time // Enable the postgresql92 enviro
Post by: ReetP on August 23, 2018, 10:51:36 PM
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.
Title: Re: Enable the python 3.3 environment at boot time // Enable the postgresql92 enviro
Post by: michelandre on August 29, 2018, 01:32:38 AM
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é

Title: Re: [Solved]Enable the python 3.3 environment at boot time // Enable the postgresql9
Post by: ReetP on August 29, 2018, 09:59:52 AM
Nice. They should at least go on the wiki.

Title: Re: [Solved]Enable the python 3.3 environment at boot time // Enable the postgresql9
Post by: ReetP on August 31, 2018, 01:50:06 PM
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.
Title: Re: [Solved]Enable the python 3.3 environment at boot time // Enable the postgresql9
Post by: stephdl on September 03, 2018, 08:35:54 PM
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