From c1163f1227f5ce139eee4182491c0f592fa42452 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 14 Mar 2009 20:18:19 +0100 Subject: [PATCH] added cron+conf+spec --- popcorn-client | 14 ++++++++++---- popcorn.conf | 11 +++++++++++ popcorn.cron | 6 ++++++ popcorn.spec | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 popcorn.conf create mode 100644 popcorn.cron create mode 100644 popcorn.spec diff --git a/popcorn-client b/popcorn-client index e5b9b96..2987bb2 100755 --- a/popcorn-client +++ b/popcorn-client @@ -128,7 +128,13 @@ class Client: def write(self): print self.data, -client = Client() -# client.post() -# client.email() -client.write() +enabled = os.environ['POPCORN_ENABLED'] if os.environ.has_key('POPCORN_ENABLED') else None +if enabled and enabled != '0': + method = os.environ['POPCORN_METHOD'] if os.environ.has_key('POPCORN_METHOD') else None + client = Client() + if method == '0': + client.email() + elif method == '1': + client.post() + else: + client.write() diff --git a/popcorn.conf b/popcorn.conf new file mode 100644 index 0000000..d92aacb --- /dev/null +++ b/popcorn.conf @@ -0,0 +1,11 @@ +# participate in the survey? +# 0 - no +# 1 - yes + +POPCORN_ENABLED=1 + +# method to use for submitting information +# 0 - e-mail +# 1 - HTTP POST + +POPCORN_METHOD=1 diff --git a/popcorn.cron b/popcorn.cron new file mode 100644 index 0000000..d91e6cb --- /dev/null +++ b/popcorn.cron @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -x /usr/bin/popcorn-client -a -f /etc/popcorn.conf ]; then + . /etc/popcorn.conf + /usr/bin/popcorn-client +fi diff --git a/popcorn.spec b/popcorn.spec new file mode 100644 index 0000000..920c05d --- /dev/null +++ b/popcorn.spec @@ -0,0 +1,34 @@ +Name: popcorn +Version: 0.1 +Release: 0 +Url: http://en.opensuse.org/Popcorn +License: X11/MIT +Group: System/Packages +Summary: Popularity Contest (for RPM) +Source0: popcorn-client +Source1: popcorn.conf +Source2: popcorn.cron +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: python rpm-python +Requires: python + +%description +Popularity Contest (for RPM) + +%prep +cp %{SOURCE0} %{SOURCE1} %{SOURCE2} . + +%build + +%install +install -D -m 0755 popcorn-client $RPM_BUILD_ROOT%{_bindir}/popcorn-client +install -D -m 0644 popcorn.conf $RPM_BUILD_ROOT%{_sysconfdir}/popcorn.conf +install -D -m 0755 popcorn.cron $RPM_BUILD_ROOT%{_sysconfdir}/cron.weekly/popcorn + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%{_bindir}/popcorn-client +%{_sysconfdir}/popcorn.conf +%{_sysconfdir}/cron.weekly/popcorn -- 2.11.4.GIT