Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of the daemon user and group is missing when installing a generated rpm on CentOS 6 ( in v. 0.7.0-RC2 ) #221

Closed
Kreinoee opened this issue Apr 8, 2014 · 16 comments
Labels

Comments

@Kreinoee
Copy link

Kreinoee commented Apr 8, 2014

Have have set the following in my build file:

NativePackagerKeys.rpmVendor in Rpm := "Development @ Cirque",
NativePackagerKeys.packageSummary := "Cirque Pim Service",
NativePackagerKeys.packageDescription := "Cirque Pim Service",
NativePackagerKeys.rpmLicense := Some("Some licence"),
NativePackagerKeys.rpmBrpJavaRepackJars := true,
NativePackagerKeys.daemonUser in Linux := "pim-service",
NativePackagerKeys.daemonGroup in Linux := "pim-service",
NativePackagerKeys.bashScriptExtraDefines := List("-Xms256M", "-Xmx1024M", "-javaagent:../lib/eclipselink-2.5.1.jar", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"),
mainClass in Compile := Some("dk.cirque.pim.init.ServiceBoot"),
NativePackagerKeys.rpmDistribution := Some("CentOS")

I have generated an rpm using rpm:packageBin.

When installing the rpm on an centos6 box, i get the following:

rpm -ihv /tmp/pim-service-3.8.0-0.noarch.rpm 
Preparing...                ########################################### [100%]
   1:pim-service            ########################################### [100%]
warning: user pim-service does not exist - using root
warning: group pim-service does not exist - using root
warning: user pim-service does not exist - using root
warning: group pim-service does not exist - using root
Starting pim-service: [  OK  ]

It does however seem to try to delete the user (twice actually), if I remove the the rpm again:

rpm -e `rpm -qa | grep pim`
Try deleting system user and group [pim-service:pim-service]
Shutdown pim-service
Try deleting system user and group [pim-service:pim-service]
@Kreinoee
Copy link
Author

Kreinoee commented Apr 8, 2014

Simple workaround:

NativePackagerKeys.rpmPretrans := Some("groupadd -r pim-service ; useradd -r -g pim-service pim-service")

But i do not think that it should be necessary.

My first attempt for a workarround was using the rpmPre setting:

NativePackagerKeys.rpmPre := Some("groupadd -r pim-service ; useradd -r -g pim-service pim-service")

But that did not work. The user was not created at all, and running the install with debug output, indicate that rpm did not try to run the commands at all.

@muuki88
Copy link
Contributor

muuki88 commented Apr 8, 2014

Have you added the packageArchetype.java_server? This will activate the correct user initialization process.
You can read more on this here: http://www.scala-sbt.org/sbt-native-packager/GettingStartedServers/MyFirstProject.html

Also you can replace the bashScriptExtraDefines with a simple etc/default template, which is described here: http://www.scala-sbt.org/sbt-native-packager/GettingStartedServers/AddingConfiguration.html

@muuki88 muuki88 added the rpm label Apr 8, 2014
@muuki88
Copy link
Contributor

muuki88 commented Apr 8, 2014

Checking the scriplets can be done with this command

rpm2cpio your.rpm | cpio -i --make-directories

@Kreinoee
Copy link
Author

Kreinoee commented Apr 8, 2014

Yes packageArchetype.java_server is added.

I will try to se what scriplets that get generated.

@Kreinoee
Copy link
Author

Kreinoee commented Apr 8, 2014

I could not figure out how to see the scriptlet with

rpm2cpio your.rpm | cpio -i --make-directories

but

rpm -qp --scripts <rmpFile>

gives a nice description of the scriptlets in an rpm. For my package it show 2 interesting things:

  • There is no scriptlet to create the user and group
  • The deletion of the user and group is done twice, both in a preuninstall and a postuninstall scriptlet:
rpm -qp --scripts pim-service-3.8.0-0.noarch.rpm 
postinstall scriptlet (using /bin/sh):
service pim-service start
preuninstall scriptlet (using /bin/sh):
# Removing system user/group : pim-service and pim-service
echo "Try deleting system user and group [pim-service:pim-service]"
if getent passwd | grep -q "^pim-service:"; 
then
    echo "Deleting system user: pim-service"
    userdel pim-service
fi
if getent group | grep -q "^pim-service:" ;
then
    echo "Deleting system group: pim-service"
    groupdel pim-service
fi

# Halting pim-service
echo "Shutdown pim-service"
service pim-service stop
postuninstall scriptlet (using /bin/sh):
# Removing system user/group : pim-service and pim-service
echo "Try deleting system user and group [pim-service:pim-service]"
if getent passwd | grep -q "^pim-service:"; 
then
    echo "Deleting system user: pim-service"
    userdel pim-service
fi
if getent group | grep -q "^pim-service:" ;
then
    echo "Deleting system group: pim-service"
    groupdel pim-service
fi

@muuki88
Copy link
Contributor

muuki88 commented Apr 8, 2014

Sorry, my bad. This was the wrong script. rpm2cpio your.rpm | cpio -i --make-directories is for extracting rpms.

Hm. This looks not good. Which version are you using? 0.7.0-RC2? Update. Yeah, it's in the ticket name.

@muuki88
Copy link
Contributor

muuki88 commented Apr 8, 2014

I will check this, this evening and fix it within this PR #219

@Kreinoee
Copy link
Author

Kreinoee commented Apr 8, 2014

Sounds good, thank you.

Yes i use 0.7.0-RC2

@Kreinoee
Copy link
Author

Kreinoee commented Apr 8, 2014

I was wondering why my first workaround did not work where i used the rpmPre setting instead of the rpmPretrans, and it turns out the the rpmPre setting is not resulting in a scriptlet in the generated rpm at all. Should i create a seperate issue on that?

@muuki88
Copy link
Contributor

muuki88 commented Apr 8, 2014

Yeah, that would be nice. With the small set of settings to reproduce the error. Thanks :)

