├── LICENSE ├── README.md ├── etcd.initd ├── etcd.logrotate ├── etcd.nofiles.conf ├── etcd.spec └── etcd.sysconfig /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmilford/rpm-etcd/26092b30663db5fd29c84832e8769f66b6ec4c7d/LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rpm-etcd 2 | ======== 3 | 4 | An RPM spec file to build and install etcd. 5 | 6 | To Install: 7 | 8 | `etcd_version='2.0.9'` 9 | 10 | `etcd_rpm_github_repo='nmilford/rpm-etcd'` 11 | 12 | `sudo yum -y install rpmdevtools && rpmdev-setuptree` 13 | 14 | `wget https://raw.github.com/${etcd_rpm_github_repo}/master/etcd.spec -O ~/rpmbuild/SPECS/etcd.spec` 15 | 16 | `wget https://github.com/coreos/etcd/releases/download/v${etcd_version}/etcd-v${etcd_version}-linux-amd64.tar.gz -O ~/rpmbuild/SOURCES/etcd-v${etcd_version}-linux-amd64.tar.gz` 17 | 18 | `wget https://raw.github.com/${etcd_rpm_github_repo}/master/etcd.initd -O ~/rpmbuild/SOURCES/etcd.initd` 19 | 20 | `wget https://raw.github.com/${etcd_rpm_github_repo}/master/etcd.sysconfig -O ~/rpmbuild/SOURCES/etcd.sysconfig` 21 | 22 | `wget https://raw.github.com/${etcd_rpm_github_repo}/master/etcd.nofiles.conf -O ~/rpmbuild/SOURCES/etcd.nofiles.conf` 23 | 24 | `wget https://raw.github.com/${etcd_rpm_github_repo}/master/etcd.logrotate -O ~/rpmbuild/SOURCES/etcd.logrotate` 25 | 26 | `rpmbuild -bb ~/rpmbuild/SPECS/etcd.spec` 27 | -------------------------------------------------------------------------------- /etcd.initd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2013, Nathan Milford 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | # /etc/init.d/etcd 17 | # 18 | # Startup script for etcd 19 | # 20 | # chkconfig: 2345 20 80 21 | # description: Starts and stops etcd 22 | 23 | . /etc/init.d/functions 24 | 25 | prog="etcd" 26 | prog_bin="/usr/sbin/$prog" 27 | desc="etcd shared configuration and service discovery daemon" 28 | 29 | if ! [ -f $prog_bin ]; then 30 | echo "$prog binary not found." 31 | exit 5 32 | fi 33 | 34 | if [ -f /etc/sysconfig/$prog ]; then 35 | . /etc/sysconfig/$prog 36 | else 37 | echo "No sysconfig file found in /etc/sysconfig/$prog... exiting." 38 | exit 5 39 | fi 40 | 41 | start() { 42 | echo "Starting $desc ($prog): " 43 | su $ETCD_USER -c "nohup $prog_bin $ETCD_OPTS >>$ETCD_OUT_FILE 2>&1 &" 44 | RETVAL=$? 45 | return $RETVAL 46 | } 47 | 48 | stop() { 49 | echo "Shutting down $desc ($prog): " 50 | pkill -f $prog_bin 51 | } 52 | 53 | restart() { 54 | stop 55 | start 56 | } 57 | 58 | status() { 59 | if [ -z $pid ]; then 60 | pid=$(pgrep -f $prog_bin) 61 | fi 62 | 63 | if [ -z $pid ]; then 64 | echo "$prog is NOT running." 65 | return 1 66 | else 67 | echo "$prog is running (pid is $pid)." 68 | fi 69 | 70 | } 71 | 72 | case "$1" in 73 | start) start;; 74 | stop) stop;; 75 | restart) restart;; 76 | status) status;; 77 | *) echo "Usage: $0 {start|stop|restart|status}" 78 | RETVAL=2;; 79 | esac 80 | exit $RETVAL 81 | -------------------------------------------------------------------------------- /etcd.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/etcd/etcd.out { 2 | copytruncate 3 | daily 4 | rotate 7 5 | compress 6 | missingok 7 | } 8 | -------------------------------------------------------------------------------- /etcd.nofiles.conf: -------------------------------------------------------------------------------- 1 | etcd - nofile 32768 2 | -------------------------------------------------------------------------------- /etcd.spec: -------------------------------------------------------------------------------- 1 | # Copyright 2013, Nathan Milford 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # To Install: 16 | # 17 | # sudo yum -y install rpmdevtools && rpmdev-setuptree 18 | # wget https://raw.github.com/nmilford/rpm-etcd/master/etcd.spec -O ~/rpmbuild/SPECS/etcd.spec 19 | # wget https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.tar.gz -O ~/rpmbuild/SOURCES/etcd-v2.0.9-linux-amd64.tar.gz 20 | # wget https://raw.github.com/nmilford/rpm-etcd/master/etcd.initd -O ~/rpmbuild/SOURCES/etcd.initd 21 | # wget https://raw.github.com/nmilford/rpm-etcd/master/etcd.sysconfig -O ~/rpmbuild/SOURCES/etcd.sysconfig 22 | # wget https://raw.github.com/nmilford/rpm-etcd/master/etcd.nofiles.conf -O ~/rpmbuild/SOURCES/etcd.nofiles.conf 23 | # wget https://raw.github.com/nmilford/rpm-etcd/master/etcd.logrotate -O ~/rpmbuild/SOURCES/etcd.logrotate 24 | # rpmbuild -bb ~/rpmbuild/SPECS/etcd.spec 25 | 26 | %define debug_package %{nil} 27 | %define etcd_user %{name} 28 | %define etcd_group %{name} 29 | %define etcd_data %{_localstatedir}/lib/%{name} 30 | 31 | Name: etcd 32 | Version: 2.0.9 33 | Release: 1 34 | Summary: A highly-available key value store for shared configuration and service discovery. 35 | License: Apache 2.0 36 | URL: https://github.com/coreos/etcd 37 | Group: System Environment/Daemons 38 | Source0: https://github.com/coreos/%{name}/releases/download/v%{version}/%{name}-v%{version}-linux-amd64.tar.gz 39 | Source1: %{name}.initd 40 | Source2: %{name}.sysconfig 41 | Source3: %{name}.nofiles.conf 42 | Source4: %{name}.logrotate 43 | Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) 44 | Packager: Nathan Milford 45 | Requires(pre): shadow-utils 46 | Requires(post): /sbin/chkconfig 47 | Requires(preun): /sbin/chkconfig, /sbin/service 48 | Requires(postun): /sbin/service 49 | 50 | %description 51 | A highly-available key value store for shared configuration and service 52 | discovery. etcd is inspired by zookeeper and doozer, with a focus on: 53 | 54 | * Simple: curl'able user facing API (HTTP+JSON) 55 | * Secure: optional SSL client cert authentication 56 | * Fast: benchmarked 1000s of writes/s per instance 57 | * Reliable: Properly distributed using Raft 58 | 59 | Etcd is written in Go and uses the raft consensus algorithm to manage a 60 | highly-available replicated log. 61 | 62 | %prep 63 | %setup -n %{name}-v%{version}-linux-amd64 64 | 65 | %build 66 | rm -rf %{buildroot} 67 | 68 | echo %{buildroot} 69 | 70 | %install 71 | install -d -m 755 %{buildroot}/%{_sbindir} 72 | install -m 755 %{_builddir}/%{name}-v%{version}-linux-amd64/etcd %{buildroot}/%{_sbindir} 73 | install -m 755 %{_builddir}/%{name}-v%{version}-linux-amd64/etcdctl %{buildroot}/%{_sbindir} 74 | 75 | install -d -m 755 %{buildroot}/usr/share/doc/%{name}-v%{version} 76 | install -m 644 %{_builddir}/%{name}-v%{version}-linux-amd64/README.md %{buildroot}/%{_defaultdocdir}/%{name}-v%{version} 77 | install -m 644 %{_builddir}/%{name}-v%{version}-linux-amd64/README-etcdctl.md %{buildroot}/%{_defaultdocdir}/%{name}-v%{version} 78 | 79 | install -d -m 755 %{buildroot}/%{_localstatedir}/log/%{name} 80 | install -d -m 755 %{buildroot}/%{_localstatedir}/lib/%{name} 81 | 82 | install -d -m 755 %{buildroot}/%{_initrddir} 83 | install -m 755 %_sourcedir/%{name}.initd %{buildroot}/%{_initrddir}/%{name} 84 | 85 | install -d -m 755 %{buildroot}/%{_sysconfdir}/sysconfig/ 86 | install -m 644 %_sourcedir/%{name}.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/%{name} 87 | 88 | install -d -m 755 %{buildroot}/%{_sysconfdir}/logrotate.d 89 | install -m 644 %_sourcedir/%{name}.logrotate %{buildroot}/%{_sysconfdir}/logrotate.d/%{name} 90 | 91 | install -d -m 755 %{buildroot}/%{_sysconfdir}/security/limits.d/ 92 | install -m 644 %_sourcedir/%{name}.nofiles.conf %{buildroot}/%{_sysconfdir}/security/limits.d/%{name}.nofiles.conf 93 | 94 | %clean 95 | rm -rf %{buildroot} 96 | 97 | %pre 98 | getent group %{etcd_group} >/dev/null || groupadd -r %{etcd_group} 99 | getent passwd %{etcd_user} >/dev/null || /usr/sbin/useradd --comment "etcd Daemon User" --shell /bin/bash -M -r -g %{etcd_group} --home %{etcd_data} %{etcd_user} 100 | 101 | %post 102 | chkconfig --add %{name} 103 | 104 | %preun 105 | if [ $1 = 0 ]; then 106 | service %{name} stop > /dev/null 2>&1 107 | chkconfig --del %{name} 108 | fi 109 | 110 | %files 111 | %defattr(-,root,root) 112 | %{_sbindir}/etc* 113 | %{_defaultdocdir}/%{name}-v%{version}/*.md 114 | %attr(0755,%{etcd_user},%{etcd_group}) %dir %{_localstatedir}/log/%{name} 115 | %attr(0755,%{etcd_user},%{etcd_group}) %dir %{_localstatedir}/lib/%{name} 116 | %{_initrddir}/etcd 117 | %{_sysconfdir}/logrotate.d/%{name} 118 | %{_sysconfdir}/security/limits.d/etcd.nofiles.conf 119 | %config(noreplace) %{_sysconfdir}/sysconfig/%{name} 120 | 121 | %changelog 122 | * Tue Apr 10 2015 Hans-Joachim Skwirblies bump version to 2.0.9 123 | * Tue Mar 17 2015 Marco Lebbink 2.0.5 124 | * Thu Sep 18 2014 Derek Douville Remove golang, etcd is statically linked 125 | * Wed Sep 17 2014 Derek Douville 0.4.6 126 | * Mon Feb 10 2014 Nathan Milford 0.3.0 127 | * Sat Dec 28 2013 Nathan Milford 0.2.0 128 | * Thu Dec 05 2013 Nathan Milford 0.2.0-rc1 129 | * Mon Aug 12 2013 Nathan Milford 0.1.0-1 130 | - Initial spec. 131 | -------------------------------------------------------------------------------- /etcd.sysconfig: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2014, Nathan Milford 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Will be used to populate IP address values below. Setting some items to 17 | # '0.0.0.0' is not compatable with the discovery API. 18 | _MY_IPADDR=$(/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | sort | awk '{print $1}') 19 | 20 | # Daemon User 21 | ETCD_USER="etcd" 22 | 23 | # Communication Protocol Identifier (http://|https://) 24 | ETCD_PROTOCOL="http://" 25 | 26 | # Cluster Seeds 27 | # You can specify a list here sepearated by commas, or leave it blank if 28 | # you're playing with a single node. 29 | ETCD_SEEDS="" 30 | 31 | # Discovery Endpoint 32 | # Leave it as the public URL unless you are running your own. 33 | ETCD_DISCOVER_ENDPOINT="https://discovery.etcd.io/" 34 | 35 | # Discovery Token 36 | # If you are using the discovery protocol you can grab your cluster token 37 | # from https://discovery.etcd.io/new if you are not hosting it yourself. 38 | ETCD_DISCOVERY_TOKEN="" 39 | 40 | # Discovery using SRV DNS Records 41 | # Configure the domain that serves the etcd cluster SRV records _etcd-server._tcp 42 | # and/or _etcd-server-https._tcp 43 | ETCD_DISCOVERY_SRV_DOMAIN="" 44 | 45 | # This node's name as it represents itself on the cluster. 46 | ETCD_NODE_NAME=$(hostname -s) 47 | 48 | # Hostname and port for the etcd server to work on. 49 | ETCD_LISTEN="${ETCD_PROTOCOL}localhost:4001,${ETCD_PROTOCOL}${_MY_IPADDR}:4001" 50 | 51 | # Directory to store log and snapshot. 52 | ETCD_DATA_DIR="/var/lib/etcd/" 53 | 54 | # File to log stdout/stderr to. 55 | ETCD_OUT_FILE="/var/log/etcd/etcd.out" 56 | 57 | # Set logging vebosity for the file above. 58 | # Valid options are "", "v" or "vv" 59 | ETCD_LOGGING="" 60 | 61 | # Set security settings for the etcd server. 62 | # Leave blank if you do not plan to use this feature, otherwise add appropriate 63 | # paths. 64 | ETCD_CAFILE="" 65 | ETCD_CERT="" 66 | ETCD_KEY="" 67 | 68 | # Toggles snapshotting. 69 | # Keep blank or set to true. 70 | ETCD_SNAPSHOT="" 71 | 72 | # Hostname and port for the RAFT server to work on. 73 | RAFT_LISTEN="${ETCD_PROTOCOL}${_MY_IPADDR}:7001" 74 | 75 | # Set security settings for the RAFT server. 76 | # Leave blank if you do not plan to use this feature, otherwise add appropriate 77 | # paths. 78 | RAFT_CAFILE="" 79 | RAFT_CERT="" 80 | RAFT_KEY="" 81 | 82 | # Below we build the opts to pass to the init script. 83 | 84 | ETCD_OPTS="-name=${ETCD_NODE_NAME} \ 85 | --listen-client-urls=${ETCD_LISTEN} \ 86 | --listen-peer-urls=${RAFT_LISTEN} \ 87 | -data-dir=${ETCD_DATA_DIR}" 88 | 89 | if [ x$ETCD_SEEDS != "x" ]; then 90 | ETCD_OPTS="$ETCD_OPTS -peers=${ETCD_SEEDS}" 91 | fi 92 | 93 | if [ x$ETCD_DISCOVERY_TOKEN != "x" ]; then 94 | ETCD_OPTS="$ETCD_OPTS -discovery=${ETCD_DISCOVER_ENDPOINT}${ETCD_DISCOVERY_TOKEN}" 95 | elif [ x$ETCD_DISCOVERY_SRV_DOMAIN != "x" ]; then 96 | ETCD_OPTS="$ETCD_OPTS --discovery-srv=${ETCD_DISCOVERY_SRV_DOMAIN}" 97 | fi 98 | 99 | if [ "$ETCD_LOGGING" == "v" ]; then 100 | ETCD_OPTS="$ETCD_OPTS -v" 101 | elif [ "$ETCD_LOGGING" == "vv" ]; then 102 | ETCD_OPTS="$ETCD_OPTS -vv" 103 | fi 104 | 105 | if [ x$ETCD_SNAPSHOT != "x" ]; then 106 | ETCD_OPTS="$ETCD_OPTS -snapshot" 107 | fi 108 | 109 | if [ x$ETCD_CAFILE != "x" ] && [ x$ETCD_CERT != "x" ] && [ x$ETCD_KEY != "x" ]; then 110 | ETCD_OPTS="$ETCD_OPTS -ca-file=${ETCD_CAFILE} -cert-file=${ETCD_CERT} -key-file=${ETCD_KEY}" 111 | fi 112 | 113 | if [ x$RAFT_CAFILE != "x" ] && [ x$RAFT_CERT != "x" ] && [ x$RAFT_KEY != "x" ]; then 114 | ETCD_OPTS="$ETCD_OPTS -peer-ca-file=${RAFT_CAFILE} -peer-cert-file=${RAFT_CERT} -peer-key-file=${RAFT_KEY}" 115 | fi 116 | 117 | # TODO 118 | # Add support for: 119 | # -peers-file 120 | # -config 121 | # -cors 122 | # -cpuprofile 123 | --------------------------------------------------------------------------------