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
14 changes: 10 additions & 4 deletions data/export/initscript/master.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/bash
### BEGIN INIT INFO
# Provides: <%= app %>
# Required-Start: $remote_fs $syslog
Expand All @@ -18,7 +18,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Runs <%= app %>"
NAME=<%= app %>
PIDDIR=/var/run/$NAME
PIDDIR=<%= run %>/pid/$NAME
SCRIPTNAME=/etc/init.d/$NAME
USERNAME=<%= user %>

Expand Down Expand Up @@ -48,8 +48,14 @@ do_start()
# START CONCURRENT: <%= num %>
# Start: <%= app %>.<%= name %>.<%= num %>
# Create $PIDDIR/<%= name %>.<%= num %>.pid
su - $USERNAME -c 'cd <%= engine.root %>; export PORT=<%= engine.port_for(process, num) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= name %>.<%= num %>.pid
<% end %>
if [ "$UID" -eq 0 ]; then
su - $USERNAME -c 'cd <%= engine.root %>; export PORT=<%= engine.port_for(process, num) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= name %>.<%= num %>.pid
chown -R $USERNAME $PIDDIR
chown -R $USERNAME <%= log %>
else
cd <%= engine.root %>; export PORT=<%= engine.port_for(process, num) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1 & echo $! > $PIDDIR/<%= name %>.<%= num %>.pid
fi
<% end %>
<% end %>

}
Expand Down
2 changes: 1 addition & 1 deletion foreman-export-initscript.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "foreman-export-initscript"
s.version = "0.0.1"
s.version = "0.0.2"
s.authors = ["Emile Cantin"]
s.email = ["emile.cantin@gmail.com"]
s.homepage = ""
Expand Down
10 changes: 5 additions & 5 deletions lib/foreman/export/initscript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class Foreman::Export::Initscript < Foreman::Export::Base

def export

#super
error("Must specify a location") unless location
FileUtils.mkdir_p(location) rescue error("Could not create: #{location}")
FileUtils.mkdir_p(log) rescue error("Could not create: #{log}")
super
# error("Must specify a location") unless location
# FileUtils.mkdir_p(location) rescue error("Could not create: #{location}")
# FileUtils.mkdir_p(log) rescue error("Could not create: #{log}")
# begin
# FileUtils.chown(user, nil, log)
# rescue Exception => e
Expand All @@ -24,7 +24,7 @@ def export
path = File.read(matchers.detect { |m| File.exists?(m) })
compiled = ERB.new(path).result(binding)
write_file "#{app}", compiled
FileUtils.chmod(755, "#{app}")
FileUtils.chmod(0755, "#{File.join location, app}")
# path = export_template name
# write_template "initscript/master.erb", "#{app}", binding
end
Expand Down