From 05f678a18c98b1cc4126508611e760c319ba517f Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Tue, 28 May 2024 16:27:47 +0200 Subject: [PATCH] initial package creation Signed-off-by: Toshaan Bharvani --- SOURCES/icinga-conf.patch | 180 ++++++++++++++ SOURCES/icinga-deps.patch | 196 +++++++++++++++ SOURCES/icinga-src.patch | 95 ++++++++ SOURCES/icinga-utils.patch | 73 ++++++ SOURCES/icingadb-redis-limit-systemd | 14 ++ SOURCES/icingadb-redis-sentinel.service | 18 ++ SOURCES/icingadb-redis-shutdown | 40 ++++ SOURCES/icingadb-redis.logrotate | 9 + SOURCES/icingadb-redis.service | 18 ++ SOURCES/macros.icingadb-redis | 2 + SPECS/icingadb-redis.spec | 301 ++++++++++++++++++++++++ 11 files changed, 946 insertions(+) create mode 100644 SOURCES/icinga-conf.patch create mode 100644 SOURCES/icinga-deps.patch create mode 100644 SOURCES/icinga-src.patch create mode 100644 SOURCES/icinga-utils.patch create mode 100644 SOURCES/icingadb-redis-limit-systemd create mode 100644 SOURCES/icingadb-redis-sentinel.service create mode 100644 SOURCES/icingadb-redis-shutdown create mode 100644 SOURCES/icingadb-redis.logrotate create mode 100644 SOURCES/icingadb-redis.service create mode 100644 SOURCES/macros.icingadb-redis create mode 100644 SPECS/icingadb-redis.spec diff --git a/SOURCES/icinga-conf.patch b/SOURCES/icinga-conf.patch new file mode 100644 index 0000000..1314f82 --- /dev/null +++ b/SOURCES/icinga-conf.patch @@ -0,0 +1,180 @@ +Author: Henrik Triem +Date: Mon Jun 27 18:00:00 2022 +0100 + + Re-arrange patches + +diff --git a/redis.conf b/redis.conf +--- a/redis.conf ++++ b/redis.conf +@@ -135,7 +135,7 @@ + + # Accept connections on the specified port, default is 6379 (IANA #815344). + # If port 0 is specified Redis will not listen on a TCP socket. +-port 6379 ++port 6380 + + # TCP listen() backlog. + # +@@ -152,7 +152,7 @@ + # incoming connections. There is no default, so Redis will not listen + # on a unix socket when not specified. + # +-# unixsocket /run/redis.sock ++# unixsocket /run/icingadb-redis/icingadb-redis-server.sock + # unixsocketperm 700 + + # Close the connection after a client is idle for N seconds (0 to disable) +@@ -192,7 +192,7 @@ + # default port, use: + # + # port 0 +-# tls-port 6379 ++# tls-port 6380 + + # Configure a X.509 certificate and private key to use for authenticating the + # server to connected clients, masters or cluster peers. These files should be +@@ -306,7 +306,7 @@ + # By default Redis does not run as a daemon. Use 'yes' if you need it. + # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. + # When Redis is supervised by upstart or systemd, this parameter has no impact. +-daemonize no ++daemonize yes + + # If you run Redis from upstart or systemd, Redis can interact with your + # supervision tree. Options: +@@ -338,7 +338,7 @@ + # + # Note that on modern Linux systems "/run/redis.pid" is more conforming + # and should be used instead. +-pidfile /var/run/redis_6379.pid ++pidfile /run/icingadb-redis/icingadb-redis-server.pid + + # Specify the server verbosity level. + # This can be one of: +@@ -351,7 +351,7 @@ + # Specify the log file name. Also the empty string can be used to force + # Redis to log on the standard output. Note that if you use standard + # output for logging but daemonize, logs will be sent to /dev/null +-logfile "" ++logfile /var/log/icingadb-redis/icingadb-redis-server.log + + # To enable logging to the system logger, just set 'syslog-enabled' to yes, + # and optionally update the other syslog parameters to suit your needs. +@@ -501,7 +501,7 @@ + # The Append Only File will also be created inside this directory. + # + # Note that you must specify a directory here, not a file name. +-dir ./ ++dir /var/lib/icingadb-redis + + ################################# REPLICATION ################################# + +@@ -1022,7 +1022,7 @@ + # The format of the external ACL user file is exactly the same as the + # format that is used inside redis.conf to describe users. + # +-# aclfile /etc/redis/users.acl ++# aclfile /etc/icingadb-redis/users.acl + + # IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility + # layer on top of the new ACL system. The option effect will be just setting +@@ -1581,7 +1581,7 @@ + # Make sure that instances running in the same system do not have + # overlapping cluster configuration file names. + # +-# cluster-config-file nodes-6379.conf ++# cluster-config-file nodes-6380.conf + + # Cluster node timeout is the amount of milliseconds a node must be unreachable + # for it to be considered in failure state. +@@ -1790,9 +1790,9 @@ + # Example: + # + # cluster-announce-ip 10.1.1.5 +-# cluster-announce-tls-port 6379 ++# cluster-announce-tls-port 6380 + # cluster-announce-port 0 +-# cluster-announce-bus-port 6380 ++# cluster-announce-bus-port 6381 + + ################################## SLOW LOG ################################### + +diff --git a/sentinel.conf b/sentinel.conf +--- a/sentinel.conf ++++ b/sentinel.conf +@@ -7,22 +7,22 @@ + + # port + # The port that this sentinel instance will run on +-port 26379 ++port 26380 + + # By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it. +-# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when +-# daemonized. +-daemonize no ++# Note that Redis will write a pid file in /var/run/icingadb-redis-sentinel.pid ++# when daemonized. ++daemonize yes + + # When running daemonized, Redis Sentinel writes a pid file in +-# /var/run/redis-sentinel.pid by default. You can specify a custom pid file +-# location here. +-pidfile /var/run/redis-sentinel.pid ++# /var/run/icingadb-redis-sentinel.pid by default. You can specify a custom ++# pid file location here. ++pidfile /run/icingadb-sentinel/icingadb-redis-sentinel.pid + + # Specify the log file name. Also the empty string can be used to force + # Sentinel to log on the standard output. Note that if you use standard + # output for logging but daemonize, logs will be sent to /dev/null +-logfile "" ++logfile /var/log/icingadb-redis/icingadb-redis-sentinel.log + + # sentinel announce-ip + # sentinel announce-port +@@ -51,7 +51,7 @@ + # For Redis Sentinel to chdir to /tmp at startup is the simplest thing + # for the process to don't interfere with administrative tasks such as + # unmounting filesystems. +-dir /tmp ++dir /var/lib/icingadb-redis + + # sentinel monitor + # +@@ -70,7 +70,7 @@ + # + # Note: master name should not include special characters or spaces. + # The valid charset is A-z 0-9 and the three characters ".-_". +-sentinel monitor mymaster 127.0.0.1 6379 2 ++sentinel monitor mymaster 127.0.0.1 6380 2 + + # sentinel auth-pass + # +@@ -147,7 +147,7 @@ + # The format of the external ACL user file is exactly the same as the + # format that is used inside redis.conf to describe users. + # +-# aclfile /etc/redis/sentinel-users.acl ++# aclfile /etc/icingadb-redis/icingadb-sentinel-users.acl + + # requirepass + # +@@ -250,7 +250,7 @@ + # + # Example: + # +-# sentinel notification-script mymaster /var/redis/notify.sh ++# sentinel notification-script mymaster /var/icingadb-redis/notify.sh + + # CLIENTS RECONFIGURATION SCRIPT + # +@@ -275,7 +275,7 @@ + # + # Example: + # +-# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh ++# sentinel client-reconfig-script mymaster /var/icingadb-redis/reconfig.sh + + # SECURITY + # diff --git a/SOURCES/icinga-deps.patch b/SOURCES/icinga-deps.patch new file mode 100644 index 0000000..5620a06 --- /dev/null +++ b/SOURCES/icinga-deps.patch @@ -0,0 +1,196 @@ +Author: Henrik Triem +Date: Mon Jun 27 18:00:00 2022 +0100 + + Re-arrange patches + +diff --git a/deps/hiredis/Makefile b/deps/hiredis/Makefile +--- a/deps/hiredis/Makefile ++++ b/deps/hiredis/Makefile +@@ -24,7 +24,7 @@ INSTALL_LIBRARY_PATH= $(DESTDIR)$(PREFIX + INSTALL_PKGCONF_PATH= $(INSTALL_LIBRARY_PATH)/$(PKGCONF_PATH) + + # redis-server configuration used for testing +-REDIS_PORT=56379 ++REDIS_PORT=56380 + REDIS_SERVER=redis-server + define REDIS_TEST_CONFIG + daemonize yes + +diff --git a/deps/hiredis/test.c b/deps/hiredis/test.c +--- a/deps/hiredis/test.c ++++ b/deps/hiredis/test.c +@@ -799,7 +799,7 @@ static void test_allocator_injection(voi + hiredisSetAllocators(&ha); + + test("redisContext uses injected allocators: "); +- redisContext *c = redisConnect("localhost", 6379); ++ redisContext *c = redisConnect("localhost", 6380); + test_cond(c == NULL); + + test("redisReader uses injected allocators: "); +@@ -823,12 +823,12 @@ static void test_blocking_connection_err + struct addrinfo hints = {.ai_family = AF_INET}; + struct addrinfo *ai_tmp = NULL; + +- int rv = getaddrinfo(HIREDIS_BAD_DOMAIN, "6379", &hints, &ai_tmp); ++ int rv = getaddrinfo(HIREDIS_BAD_DOMAIN, "6380", &hints, &ai_tmp); + if (rv != 0) { + // Address does *not* exist + test("Returns error when host cannot be resolved: "); + // First see if this domain name *actually* resolves to NXDOMAIN +- c = redisConnect(HIREDIS_BAD_DOMAIN, 6379); ++ c = redisConnect(HIREDIS_BAD_DOMAIN, 6380); + test_cond( + c->err == REDIS_ERR_OTHER && + (strcmp(c->errstr, "Name or service not known") == 0 || +@@ -1885,7 +1885,7 @@ int main(int argc, char **argv) { + struct config cfg = { + .tcp = { + .host = "127.0.0.1", +- .port = 6379 ++ .port = 6380 + }, + .unix_sock = { + .path = "/tmp/redis.sock" +diff --git a/deps/hiredis/test.sh b/deps/hiredis/test.sh +--- a/deps/hiredis/test.sh ++++ b/deps/hiredis/test.sh +@@ -1,7 +1,7 @@ + #!/bin/sh -ue + + REDIS_SERVER=${REDIS_SERVER:-redis-server} +-REDIS_PORT=${REDIS_PORT:-56379} ++REDIS_PORT=${REDIS_PORT:-56380} + REDIS_SSL_PORT=${REDIS_SSL_PORT:-56443} + TEST_SSL=${TEST_SSL:-0} + SKIPS_AS_FAILS=${SKIPS_AS_FAILS-:0} + +diff --git a/deps/hiredis/examples/example-ae.c b/deps/hiredis/examples/example-ae.c +--- a/deps/hiredis/examples/example-ae.c ++++ b/deps/hiredis/examples/example-ae.c +@@ -43,7 +43,7 @@ void disconnectCallback(const redisAsync + int main (int argc, char **argv) { + signal(SIGPIPE, SIG_IGN); + +- redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); ++ redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6380); + if (c->err) { + /* Let *c leak for now... */ + printf("Error: %s\n", c->errstr); + +diff --git a/deps/hiredis/examples/example-glib.c b/deps/hiredis/examples/example-glib.c +--- a/deps/hiredis/examples/example-glib.c ++++ b/deps/hiredis/examples/example-glib.c +@@ -52,7 +52,7 @@ main (gint argc G_GNUC_UNUSED, + GMainContext *context = NULL; + GSource *source; + +- ac = redisAsyncConnect("127.0.0.1", 6379); ++ ac = redisAsyncConnect("127.0.0.1", 6380); + if (ac->err) { + g_printerr("%s\n", ac->errstr); + exit(EXIT_FAILURE); + +diff --git a/deps/hiredis/examples/example-ivykis.c b/deps/hiredis/examples/example-ivykis.c +--- a/deps/hiredis/examples/example-ivykis.c ++++ b/deps/hiredis/examples/example-ivykis.c +@@ -39,7 +39,7 @@ int main (int argc, char **argv) { + + iv_init(); + +- redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); ++ redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6380); + if (c->err) { + /* Let *c leak for now... */ + printf("Error: %s\n", c->errstr); + +diff --git a/deps/hiredis/examples/example-libev.c b/deps/hiredis/examples/example-libev.c +--- a/deps/hiredis/examples/example-libev.c ++++ b/deps/hiredis/examples/example-libev.c +@@ -37,7 +37,7 @@ int main (int argc, char **argv) { + signal(SIGPIPE, SIG_IGN); + #endif + +- redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); ++ redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6380); + if (c->err) { + /* Let *c leak for now... */ + printf("Error: %s\n", c->errstr); + +diff --git a/deps/hiredis/examples/example-libevent.c b/deps/hiredis/examples/example-libevent.c +--- a/deps/hiredis/examples/example-libevent.c ++++ b/deps/hiredis/examples/example-libevent.c +@@ -44,7 +44,7 @@ int main (int argc, char **argv) { + + struct event_base *base = event_base_new(); + redisOptions options = {0}; +- REDIS_OPTIONS_SET_TCP(&options, "127.0.0.1", 6379); ++ REDIS_OPTIONS_SET_TCP(&options, "127.0.0.1", 6380); + struct timeval tv = {0}; + tv.tv_sec = 1; + options.connect_timeout = &tv; + +diff --git a/deps/hiredis/examples/example-libuv.c b/deps/hiredis/examples/example-libuv.c +--- a/deps/hiredis/examples/example-libuv.c ++++ b/deps/hiredis/examples/example-libuv.c +@@ -54,7 +54,7 @@ int main (int argc, char **argv) { + + uv_loop_t* loop = uv_default_loop(); + +- redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); ++ redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6380); + if (c->err) { + /* Let *c leak for now... */ + printf("Error: %s\n", c->errstr); + +diff --git a/deps/hiredis/examples/example-macosx.c b/deps/hiredis/examples/example-macosx.c +--- a/deps/hiredis/examples/example-macosx.c ++++ b/deps/hiredis/examples/example-macosx.c +@@ -44,7 +44,7 @@ int main (int argc, char **argv) { + return 1; + } + +- redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); ++ redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6380); + if (c->err) { + /* Let *c leak for now... */ + printf("Error: %s\n", c->errstr); + +diff --git a/deps/hiredis/examples/example-push.c b/deps/hiredis/examples/example-push.c +--- a/deps/hiredis/examples/example-push.c ++++ b/deps/hiredis/examples/example-push.c +@@ -109,7 +109,7 @@ int main(int argc, char **argv) { + redisReply *reply; + + const char *hostname = (argc > 1) ? argv[1] : "127.0.0.1"; +- int port = (argc > 2) ? atoi(argv[2]) : 6379; ++ int port = (argc > 2) ? atoi(argv[2]) : 6380; + + redisOptions o = {0}; + REDIS_OPTIONS_SET_TCP(&o, hostname, port); + +diff --git a/deps/hiredis/examples/example-qt.cpp b/deps/hiredis/examples/example-qt.cpp +--- a/deps/hiredis/examples/example-qt.cpp ++++ b/deps/hiredis/examples/example-qt.cpp +@@ -19,7 +19,7 @@ void getCallback(redisAsyncContext *, vo + + void ExampleQt::run() { + +- m_ctx = redisAsyncConnect("localhost", 6379); ++ m_ctx = redisAsyncConnect("localhost", 6380); + + if (m_ctx->err) { + cerr << "Error: " << m_ctx->errstr << endl; + +diff --git a/deps/hiredis/examples/example.c b/deps/hiredis/examples/example.c +--- a/deps/hiredis/examples/example.c ++++ b/deps/hiredis/examples/example.c +@@ -21,7 +21,7 @@ int main(int argc, char **argv) { + } + } + +- int port = (argc > 2) ? atoi(argv[2]) : 6379; ++ int port = (argc > 2) ? atoi(argv[2]) : 6380; + + struct timeval timeout = { 1, 500000 }; // 1.5 seconds + if (isunix) { diff --git a/SOURCES/icinga-src.patch b/SOURCES/icinga-src.patch new file mode 100644 index 0000000..e031771 --- /dev/null +++ b/SOURCES/icinga-src.patch @@ -0,0 +1,95 @@ +Author: Henrik Triem +Date: Mon Jun 27 18:00:00 2022 +0100 + + Re-arrange patches + +diff --git a/src/config.c b/src/config.c +--- a/src/config.c ++++ b/src/config.c +@@ -3016,7 +3016,7 @@ standardConfig static_configs[] = { + + /* Integer configs */ + createIntConfig("databases", NULL, IMMUTABLE_CONFIG, 1, INT_MAX, server.dbnum, 16, INTEGER_CONFIG, NULL, NULL), +- createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6379, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */ ++ createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6380, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */ + createIntConfig("io-threads", NULL, DEBUG_CONFIG | IMMUTABLE_CONFIG, 1, 128, server.io_threads_num, 1, INTEGER_CONFIG, NULL, NULL), /* Single threaded by default */ + createIntConfig("auto-aof-rewrite-percentage", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.aof_rewrite_perc, 100, INTEGER_CONFIG, NULL, NULL), + createIntConfig("cluster-replica-validity-factor", "cluster-slave-validity-factor", MODIFIABLE_CONFIG, 0, INT_MAX, server.cluster_slave_validity_factor, 10, INTEGER_CONFIG, NULL, NULL), /* Slave max data age factor. */ + +diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c +--- a/src/redis-benchmark.c ++++ b/src/redis-benchmark.c +@@ -1741,7 +1741,7 @@ int main(int argc, char **argv) { + config.idlemode = 0; + config.clients = listCreate(); + config.conn_info.hostip = sdsnew("127.0.0.1"); +- config.conn_info.hostport = 6379; ++ config.conn_info.hostport = 6380; + config.hostsocket = NULL; + config.tests = NULL; + config.conn_info.input_dbnum = 0; + +diff --git a/src/redis-cli.c b/src/redis-cli.c +--- a/src/redis-cli.c ++++ b/src/redis-cli.c +@@ -8858,7 +8858,7 @@ int main(int argc, char **argv) { + + memset(&config.sslconfig, 0, sizeof(config.sslconfig)); + config.conn_info.hostip = sdsnew("127.0.0.1"); +- config.conn_info.hostport = 6379; ++ config.conn_info.hostport = 6380; + config.hostsocket = NULL; + config.repeat = 1; + config.interval = 0; + +diff --git a/src/sentinel.c b/src/sentinel.c +--- a/src/sentinel.c ++++ b/src/sentinel.c +@@ -49,7 +49,7 @@ extern SSL_CTX *redis_tls_ctx; + extern SSL_CTX *redis_tls_client_ctx; + #endif + +-#define REDIS_SENTINEL_PORT 26379 ++#define REDIS_SENTINEL_PORT 26380 + + /* ======================== Sentinel global state =========================== */ + + +diff --git a/src/server.c b/src/server.c +--- a/src/server.c ++++ b/src/server.c +@@ -1915,7 +1915,7 @@ void initServerConfig(void) { + + /* Replication related */ + server.masterhost = NULL; +- server.masterport = 6379; ++ server.masterport = 6380; + server.master = NULL; + server.cached_master = NULL; + server.master_initial_offset = -1; + +diff --git a/src/Makefile b/src/Makefile +--- a/src/Makefile ++++ b/src/Makefile +@@ -319,15 +319,15 @@ QUIET_LINK = @printf ' %b %b\n' $(LIN + QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; + endif + +-REDIS_SERVER_NAME=redis-server$(PROG_SUFFIX) +-REDIS_SENTINEL_NAME=redis-sentinel$(PROG_SUFFIX) ++REDIS_SERVER_NAME=icingadb-redis-server$(PROG_SUFFIX) ++REDIS_SENTINEL_NAME=icingadb-redis-sentinel$(PROG_SUFFIX) + REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o connection.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o +-REDIS_CLI_NAME=redis-cli$(PROG_SUFFIX) ++REDIS_CLI_NAME=icingadb-redis-cli$(PROG_SUFFIX) + REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o redisassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o +-REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX) ++REDIS_BENCHMARK_NAME=icingadb-redis-benchmark$(PROG_SUFFIX) + REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o +-REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX) +-REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX) ++REDIS_CHECK_RDB_NAME=icingadb-redis-check-rdb$(PROG_SUFFIX) ++REDIS_CHECK_AOF_NAME=icingadb-redis-check-aof$(PROG_SUFFIX) + ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ))) + + all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) diff --git a/SOURCES/icinga-utils.patch b/SOURCES/icinga-utils.patch new file mode 100644 index 0000000..18533c6 --- /dev/null +++ b/SOURCES/icinga-utils.patch @@ -0,0 +1,73 @@ +diff --git a/utils/generate-commands-json.py b/utils/generate-commands-json.py +--- a/utils/generate-commands-json.py ++++ b/utils/generate-commands-json.py +@@ -103,11 +103,11 @@ srcdir = os.path.abspath(os.path.dirname + if __name__ == '__main__': + opts = { + 'description': 'Transform the output from `redis-cli --json` using COMMAND and COMMAND DOCS to a single commands.json format.', +- 'epilog': f'Usage example: {argv[0]} --cli src/redis-cli --port 6379 > commands.json' ++ 'epilog': f'Usage example: {argv[0]} --cli src/redis-cli --port 6380 > commands.json' + } + parser = argparse.ArgumentParser(**opts) + parser.add_argument('--host', type=str, default='localhost') +- parser.add_argument('--port', type=int, default=6379) ++ parser.add_argument('--port', type=int, default=6380) + parser.add_argument('--cli', type=str, default='%s/redis-cli' % srcdir) + args = parser.parse_args() + + +diff --git a/utils/install_server.sh b/utils/install_server.sh +--- a/utils/install_server.sh ++++ b/utils/install_server.sh +@@ -60,7 +60,7 @@ SCRIPT=$(readlink -f $0) + SCRIPTPATH=$(dirname $SCRIPT) + + #Initial defaults +-_REDIS_PORT=6379 ++_REDIS_PORT=6380 + _MANUAL_EXECUTION=false + + echo "Welcome to the redis service installer" +@@ -212,7 +212,7 @@ REDIS_CHKCONFIG_INFO=\ + # chkconfig: - 58 74\n + # description: redis_${REDIS_PORT} is the redis daemon.\n + ### BEGIN INIT INFO\n +-# Provides: redis_6379\n ++# Provides: redis_6380\n + # Required-Start: \$network \$local_fs \$remote_fs\n + # Required-Stop: \$network \$local_fs \$remote_fs\n + # Default-Start: 2 3 4 5\n + +diff --git a/utils/redis-sha1.rb b/utils/redis-sha1.rb +--- a/utils/redis-sha1.rb ++++ b/utils/redis-sha1.rb +@@ -46,7 +46,7 @@ def redisSha1(opts={}) + end + + host = ARGV[0] || "127.0.0.1" +-port = ARGV[1] || "6379" ++port = ARGV[1] || "6380" + db = ARGV[2] || "0" + puts "Performing SHA1 of Redis server #{host} #{port} DB: #{db}" + p "Dataset SHA1: #{redisSha1(:host => host, :port => port.to_i, :db => db)}" + +diff --git a/utils/redis_init_script b/utils/redis_init_script +--- a/utils/redis_init_script ++++ b/utils/redis_init_script +@@ -4,14 +4,14 @@ + # as it does use of the /proc filesystem. + + ### BEGIN INIT INFO +-# Provides: redis_6379 ++# Provides: redis_6380 + # Default-Start: 2 3 4 5 + # Default-Stop: 0 1 6 + # Short-Description: Redis data structure server + # Description: Redis data structure server. See https://redis.io + ### END INIT INFO + +-REDISPORT=6379 ++REDISPORT=6380 + EXEC=/usr/local/bin/redis-server + CLIEXEC=/usr/local/bin/redis-cli + diff --git a/SOURCES/icingadb-redis-limit-systemd b/SOURCES/icingadb-redis-limit-systemd new file mode 100644 index 0000000..a792937 --- /dev/null +++ b/SOURCES/icingadb-redis-limit-systemd @@ -0,0 +1,14 @@ +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below. +# See "man systemd.exec" for more information. + +# Slave nodes on large system may take lot of time to start. +# You may need to uncomment TimeoutStartSec and TimeoutStopSec +# directives below and raise their value. +# See "man systemd.service" for more information. + +[Service] +LimitNOFILE=10240 +#TimeoutStartSec=90s +#TimeoutStopSec=90s diff --git a/SOURCES/icingadb-redis-sentinel.service b/SOURCES/icingadb-redis-sentinel.service new file mode 100644 index 0000000..92c88d8 --- /dev/null +++ b/SOURCES/icingadb-redis-sentinel.service @@ -0,0 +1,18 @@ +[Unit] +Description=IcingaDB Redis Sentinel +After=network.target +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/icingadb-redis-sentinel /etc/icingadb-redis/icingadb-sentinel.conf --daemonize no --supervised systemd +ExecStop=/usr/libexec/icingadb-redis-shutdown icingadb-sentinel +Type=notify +User=icingadb-redis +Group=icingadb-redis +RuntimeDirectory=icingadb-redis +RuntimeDirectoryMode=0755 + +[Install] +WantedBy=multi-user.target + diff --git a/SOURCES/icingadb-redis-shutdown b/SOURCES/icingadb-redis-shutdown new file mode 100644 index 0000000..803d865 --- /dev/null +++ b/SOURCES/icingadb-redis-shutdown @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Wrapper to close properly redis and sentinel +test x"$REDIS_DEBUG" != x && set -x + +REDIS_CLI=/usr/bin/icingadb-redis-cli + +# Retrieve service name +SERVICE_NAME="$1" +if [ -z "$SERVICE_NAME" ]; then + SERVICE_NAME=icingadb-redis +fi + +# Get the proper config file based on service name +CONFIG_FILE="/etc/icingadb-redis/$SERVICE_NAME.conf" + +# Use awk to retrieve host, port from config file +HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE | tail -n1` +PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE | tail -n1` +PASS=`awk '/^[[:blank:]]*requirepass/ { print $2 }' $CONFIG_FILE | tail -n1` +SOCK=`awk '/^[[:blank:]]*unixsocket\s/ { print $2 }' $CONFIG_FILE | tail -n1` + +# Just in case, use default host, port +HOST=${HOST:-127.0.0.1} +if [ "$SERVICE_NAME" = icingadb-redis ]; then + PORT=${PORT:-6380} +else + PORT=${PORT:-26739} +fi + +# Setup additional parameters +# e.g password-protected redis instances +[ -z "$PASS" ] || ADDITIONAL_PARAMS="-a $PASS" + +# shutdown the service properly +if [ -e "$SOCK" ] ; then + $REDIS_CLI -s $SOCK $ADDITIONAL_PARAMS shutdown +else + $REDIS_CLI -h $HOST -p $PORT $ADDITIONAL_PARAMS shutdown +fi diff --git a/SOURCES/icingadb-redis.logrotate b/SOURCES/icingadb-redis.logrotate new file mode 100644 index 0000000..ffade00 --- /dev/null +++ b/SOURCES/icingadb-redis.logrotate @@ -0,0 +1,9 @@ +/var/log/icingadb-redis/*.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/SOURCES/icingadb-redis.service b/SOURCES/icingadb-redis.service new file mode 100644 index 0000000..4c332b9 --- /dev/null +++ b/SOURCES/icingadb-redis.service @@ -0,0 +1,18 @@ +[Unit] +Description=IcingaDB Redis persistent key-value database +After=network.target +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/icingadb-redis-server /etc/icingadb-redis/icingadb-redis.conf --daemonize no --supervised systemd +ExecStop=/usr/libexec/icingadb-redis-shutdown +Type=notify +User=icingadb-redis +Group=icingadb-redis +RuntimeDirectory=icingadb-redis +RuntimeDirectoryMode=0755 + +[Install] +WantedBy=multi-user.target + diff --git a/SOURCES/macros.icingadb-redis b/SOURCES/macros.icingadb-redis new file mode 100644 index 0000000..b6d372b --- /dev/null +++ b/SOURCES/macros.icingadb-redis @@ -0,0 +1,2 @@ +%redis_modules_abi 1 +%redis_modules_dir %{_libdir}/icingadb-redis/modules diff --git a/SPECS/icingadb-redis.spec b/SPECS/icingadb-redis.spec new file mode 100644 index 0000000..4d041a2 --- /dev/null +++ b/SPECS/icingadb-redis.spec @@ -0,0 +1,301 @@ +%undefine _package_note_file +%global doc_commit e50ea1872e4efaf2a7174700050b7ce1c47dc2a8 +%global short_doc_commit %(c=%{doc_commit}; echo ${c:0:7}) +%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) +%global redis_port 6380 + +Name: icingadb-redis +Version: 7.0.5 +Release: 1%{?dist} +Summary: A persistent key-value database +License: BSD and MIT +URL: https://redis.io +Source0: https://download.redis.io/releases/redis-%{version}.tar.gz +Source1: icingadb-redis.logrotate +Source2: icingadb-redis-sentinel.service +Source3: icingadb-redis.service +Source6: icingadb-redis-shutdown +Source7: icingadb-redis-limit-systemd +Source9: macros.icingadb-redis +Source10: https://github.com/redis/redis-doc/archive/%{doc_commit}/redis-doc-%{short_doc_commit}.tar.gz +# To refresh patches: +# tar xf redis-xxx.tar.gz && cd redis-xxx && git init && git add . && git commit -m "%%{version} baseline" +# git am %%{patches} +# Then refresh your patches +# git format-patch HEAD~ +# Update configuration for Fedora +# https://github.com/redis/redis/pull/3491 - man pages +Patch0001: 0001-1st-man-pageis-for-redis-cli-redis-benchmark-redis-c.patch +# Update default port from 6370 to 6380 +Patch0901: icinga-conf.patch +Patch0902: icinga-deps.patch +Patch0903: icinga-src.patch +Patch0904: icinga-utils.patch +BuildRequires: make +BuildRequires: gcc +%if %{with tests} +BuildRequires: procps-ng +BuildRequires: tcl +%endif +BuildRequires: pkgconfig(libsystemd) +BuildRequires: systemd-devel +#BuildRequires: systemd-rpm-macros +BuildRequires: openssl-devel +Obsoletes: redis-trib < 5 +Requires: /bin/awk +Requires: logrotate +Requires(pre): shadow-utils +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +# from deps/hiredis/hiredis.h +Provides: bundled(hiredis) = 0.14.0 +# from deps/jemalloc/VERSION +Provides: bundled(jemalloc) = 5.2.1 +# from deps/lua/src/lua.h +Provides: bundled(lua-libs) = 5.1.5 +# from deps/linenoise/linenoise.h +Provides: bundled(linenoise) = 1.0 +Provides: bundled(lzf) +# from deps/hdr_histogram/README.md +Provides: bundled(hdr_histogram) = 0.11.0 +%global redis_modules_abi 1 +%global redis_modules_dir %{_libdir}/%{name}/modules +Provides: redis(modules_abi)%{?_isa} = %{redis_modules_abi} +Conflicts: icinga-redis + + +%description +Redis is an advanced key-value store. It is often referred to as a data +structure server since keys can contain strings, hashes, lists, sets and +sorted sets. +You can run atomic operations on these types, like appending to a string; +incrementing the value in a hash; pushing to a list; computing set +intersection, union and difference; or getting the member with highest +ranking in a sorted set. +In order to achieve its outstanding performance, Redis works with an +in-memory dataset. Depending on your use case, you can persist it either +by dumping the dataset to disk every once in a while, or by appending +each command to a log. +Redis also supports trivial-to-setup master-slave replication, with very +fast non-blocking first synchronization, auto-reconnection on net split +and so forth. +Other features include Transactions, Pub/Sub, Lua scripting, Keys with a +limited time-to-live, and configuration settings to make Redis behave like +a cache. +You can use Redis from most programming languages also. + + +%package devel +Summary: Development header for Redis module development +Provides: icingadb-redis-static = %{version}-%{release} +%description devel +Header file required for building loadable Redis modules. Detailed +API documentation is available in the redis-doc package. + +%package doc +Summary: Documentation for Redis including man pages +License: CC-BY-SA +BuildArch: noarch +Conflicts: redis < 4.0 +%description doc +Manual pages and detailed documentation for many aspects of Redis use, +administration and development. + + +%prep +%setup -q -b 10 -n redis-%{version} +%setup -q -n redis-%{version} +mv ../redis-doc-%{doc_commit} doc +%patch0001 -p1 +%patch0901 -p1 +%patch0902 -p1 +%patch0903 -p1 +%patch0904 -p1 +mv deps/lua/COPYRIGHT COPYRIGHT-lua +mv deps/jemalloc/COPYING COPYING-jemalloc +mv deps/hiredis/COPYING COPYING-hiredis +mv deps/hdr_histogram/LICENSE.txt LICENSE-hdrhistogram +mv deps/hdr_histogram/COPYING.txt COPYING-hdrhistogram +# Configuration file changes +sed -i -e 's|^logfile .*$|logfile /var/log/%{name}/redis.log|g' redis.conf +sed -i -e 's|^logfile .*$|logfile /var/log/%{name}/sentinel.log|g' sentinel.conf +sed -i -e 's|^dir .*$|dir /var/lib/%{name}|g' redis.conf +# Update redis port in config +sed -i -e 's|^port .*$|port %{redis_port}|'g redis.conf +sed -i -e 's|^port .*$|port 2%{redis_port}|'g sentinel.conf +# Update PID file in config +sed -i -e 's|^pidfile .*$|pidfile /var/run/%{name}/redis.pid|g' redis.conf +sed -i -e 's|^pidfile .*$|pidfile /var/run/%{name}/redis-sentinel.pid|g' sentinel.conf +# Module API version safety check +api=`sed -n -e 's/#define REDISMODULE_APIVER_[0-9][0-9]* //p' src/redismodule.h` +if test "$api" != "%{redis_modules_abi}"; then + : Error: Upstream API version is now ${api}, expecting %%{redis_modules_abi}. + : Update the redis_modules_abi macro, the rpmmacros file, and rebuild. + exit 1 +fi +%global make_flags DEBUG="" V="echo" LDFLAGS="%{?__global_ldflags}" CFLAGS+="%{optflags} -fPIC" INSTALL="install -p" PREFIX=%{buildroot}%{_prefix} BUILD_WITH_SYSTEMD=yes BUILD_TLS=yes + + +%build +%make_build %{make_flags} all + + +%install +make %{make_flags} install +# Filesystem. +install -d %{buildroot}%{_sharedstatedir}/%{name} +install -d %{buildroot}%{_localstatedir}/log/%{name} +install -d %{buildroot}%{_localstatedir}/run/%{name} +install -d %{buildroot}%{redis_modules_dir} +# Install logrotate file. +install -pDm644 %{S:1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +# Install configuration files. +#newicingaline1 +install -pd %{buildroot}%{_sysconfdir}/%{name} +install -pDm640 redis.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf +install -pDm640 sentinel.conf %{buildroot}%{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf +# Install systemd unit files. +mkdir -p %{buildroot}%{_unitdir} +install -pm644 %{S:3} %{buildroot}%{_unitdir}/%{name}.service +install -pm644 %{S:2} %{buildroot}%{_unitdir}/%{name}-sentinel.service +# Install systemd limit files (requires systemd >= 204) +install -p -D -m 644 %{S:7} %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf +install -p -D -m 644 %{S:7} %{buildroot}%{_sysconfdir}/systemd/system/%{name}-sentinel.service.d/limit.conf +# Fix non-standard-executable-perm error. +#newicingaline5 +for bin in $(cd %{buildroot}%{_bindir}; ls redis*); do + # Rename bin file and add prefix if set + [ -z %{?pkg_prefix} ] || mv %{buildroot}%{_bindir}/${bin} %{buildroot}%{_bindir}/%{?pkg_prefix}${bin} + chmod 755 %{buildroot}%{_bindir}/%{?pkg_prefix}${bin} +done +# Fix symlinks for checks +#newicingaline4 +if [ -n %{?pkg_prefix} ]; then + ln -svf %{name}-server %{buildroot}%{_bindir}/%{name}-check-aof + ln -svf %{name}-server %{buildroot}%{_bindir}/%{name}-check-rdb +fi +# Install redis-shutdown +install -pDm755 %{S:6} %{buildroot}%{_libexecdir}/%{name}-shutdown +# Install redis module header +install -pDm644 src/redismodule.h %{buildroot}%{_includedir}/%{name}module.h +# Install man pages +man=$(dirname %{buildroot}%{_mandir}) +for page in man/man?/*; do +#newicingaline3 + dir=$(dirname $page) + file=$(basename $page) + install -Dpm644 $page $man/$dir/icingadb-$file +done +ln -s redis-server.1 %{buildroot}%{_mandir}/man1/icingadb-redis-sentinel.1 +ln -s redis.conf.5 %{buildroot}%{_mandir}/man5/icingadb-redis-sentinel.conf.5 +# Install documentation and html pages +doc=$(echo %{buildroot}/%{_docdir}/%{name}) +for page in 00-RELEASENOTES BUGS MANIFESTO *.md; do + install -Dpm644 $page $doc/$page +done +for page in $(find doc -name \*.md | sed -e 's|.md$||g'); do + base=$(echo $page | sed -e 's|doc/||g') + install -Dpm644 $page.md $doc/$base.md +done +# Install rpm macros for redis modules +mkdir -p %{buildroot}%{macrosdir} +install -pDm644 %{S:9} %{buildroot}%{macrosdir}/macros.%{name} + + +%check +%if %{with tests} +# https://github.com/redis/redis/issues/1417 (for "taskset -c 1") +taskset -c 1 make %{make_flags} test +make %{make_flags} test-sentinel +%endif + + +%pre +getent group %{name} &> /dev/null || \ +groupadd -r %{name} &> /dev/null +getent passwd %{name} &> /dev/null || \ +useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \ +-c 'Redis Database Server' %{name} &> /dev/null +exit 0 +%post +if [ -f %{_sysconfdir}/%{name}.conf -a ! -L %{_sysconfdir}/%{name}.conf ]; then + if [ -f %{_sysconfdir}/%{name}/%{name}.conf.rpmnew ]; then + rm %{_sysconfdir}/%{name}/%{name}.conf.rpmnew + fi + if [ -f %{_sysconfdir}/%{name}/%{name}.conf ]; then + mv %{_sysconfdir}/%{name}/%{name}.conf %{_sysconfdir}/%{name}/%{name}.conf.rpmnew + fi + mv %{_sysconfdir}/%{name}.conf %{_sysconfdir}/%{name}/%{name}.conf + echo -e "\nWarning: %{name} configuration is now in %{_sysconfdir}/%{name} directory\n" +fi +if [ -f %{_sysconfdir}/%{name}-sentinel.conf -a ! -L %{_sysconfdir}/%{name}-sentinel.conf ]; then + if [ -f %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew ]; then + rm %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew + fi + if [ -f %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf ]; then + mv %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew + fi + mv %{_sysconfdir}/%{name}-sentinel.conf %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf +fi +/usr/sbin/semanage port -a -t redis_port_t -p tcp 6380 &> /dev/null || true +%systemd_post %{name}.service +%systemd_post %{name}-sentinel.service +%preun +%systemd_preun %{name}.service +%systemd_preun %{name}-sentinel.service +%postun +%systemd_postun_with_restart %{name}.service +%systemd_postun_with_restart %{name}-sentinel.service +if [ $1 -eq 0 ]; then + /usr/sbin/semanage port -d -t redis_port_t -p tcp 6380 &> /dev/null || true +fi + + +%files +%{!?_licensedir:%global license %%doc} +%license COPYING +%license COPYRIGHT-lua +%license COPYING-jemalloc +%license COPYING-hiredis +%license LICENSE-hdrhistogram +%license COPYING-hdrhistogram +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%attr(0750, %{name}, root) %dir %{_sysconfdir}/%{name} +%attr(0640, %{name}, root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf +%attr(0640, %{name}, root) %config(noreplace) %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf +%dir %attr(0750, %{name}, %{name}) %{_libdir}/%{name} +%dir %attr(0750, %{name}, %{name}) %{redis_modules_dir} +%dir %attr(0750, %{name}, %{name}) %{_sharedstatedir}/%{name} +%dir %attr(0750, %{name}, %{name}) %{_localstatedir}/log/%{name} +%exclude %{macrosdir} +%exclude %{_includedir} +%exclude %{_docdir}/%{name}/* +%{_bindir}/%{name}-* +%{_libexecdir}/%{name}-* +%{_mandir}/man1/%{name}* +%{_mandir}/man5/%{name}* +%{_unitdir}/%{name}.service +%{_unitdir}/%{name}-sentinel.service +%dir %{_sysconfdir}/systemd/system/%{name}.service.d +%config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf +%dir %{_sysconfdir}/systemd/system/%{name}-sentinel.service.d +%config(noreplace) %{_sysconfdir}/systemd/system/%{name}-sentinel.service.d/limit.conf +%dir %attr(0755, %{name}, %{name}) %ghost %{_localstatedir}/run/%{name} + + +%files devel +# main package is not required +%license COPYING +%{_includedir}/%{name}module.h +%{macrosdir}/* + + +%files doc +# specific for documentation (CC-BY-SA) +%license doc/LICENSE +%docdir %{_docdir}/%{name} +%{_docdir}/%{name} + + +%changelog