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
-
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:
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:
export X_SCLS="`scl enable python33, scl enable postgresql92 'echo $X_SCLS'`"
Is that the proper way?
Thank you in advance,
Michel-André
-
Have a look at concatenating bash vars.
Something like this:
foo= "bar"
foo="$foo bar"
echo $foo
Should be
"bar bar"
-
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.
-
Hi ReetP,
Finally I am using "rh-python36" and "rh-postgresql96" collections.
##### 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"
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"
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.
# 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é
-
Nice. They should at least go on the wiki.
-
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
#!/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
#!/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.
-
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