@muuki88
Copy link
Contributor

muuki88 commented Apr 9, 2014

Checkout #219 and see if this work for you. If yes, I would close this.

@Kreinoee
Copy link
Author

Kreinoee commented Apr 9, 2014

I will, but it will properly firs be tomorrow, my calendar is pretty packed today, sorry :(

The same goes for the other issue i promised to create.

@Kreinoee
Copy link
Author

Kreinoee commented Apr 9, 2014

Well i found some time, but i could not get it to work.

I am not a experienced user of github, so just to be sure, it was this commit your wanted me to test?: 3b7c243

With that i get the following:

rpm -qp --scripts /tmp/pim-service-3.8.0-0.noarch.rpm 
postinstall scriptlet (using /bin/sh):
chgrp pim-service /etc/pim-service/tsapi.pro ; chmod g+w /etc/pim-service/tsapi.pro
preuninstall scriptlet (using /bin/sh):
# Halting pim-service
echo "Shutdown pim-service"
service pim-service stop
postuninstall scriptlet (using /bin/sh):
# Removing system user/group : pim-service and pim-service
echo "Try deleting system user and group [pim-service:pim-service]"
if getent passwd | grep -q "^pim-service:"; 
then
    echo "Deleting system user: pim-service"
    userdel pim-service
fi
if getent group | grep -q "^pim-service:" ;
then
    echo "Deleting system group: pim-service"
    groupdel pim-service
fi

and when i try to install it:

rpm -ihv /tmp/pim-service-3.8.0-0.noarch.rpm 
Preparing...                ########################################### [100%]
   1:pim-service            ########################################### [100%]
warning: user pim-service does not exist - using root
warning: group pim-service does not exist - using root
warning: user pim-service does not exist - using root
warning: group pim-service does not exist - using root
chgrp: invalid group: `pim-service'

@muuki88
Copy link
Contributor

muuki88 commented Apr 9, 2014

I think you should checkout the complete pull request. Instructions can be found here
https://help.github.com/articles/checking-out-pull-requests-locally

then

git checkout pr/219
sbt publish-local

use the 0.7-3b7c2438a40757dfa8f7ea0d60e4b6ebd575c8ee as version.

Which version of rpm are you using?

@Kreinoee
Copy link
Author

Following the instructinos, make me end on the same commit, that i had already tested, and it was with version 0.7-3b7c2438a40757dfa8f7ea0d60e4b6ebd575c8ee

I am using rpm version 4.11.1 on the building machine, and 4.8.0 on the machine where it is installed.

@muuki88
Copy link
Contributor

muuki88 commented Apr 10, 2014

We found the bug. I asume you are using rpmBrpJavaRepackJars := true. This setting is causing the missing rpmPre. Please comment on #219 for further questions, so the discussions doesn't get to messy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants