diff --git a/README.md b/README.md index 4a1ce7914..8a015a39e 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,11 @@ In order to install Redis binaries into /usr/local/bin, just use: You can use `make PREFIX=/some/other/directory install` if you wish to use a different destination. +_Note_: For compatibility with Redis, we create symlinks from the Redis names (`redis-server`, `redis-cli`, etc.) to the Valkey binaries installed by `make install`. +The symlinks are created in same directory as the Valkey binaries. +The symlinks are removed when using `make uninstall`. +The creation of the symlinks can be skipped by setting the makefile variable `USE_REDIS_SYMLINKS=no`. + `make install` will just install binaries in your system, but will not configure init scripts and configuration files in the appropriate place. This is not needed if you just want to play a bit with Redis, but if you are installing diff --git a/src/Makefile b/src/Makefile index e6d72f902..467eab706 100644 --- a/src/Makefile +++ b/src/Makefile @@ -319,10 +319,33 @@ ifndef V @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2 @$(INSTALL) $(1) $(2) endef + + define INSTALL_REDIS_SYMLINK + @printf ' %b %b %b %b %b %b %b\n' \ + $(LINKCOLOR)INSTALL SYMLINK$(ENDCOLOR) \ + $(BINCOLOR)$(subst $(ENGINE_NAME),redis,$(1))$(ENDCOLOR) -\> $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2 + @ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1)) + endef else define MAKE_INSTALL $(INSTALL) $(1) $(2) endef + + define INSTALL_REDIS_SYMLINK + ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1)) + endef +endif + +# Determine install/unstall Redis symlinks for compatibility when +# installing/uninstalling Valkey binaries (defaulting to `yes`) +USE_REDIS_SYMLINKS?=yes +ifeq ($(USE_REDIS_SYMLINKS),yes) + MAYBE_INSTALL_REDIS_SYMLINK=$(INSTALL_REDIS_SYMLINK) + MAYBE_UNINSTALL_REDIS_SYMLINK=@rm -f $(1)/$(subst $(ENGINE_NAME),redis,$(2)) + FINAL_CFLAGS+= -DUSE_REDIS_SYMLINKS +else + MAYBE_INSTALL_REDIS_SYMLINK= + MAYBE_UNINSTALL_REDIS_SYMLINK= endif REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) @@ -517,6 +540,18 @@ install: all @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_RDB_NAME) @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_AOF_NAME) @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_SERVER_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CLI_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_BENCHMARK_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CHECK_RDB_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CHECK_AOF_NAME),$(INSTALL_BIN)) + $(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_SENTINEL_NAME),$(INSTALL_BIN)) uninstall: rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)} + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_SERVER_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_CLI_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_BENCHMARK_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_CHECK_RDB_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_CHECK_AOF_NAME)) + $(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(REDIS_SENTINEL_NAME)) diff --git a/src/server.c b/src/server.c index 451f64c3d..1a0a2e5e8 100644 --- a/src/server.c +++ b/src/server.c @@ -7137,6 +7137,16 @@ int main(int argc, char **argv) { redis_check_rdb_main(argc,argv,NULL); else if (strstr(exec_name,"valkey-check-aof") != NULL) redis_check_aof_main(argc,argv); + + /* If enable USE_REDIS_SYMLINKS, valkey may install symlinks like + * redis-server -> valkey-server, redis-check-rdb -> valkey-check-rdb, + * redis-check-aof -> valkey-check-aof, etc. */ +#ifdef USE_REDIS_SYMLINKS + if (strstr(exec_name,"redis-check-rdb") != NULL) + redis_check_rdb_main(argc, argv, NULL); + else if (strstr(exec_name,"redis-check-aof") != NULL) + redis_check_aof_main(argc,argv); +#endif if (argc >= 2) { j = 1; /* First option to parse in argv[] */