Opened 4 years ago

Closed 4 years ago

#330 closed defect (fixed)

tomcat user and initpetascopedb function in /etc/init.d/rasdaman script

Reported by: damiano Owned by: dmisev
Priority: major Milestone: 8.4
Component: RPM Version: 8.4
Keywords: initpetascopedb Cc: mantovani@…
Complexity: Medium

Description

With the following distro initpetascopedb function fails

  • Scientific Linux release 6.X
  • CentOS release 6.X

Probably with any other EL 6.X distro the function will not work (Not tested)

In these distro tomcat user is "tomcat" and not "tomcat6"

Error:
At row 203 function search for hard-coded user tomcat6 in petascope.properties so it is assumed tomcat6 user as default user.
Consequently the grep command return 0, the sed command is not executed and in petascope.properties metadata_user remains tomcat6

update_petascopedb.sh: postgres settings read from /etc/rasdaman/petascope.properties
update_petascopedb.sh: user: tomcat6
update_petascopedb.sh: port: 5432
update_petascopedb.sh: db: petascopedb
update_petascopedb.sh: no petascope database found, creating... createdb: could not connect to database postgres: FATAL: role "tomcat6" does not exist
failed.
update_petascopedb.sh: exiting.

Proposed Solution
Execute the sed command directly, removing grep at row 203 and the if statement at row 204. The tomcat use is identified correctly in the previous step and is in variable $tomcat_user.
Solution tested, works

Ciao

Damiano

# /etc/init.d/rasdaman initpetascopedb
creating user
update_petascopedb.sh: postgres settings read from /etc/rasdaman/petascope.properties
update_petascopedb.sh: user: tomcat
update_petascopedb.sh: port: 5432
update_petascopedb.sh: db: petascopedb
update_petascopedb.sh: no petascope database found, creating... ok.

update_petascopedb.sh: executing updates:
update_petascopedb.sh: update 0... ok.
update_petascopedb.sh: update 1... ok.
update_petascopedb.sh: update 2... ok.
update_petascopedb.sh: update 3... ok.
update_petascopedb.sh: update 4... ok.
update_petascopedb.sh: update 5... ok.
update_petascopedb.sh: update 6... ok.
update_petascopedb.sh: update 7... ok.
update_petascopedb.sh: updated database to update 7

update_petascopedb.sh: done, exiting.

Attachments (1)

rasdaman (7.5 KB) - added by damiano 4 years ago.
rasdaman init script in rasdaman-8.4.0-rc.2.2.el6.x86_64.rpm

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by dmisev

Do you have the latest RPMs? I've fixed this just before tagging 8.4.0-rc.2, in changeset:a7b70d9

 	197	  # determine tomcat user, seems to vary between different distributions 
 	198	  tomcat_user=`grep -i tomcat /etc/passwd | awk -F ':' '{ print $1; }' | head -n 1` 
 	199	  if [ -z "$tomcat_user" ]; then 
 	200	    tomcat_user="tomcat6" 
 	201	  fi 

Can you attach the rasdaman init script here?

Changed 4 years ago by damiano

rasdaman init script in rasdaman-8.4.0-rc.2.2.el6.x86_64.rpm

comment:2 Changed 4 years ago by barboni@…

Yes dimitar, function is updated but tomcat6 remains hard-coded in the following section (row 203:207):

# update petascope user in configuration, unless the user has changed it
grep 'metadata_user=tomcat6' /etc/rasdaman/petascope.properties > /dev/null
if [ $? -ne 0 ]; then

sed -i 's/metadata_user=.\+/metadata_user='$tomcat_user'/' /etc/rasdaman/petascope.properties

fi

file attached

Ciao

Damiano

comment:3 Changed 4 years ago by dmisev

We check for the tomcat6 user because this is the default user defined in the properties when rasdaman-petascope is installed. If the petascope user is not tomcat6 then it's assumed that the user has changed the configuration, and we should not overwrite these modifications.

comment:4 Changed 4 years ago by dmisev

  • Status changed from new to accepted

But it seems I haven't tested properly with a different user in petascope.properties, the initpetascopedb should not give an error.

comment:5 Changed 4 years ago by dmisev

Ah, the

grep 'metadata_user=tomcat6' /etc/rasdaman/petascope.properties > /dev/null
if [ $? -ne 0 ]; then

should be

grep 'metadata_user=tomcat6' /etc/rasdaman/petascope.properties > /dev/null
if [ $? -eq 0 ]; then

comment:6 Changed 4 years ago by dmisev

Can you test by just changing the -ne to -eq?

comment:7 Changed 4 years ago by barboni@…

Ok Dimitar, now I understand your point of view and why you check for "tomcat6" user

To change if condition "-ne" with "-eq" fix the issue.

Tested.

Ciao

Damiano

# /etc/init.d/rasdaman initpetascopedb
creating user
update_petascopedb.sh: postgres settings read from /etc/rasdaman/petascope.properties
update_petascopedb.sh: user: tomcat
update_petascopedb.sh: port: 5432
update_petascopedb.sh: db: petascopedb
update_petascopedb.sh: no petascope database found, creating... ok.

update_petascopedb.sh: executing updates:
update_petascopedb.sh: update 0... ok.
update_petascopedb.sh: update 1... ok.
update_petascopedb.sh: update 2... ok.
update_petascopedb.sh: update 3... ok.
update_petascopedb.sh: update 4... ok.
update_petascopedb.sh: update 5... ok.
update_petascopedb.sh: update 6... ok.
update_petascopedb.sh: update 7... ok.
update_petascopedb.sh: updated database to update 7

update_petascopedb.sh: done, exiting.

comment:8 Changed 4 years ago by dmisev

  • Resolution set to fixed
  • Status changed from accepted to closed

Thanks for checking, so fixed in changeset:2aa58a0 and we close the ticket.

comment:9 Changed 4 years ago by damiano

  • Resolution fixed deleted
  • Status changed from closed to reopened

if condition is again "-ne" and not "-eq" with the latest rpm 8.4.1

# rpm -qa | grep rasda
rasdaman-petascope-8.4.1-1.el6.noarch
rasdaman-8.4.1-1.el6.x86_64

# update petascope user in configuration, unless the user has changed it
grep 'metadata_user=tomcat6' /etc/rasdaman/petascope.properties > /dev/null
if [ $? -ne 0 ]; then

sed -i 's/metadata_user=.\+/metadata_user='$tomcat_user'/' /etc/rasdaman/petascope.properties

fi

comment:10 Changed 4 years ago by damiano

  • Resolution set to fixed
  • Status changed from reopened to closed

fixed in rasdaman-8.4.1-2.el6.x86_64.rpm

thanks Joachim

Note: See TracTickets for help on using tickets.