Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ dist_dirs:
prep_cmd: lineman build
upstart_files:
- conf/some-project-initfile
systemd_files:
- conf/some-project-sysfile
mnt_log_path: path/to/service/logs
postinst: |
# This script will be in /var/lib/dpkg/info/${PACKAGE_NAME}.postinst
# once the package is installed. Ploy adds #!/bin/bash to the top
# automatically.
```
**Note:**
`systemd_files` and `mnt_log_path` are necessary if you want to install the service using systemd. If you don't want to use systemd, you can ignore these fields.

### metadata files

Expand Down
2 changes: 2 additions & 0 deletions lib/ploy/localpackage/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def builder
:branch => git_branch,
:timestamp => git_timestamp,
:upstart_files => @conf['upstart_files'],
:systemd_files => @conf['systemd_files'],
:mnt_log_path => @conf['mnt_log_path'],
:dist_dirs => @conf['dist_dirs'],
:dist_dir => @conf['dist_dir'],
:prefix => @conf['prefix'],
Expand Down
28 changes: 25 additions & 3 deletions lib/ploy/localpackage/debbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class DebBuilder
attr_accessor :branch
attr_accessor :timestamp
attr_accessor :upstart_files
attr_accessor :systemd_files
attr_accessor :mnt_log_path
attr_accessor :dist_dirs
attr_accessor :dist_dir
attr_accessor :prefix
Expand All @@ -35,7 +37,9 @@ def build_deb
ol = fpm_optlist(dir)
ol.add("--after-install", file.path)
#puts "debug: fpm #{ol.as_string} ."
info = eval(`fpm #{ol.as_string} .`)
output = `fpm #{ol.as_string} .`
output = output.gsub("Adding action files", "")
info = eval(output)
end
end
return info[:path]
Expand All @@ -54,12 +58,20 @@ def fpm_optlist(dir)
{ "-v" => safeversion(@timestamp + '.' + @branch) },
]

if @upstart_files then
if @upstart_files && !@systemd_files then
@upstart_files.each do | upstart |
optlist.add("--deb-upstart", upstart)
end
end

if @systemd_files then
@systemd_files.each do | systemd |
optlist.add("--deb-systemd", systemd)
optlist.add("--deb-systemd-auto-start", "")
optlist.add("--deb-systemd-restart-after-upgrade", "")
optlist.add("--deb-systemd-enable", "")
end
end
return optlist
end

Expand Down Expand Up @@ -90,7 +102,7 @@ def write_after_install_script(file)
# END PACKAGE POSTINST
SCRIPT

if @upstart_files then
if @upstart_files && !@systemd_files then
@upstart_files.each do | upstart |
service = File.basename(upstart)
file.write <<SCRIPT
Expand All @@ -105,6 +117,16 @@ def write_after_install_script(file)
stop #{service}
fi
start #{service}
SCRIPT
end
elsif @systemd_files then
@systemd_files.each do | systemd |
service = File.basename(systemd)
mnt_log = @mnt_log_path ? @mnt_log_path : "/mnt/" + service
file.write <<SCRIPT
# Systemd after script
mkdir -p #{mnt_log}

SCRIPT
end
end
Expand Down