Skip to content

Commit

Permalink
build rpms w/new supervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
ezuce-admin committed Jan 24, 2012
1 parent cf7a3f0 commit 72ed034
Show file tree
Hide file tree
Showing 33 changed files with 212 additions and 212 deletions.
File renamed without changes.
9 changes: 5 additions & 4 deletions mak/rpm.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RPM_DIST = @RPM_DIST@

# trick lets you create centos compatible repos from any other distro
CREATEREPO_OPTS_centos = @BACKWARD_COMPATIBLE_CREATEREPO_OPTS_FOR_CENTOS@
CREATEREPO_OPTS = -g $(SRC)/mak/comps.xml $(CREATEREPO_OPTS_$(DISTRO_OS))
MOCK_RESULTS_DIR = @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/$(DISTRO_ARCH)
MOCK_SRPM_DIR = @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/source
MOCK_OPTS = \
Expand Down Expand Up @@ -82,13 +83,13 @@ help.{1|2}.rpm-by-mock = Called automatically as part of rpm process after srpm
$(MOCK_SRPM_DIR)/$($(PROJ)_SRPM)
find $(MOCK_RESULTS_DIR) -name '*.src.rpm' -exec rm {} \;
# generate repo AFTER build because then it's usable as a repo to feed to next build or other systems.
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS_$(DISTRO_OS)) .
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .

help.repo-chroot-init = Clear mock chroot for $(DISTRO). Requied before first build and useful when you suspect caching is the result of a build error.
repo-chroot-init : repo-create repo-webserver
mock $(MOCK_OPTS) --scrub=all
test -d $(MOCK_RESULTS_DIR) || mkdir -p $(MOCK_RESULTS_DIR)
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS_$(DISTRO_OS)) .
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .
mock $(MOCK_OPTS) --init

help.{1|2}.check-rpm = Install the project rpm in the mock environment to test install. This does not install all rpms generated by a project, just the main one. You can install then pretty easily though with command 'mock -r $(MOCK_TARGET_PLATFORM) --install package-name'
Expand All @@ -114,7 +115,7 @@ repo-webserver :
help.repo-src = Assemble source rpms into @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/source
repo-src :
for f in $(shell $(SRC)/mak/list-obsolete-rpms $(MOCK_SRPM_DIR)); do rm $$f; done
cd $(MOCK_SRPM_DIR); createrepo $(CREATEREPO_OPTS_$(DISTRO_OS)) .
cd $(MOCK_SRPM_DIR); createrepo $(CREATEREPO_OPTS) .

help.repo-check = Installs sipXecs in chroot. Tip, run repo-chroot-init first for more thourugh test of all dependencies.
repo-check : repo-webserver
Expand All @@ -127,7 +128,7 @@ repo-remove-dups:
help.repo-create = run createrepo in $(MOCK_RESULTS_DIR)
repo-create:
test -d $(MOCK_RESULTS_DIR) || mkdir -p $(MOCK_RESULTS_DIR)
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS_$(DISTRO_OS)) .
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .

help.repo-update = If you rebuild local rpms, repo will not automatically replace previously installed versions. This call will force up update to all packages at once.
repo-update :
Expand Down
1 change: 0 additions & 1 deletion sipXacd/sipxacd.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Obsoletes: %name-devel

Requires: sipxcommserverlib >= %version
Requires: sipxcalllib >= %version
Requires: sipxpbx >= %version
Requires: boost

Prefix: %_prefix
Expand Down
13 changes: 9 additions & 4 deletions sipXacdStatistics/bin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ include $(top_srcdir)/config/utility.am

EXTRA_DIST = \
$(bin_SCRIPTS:=.in) \
$(setupbin_SCRIPTS:=.in)
$(setupbin_SCRIPTS:=.in) \
$(initd_SCRIPTS:=.in)

setupbindir = @SIPX_LIBEXECDIR@/setup.d
setupbindir = @SIPX_LIBEXECDIR@
setupbin_SCRIPTS = \
sipxacd-report-setup

initddir = @SIPX_SERVICEDIR@
initd_SCRIPTS = \
sipxacd-stats-daemon

bin_SCRIPTS = \
sipxacd-stats \
sipxacd-report

$(setupbin_SCRIPTS) $(bin_SCRIPTS) : % : %.in Makefile
$(initd_SCRIPTS) $(setupbin_SCRIPTS) $(bin_SCRIPTS) : % : %.in Makefile
@$(call SearchAndReplace, $<, $@)

CLEANFILES = $(setupbin_SCRIPTS) $(bin_SCRIPTS)
CLEANFILES = $(setupbin_SCRIPTS) $(bin_SCRIPTS) $(initd_SCRIPTS)
5 changes: 1 addition & 4 deletions sipXacdStatistics/bin/sipxacd-report-setup.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
: ${ConfDir:=@SIPX_CONFDIR@}
: ${DbVersion:=2}
: ${DbPatchDir:=${ConfDir}/report}
: ${DbPatchLog:=${LogDir}/sipacdreportpatch.log}
: ${DbPatchLog:=@SIPX_LOGDIR@/sipacdreportpatch.log}

