瀏覽代碼

new package

Ralf S. Engelschall 11 年之前
父節點
當前提交
13f99d8ef5
共有 5 個文件被更改,包括 207 次插入0 次删除
  1. 103 0
      confd/confd.spec
  2. 17 0
      confd/confd.toml
  3. 8 0
      confd/example.conf.tmpl
  4. 21 0
      confd/example.toml
  5. 58 0
      confd/rc.confd

+ 103 - 0
confd/confd.spec

@@ -0,0 +1,103 @@
+##
+##  confd.spec -- OpenPKG RPM Package Specification
+##  Copyright (c) 2000-2014 OpenPKG Foundation e.V. <http://openpkg.net/>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package version
+%define       V_opkg  0.5.0b2
+%define       V_dist  0.5.0-beta2
+
+#   package information
+Name:         confd
+Summary:      Configuration Management Server
+URL:          http://www.confd.io/
+Vendor:       Kelsey Hightower
+Packager:     OpenPKG Foundation e.V.
+Distribution: OpenPKG Community
+Class:        EVAL
+Group:        Network
+License:      MIT
+Version:      %{V_opkg}
+Release:      20140705
+
+#   list of sources
+Source0:      https://github.com/kelseyhightower/confd/archive/v%{V_dist}.tar.gz
+Source1:      confd.toml
+Source2:      rc.confd
+Source3:      example.toml
+Source4:      example.conf.tmpl
+
+#   build information
+BuildPreReq:  OpenPKG, openpkg >= 20120101, go
+PreReq:       OpenPKG, openpkg >= 20120101, etcd
+
+%description
+    confd(8) is a lightweight configuration management tool focusing on:
+    keeping local configuration files up-to-date by polling etcd(8) and
+    processing template resources; reloading applications to pick up new
+    config file changes.
+
+%track
+    prog confd = {
+        version   = %{version}
+        url       = https://github.com/kelseyhightower/confd/releases
+        regex     = v(__VER__)\.tar\.gz
+    }
+
+%prep
+    %setup -q -n confd-%{V_dist}
+
+%build
+    %{l_shtool} subst \
+        -e 's;/etc/confd/confd.toml;%{l_prefix}/etc/confd/confd.toml;' \
+        confd.go
+    mkdir -p Godeps/_workspace/src/github.com/kelseyhightower
+    ln -s ../../../../.. Godeps/_workspace/src/github.com/kelseyhightower/confd
+    export GOBIN=`pwd`/bin
+    export GOPATH=`pwd`/Godeps/_workspace
+    go install github.com/kelseyhightower/confd
+
+%install
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/sbin \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/confd/conf.d/template \
+        $RPM_BUILD_ROOT%{l_prefix}/var/confd/run \
+        $RPM_BUILD_ROOT%{l_prefix}/var/confd/log \
+        $RPM_BUILD_ROOT%{l_prefix}/var/confd/out
+    %{l_shtool} install -c -s -m 755 \
+        bin/confd $RPM_BUILD_ROOT%{l_prefix}/sbin/
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE confd.toml} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE example.toml} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/conf.d/
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE example.conf.tmpl} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/conf.d/template/
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE rc.confd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/confd/*'
+
+%files -f files
+
+%clean
+

+ 17 - 0
confd/confd.toml

@@ -0,0 +1,17 @@
+##
+##  confd.toml -- confd(8) configuration
+##
+
+[confd]
+verbose     = true
+
+backend     = "etcd"
+etcd_nodes  = [ "http://127.0.0.1:4001" ]
+etcd_scheme = "http"
+client_cert = "@l_prefix@/etc/x509/example-client.crt.pem"
+client_key  = "@l_prefix@/etc/x509/example-client.key.pem"
+prefix      = "/"
+
+confdir     = "@l_prefix@/etc/confd/confd.d"
+interval    = 600
+

+ 8 - 0
confd/example.conf.tmpl

@@ -0,0 +1,8 @@
+
+#   you can configure this via:
+#   $ etcdctl set /example/foo "The Foo"
+#   $ etcdctl set /example/bar "The Bar"
+
+foo = {{ .example_foo }}
+bar = {{ .example_bar }}
+

+ 21 - 0
confd/example.toml

@@ -0,0 +1,21 @@
+##
+##  example.toml -- example configuration
+##
+
+[template]
+
+src  = "example.conf.tmpl"
+dest = "@l_prefix@/var/confd/out/example.conf"
+
+keys = [
+    "/example/foo",
+    "/example/bar"
+]
+
+owner = "@l_musr@"
+group = "@l_mgrp@"
+mode  = "0644"
+
+# check_cmd  = "exampled -c {{ .src }}"
+# reload_cmd = "@l_prefix@/bin/openpkg rc example reload"
+

+ 58 - 0
confd/rc.confd

@@ -0,0 +1,58 @@
+#!@l_prefix@/bin/openpkg rc
+##
+##  rc.confd -- Run-Commands
+##
+
+%config
+    confd_enable="$openpkg_rc_def"
+    confd_log_prolog="true"
+    confd_log_epilog="true"
+    confd_log_numfiles="10"
+    confd_log_minsize="1M"
+    confd_log_complevel="9"
+
+%common
+    confd_pidfile="@l_prefix@/var/confd/run/confd.pid"
+    confd_logfile="@l_prefix@/var/confd/log/confd.log"
+    confd_signal () {
+        [ -f $confd_pidfile ] && kill -$1 `cat $confd_pidfile`
+    }
+
+%status -u @l_susr@ -o
+    confd_usable="unknown"
+    confd_active="no"
+    rcService confd enable yes && \
+        confd_signal 0 && confd_active="yes"
+    echo "confd_enable=\"$confd_enable\""
+    echo "confd_usable=\"$confd_usable\""
+    echo "confd_active=\"$confd_active\""
+
+%start -u @l_susr@
+    rcService confd enable yes || exit 0
+    rcService confd active yes && exit 0
+    (   nohup @l_prefix@/sbin/confd \
+        </dev/null >>$confd_logfile 2>&1 &
+        echo $! >$confd_pidfile
+    ) >/dev/null 2>&1
+
+%stop -u @l_susr@
+    rcService confd enable yes || exit 0
+    rcService confd active no  && exit 0
+    confd_signal TERM
+    sleep 2
+    rm -f $confd_pidfile >/dev/null 2>&1 || true
+
+%restart -u @l_susr@
+    rcService confd enable yes || exit 0
+    rcService confd active no  && exit 0
+    rc confd stop start
+
+%daily -u @l_susr@
+    rcService confd enable yes || exit 0
+    shtool rotate -f \
+        -n ${confd_log_numfiles} -s ${confd_log_minsize} -d \
+        -z ${confd_log_complevel} -m 664 -o @l_susr@ -g @l_sgrp@ \
+        -P "${confd_log_prolog}" \
+        -E "${confd_log_epilog}; rc confd restart" \
+        $confd_logfile
+