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

New source: pleaserun #1119

Merged
merged 15 commits into from May 26, 2016

Conversation

@jordansissel
Copy link
Owner

jordansissel commented May 26, 2016

The pleaserun tool helps generate service manifests for different service platforms such as systemd and runit.

This PR introduces pleaserun as a package source. The goal is to have a package you can install that will "do the right thing" and install the best-fitting service manifest for the target system.

Example usage:

% fpm -s pleaserun -t rpm -a all -n redis-service --pleaserun-name redis /usr/bin/redis-server
...

% sudo yum install redis-service-1.0-1.noarch.rpm
...
  Installing  : redis-service-1.0-1.noarch                                                            1/1
Platform systemd (default) detected. Installing service.
To start this service, use: systemctl start redis
  Verifying   : redis-service-1.0-1.noarch                                                            1/1

Installed:
  redis-service.noarch 1.0-1
...

% systemctl status redis
● redis.service - redis
   Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Yay, easy services!

It also tries to clean up during package removal:

% sudo yum remove redis-service
...
Running cleanup to remove service for package redis-service
...

% sudo systemctl status redis
● redis.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
jordansissel added 15 commits May 13, 2016
Long term, we'll probably have a "smart" post-install that will choose
the correct service (systemd, etc) to install based on the platform
doing the installation, not the platform creating the package :)

Adds dependencies on pleaserun and upgrades clamp to suit.

Example using the defaults in pleaserun:

    # Create a package called 'example-service' that installs a service named 'example'
    % bin/fpm -s pleaserun -t rpm -n example-service --pleaserun-name example  =logger hello world
    No platform selected. Autodetecting... {:platform=>"systemd", :version=>"default", :level=>:warn}
    Writing file {:destination=>"/tmp/package-pleaserun-staging20160513-12576-1ozurnf/lib/systemd/system/example.service"}
    Writing install actions. You will want to run this script to properly activate your service on the target host {:path=>"/tmp/package-pleaserun-staging20160513-12576-1ozurnf/install_actions.sh"}
    Created package {:path=>"example-service-1.0-1.x86_64.rpm"}

    # ^^ The above service will execute "logger hello world"

    # What's in our rpm?
    % rpm -qlp example-service-1.0-1.x86_64.rpm
    /lib/systemd/system/example.service

    # What about any post-install steps?
    % rpm -qp example-service-1.0-1.x86_64.rpm --scripts
    postinstall scriptlet (using /bin/sh):
    systemctl --system daemon-reload

    # Install it.
    % sudo rpm -ivh example-service-1.0-1.x86_64.rpm

    # Start it.
    % sudo systemctl start example

    # Check the logs!
    % sudo tail -n1 /var/log/messages
    May 13 03:32:55 localhost root: hello world

Example choosing 'sysv' as the platform:

    % bin/fpm -s pleaserun -t rpm -n example-service --pleaserun-platform sysv --pleaserun-name example  =logger hello world
    Writing file
    {:destination=>"/tmp/package-pleaserun-staging20160513-13675-xae6xd/etc/init.d/example"}
    Writing file
    {:destination=>"/tmp/package-pleaserun-staging20160513-13675-xae6xd/etc/default/example"}
    Created package {:path=>"example-service-1.0-1.x86_64.rpm"}

    % rpm -qlp example-service-1.0-1.x86_64.rpm
    /etc/default/example
    /etc/init.d/example
… detected.

Also move files to be /platform/version/... instead of
/platform-version/...
* Only try install actions if they exist
* Add special case for Upstart 0.6.5 (CentOS 6)
The scripts will be written to the top-level `.scripts/` directory
The `install.sh` will generate a cleanup.sh script that is executed when
the package is removed.
…. Without this, the default is 'no description given' which is not a helpful default
@untergeek

This comment has been minimized.

Copy link

untergeek commented May 26, 2016

👍

@jordansissel

This comment has been minimized.

Copy link
Owner Author

jordansissel commented May 26, 2016

Specs reasonably passing for me. This PR adds no meaningful tests, but that's partly because I'm still trying to figure out a nice way to actually test it.

@jordansissel jordansissel merged commit 77317e3 into master May 26, 2016
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
jordansissel added a commit that referenced this pull request Jun 20, 2016
@josegonzalez josegonzalez deleted the feature/pleaserun branch Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.