Database=SIPXACD_HISTORY

#Creates database if not found
@bindir@/sipxacd-report --setup

# How to add a database patch:
#
# Add a file containing SQL statements in the sipXproxy/etc/database directory.
Expand Down
16 changes: 4 additions & 12 deletions sipXacdStatistics/bin/sipxacd-report.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ def parse(args)
exit
end

opts.on_tail("--setup", "Configure postgres to allow connection and create database") do
setuppg
createdb
exit
end

opts.on_tail("--disable", "Disable production of the sipxconfig-report") do
disablereport
exit
Expand Down Expand Up @@ -83,12 +77,6 @@ def parse(args)
`#perl -pi -e 's/^(CONFIG_SERVER_REPORT\s*=\s*")ENABLED"/\1DISABLED"/' @SIPX_CONFDIR@/sipxconfig-report-config`
end

def setuppg
if ! system('@bindir@/pgpatch.sh')
raise "could not patch postgres setup"
end
end

end
opts.parse!(args)
options
Expand Down Expand Up @@ -130,6 +118,10 @@ pid.close
configUrls = Array.new(CONFIG_SERVER_AGENT_URL.split(";"))
locationFqdns = Array.new(LOCATION_FQDN.split(";"))

# check db schema is updated
createdb
system("@SIPX_LIBEXECDIR@/sipxacd-report-setup")

configUrls.length.times do |i|
importer = Reports::Importer.new
begin
Expand Down
21 changes: 21 additions & 0 deletions sipXacdStatistics/bin/sipxacd-stats-daemon.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/ruby
ENV['GEM_PATH'] = '/opt/sipx-main/lib/ruby/gems/1.8:/usr/lib/ruby/gems/1.8:/var/lib/gems/1.8'

require 'rubygems'
require 'daemons'
require 'etc'

uid = Etc.getpwnam('@SIPXPBXUSER@').uid
gid = Etc.getgrnam('@SIPXPBXGROUP@').gid

unless Process.euid == uid && Process.egid == gid
Process.initgroups('@SIPXPBXUSER@', gid)
Process::GID.change_privilege(gid)
Process::UID.change_privilege(uid)
end

Daemons.run('@SIPX_BINDIR@/sipxacd-stats',
:app_name => 'sipxacd-stats',
:dir_mode => :normal,
:dir => '@SIPX_RUNDIR@',
:log_output => true)
68 changes: 1 addition & 67 deletions sipXacdStatistics/bin/sipxacd-stats.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,8 @@
# NOTE: Keep this at top of file, see XCF-1096. Debian Etch looks in /var/lib/gems/1.8
ENV['GEM_PATH'] = '@GEM_LOCAL_LIB_DIR@:/usr/lib/ruby/gems/1.8:/var/lib/gems/1.8'

require 'tempfile'
require 'optparse'
require 'ostruct'

def load_config_properties
load ('@SIPX_CONFDIR@/config-agent.properties')
end

def parse(args)
options = OpenStruct.new

opts = OptionParser.new do |opts|
opts.banner = "Usage: sipxconfig-agent [--conftest | --stop]"

opts.separator ""
opts.separator "Specific options:"

opts.on_tail("-c", "--configtest", "Run tests on configuration") do
if ! defined? CONFIG_SERVER_AGENT_PORT
raise "Missing items 'CONFIG_SERVER_AGENT_PORT' in config-agent.properties"
end
exit
end

opts.on_tail("-s", "--stop", "Stop the ConfigAgent") do
print "Stopping @SIPX_RUNDIR@/sipxconfig-agent.pid "
if File.exist?('@SIPX_RUNDIR@/sipxconfig-agent.pid')
pid=File.read('@SIPX_RUNDIR@/sipxconfig-agent.pid').to_i
if pid
begin
Process.kill("TERM", pid)
20.times do
print "."
$stdout.flush
sleep 1
Process.kill(0, pid)
end
# ESRCH means "No such process": success
rescue Errno::ESRCH
puts " Success"
File.delete('@SIPX_RUNDIR@/sipxconfig-agent.pid')
# other errors could indicate permissions, etc
rescue
puts " Failed, error #{$!}"
# reached end of loop
else
puts " Failed to stop"
end
end
else
puts "Success (Not started)"
end
exit
end

end
opts.parse!(args)
options
end

load_config_properties
parse(ARGV)

require 'rubygems'
require 'main'

pid=File.open('@SIPX_RUNDIR@/sipxconfig-agent.pid', 'w')
pid.puts Process.pid
pid.close

load('@SIPX_CONFDIR@/config-agent.properties')
main('@SIPX_LOGDIR@/sipxacd_events.log', CONFIG_SERVER_AGENT_PORT)
32 changes: 4 additions & 28 deletions sipXacdStatistics/etc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
include $(top_srcdir)/config/utility.am

EXTRA_DIST = \
$(proc_DATA:=.in) \
$(cfg_DATA:=.in) \
$(rpt_DATA) \
$(cron_FILES:=.in)

cron_FILES = sipxconfig-report-crontab
if IS_RPMBUILD
# Target is not normally run, also, you may have to add sipx user to
# /etc/cron.d/cron.allow file
crondir = $(CRON_D)
cron_SCRIPTS = $(cron_FILES)
else
noinst_SCRIPTS = $(cron_FILES)
endif

procdir = $(SIPX_DATADIR)/process.d
proc_DATA = \
sipxconfig-agent-process.xml

cfgdir = $(SIPX_CONFDIR)
cfg_DATA = \
sipxconfig-report-config

rptdir = $(SIPX_CONFDIR)/report
rpt_DATA = \
dist_rpt_DATA = \
schema.sql \
enable_upgrades.sql \
location_fqdn.sql

$(cron_FILES) $(cfg_DATA) $(proc_DATA) : % : %.in Makefile
@$(call SearchAndReplace, $<, $@)
cfinputsdir = $(SIPX_CFINPUTS)/plugin.d
dist_cfinputs_DATA = \
sipxacdstatistics.cf

CLEANFILES = $(cron_FILES) $(cfg_DATA) $(proc_DATA)
92 changes: 92 additions & 0 deletions sipXacdStatistics/etc/sipxacdstatistics.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright (C) 2012 eZuce Inc., certain elements licensed under a Contributor Agreement.
# Contributors retain copyright to elements licensed under a Contributor Agreement.
# Licensed to the User under the AGPL license.

#
# sipxacdstatistics configuration and process management
#
bundle agent sipxacdstatistics {
methods:
sipxacdstatistics::
"any" usebundle => "sipxacdstatistics_config";
"any" usebundle => "sipxacdstatistics_setup";
any::
"any" usebundle => "sipxacdstatistics_running";
}

bundle agent sipxacdstatistics_config {
vars:
any::
"agent[CONFIG_SERVER_AGENT_PORT]" string => "$(sipx.CONFIG_SERVER_AGENT_PORT)";

files:
any::
"$(sipx.SIPX_CONFDIR)/sipxconfig-report-config"
create => "true",
perms => m("644"),
edit_line => sipxacdstatistics_report_config,
action => track("$(this.promiser)");

"$(sipx.SIPX_CONFDIR)/config-agent.properties"
create => "true",
perms => m("644"),
edit_line => set_variable_values("sipxacdstatistics_config.agent"),
classes => if_repaired("restart_sipxacdstatistics"),
action => track("$(this.promiser)");
}

bundle edit_line sipxacdstatistics_report_config {
insert_lines:
"$(sipx.SIPX_CFDATA)/$(sipx.location_id)/sipxconfig-report-config.part"
insert_type => "file";
"LOCATION_FQDN=\"$(sys.fqhost);\"";

delete_lines:
".*";
}

bundle agent sipxacdstatistics_setup {
vars:
# script uses few resources so even every minute would be reasonable
# time should be less than one-half the time window sipxconfig-agent keeps
# around with is currently 90 minutes (although for the first 1000 events, it doesn't
# matter and sipxconfig-agent will keep at least that many)
"cron" string => "*/30 * * * * $(sipx.SIPXPBXUSER) $(sipx.SIPX_BINDIR)/sipxconfig-report > /dev/null";
"cron_id" string => ".*/sipxconfig-report .*"; #regex

methods:
!src.sipxacdstatistics::
"any" usebundle => rh_chkconfig_status("sipxacdstatistics on");
"any" usebundle => add_crontab("$(cron_id)","$(cron)");

!src.!sipxacdstatistics::
"any" usebundle => rh_chkconfig_status("sipxacdstatistics off");
"any" usebundle => remove_crontab("$(cron_id)");
}

bundle agent sipxacdstatistics_running {
vars:
any::
"service_command" string => "$(sipx.SIPX_BINDIR)/sipxacd-stats";

methods:
any::
"any" usebundle => find_sipxservice_by_command("$(service_command)","sipxacdstatistics_running");

commands:
sipxacdstatistics_running.!sipxacdstatistics::
"$(sipx.SIPX_SERVICEDIR)/sipxacdstatistics"
args => "stop",
action => track("sipxacdstatistics_stop");

!sipxacdstatistics_running.sipxacdstatistics::
"$(sipx.SIPX_SERVICEDIR)/sipxacdstatistics"
args => "start",
action => track("sipxacdstatistics_start");

restart_sipxacdstatistics::
"$(sipx.SIPX_SERVICEDIR)/sipxacdstatistics"
args => "restart",
action => track("sipxacdstatistics_restart");
}

26 changes: 0 additions & 26 deletions sipXacdStatistics/etc/sipxconfig-agent-process.xml.in

This file was deleted.

5 changes: 0 additions & 5 deletions sipXacdStatistics/etc/sipxconfig-report-config.in

This file was deleted.

5 changes: 0 additions & 5 deletions sipXacdStatistics/etc/sipxconfig-report-crontab.in

This file was deleted.

Loading

0 comments on commit 72ed034

Please sign in to comment.