Add redis symlinks at the same place as the installed binaries (#193)
Adds a new make variable called `USE_REDIS_SYMLINKS`, with default value `yes`. If yes, then `make install` creates additional symlinks to the installed binaries: * `valkey-server` * `valkey-cli` * `valkey-benchmark` * `valkey-check-rdb` * `valkey-check-aof` * `valkey-sentinel` The names of the symlinks are the legacy redis binary names (`redis-server`, etc.). The purpose is to provide backward compatibility for scripts expecting the these filenames. The symlinks are installed in the same directory as the binaries (typically `/usr/local/bin/` or similar). Similarly, `make uninstall` removes these symlinks if `USE_REDIS_SYMLINKS` is `yes`. This is described in a note in README.md. Fixes #147 --------- Signed-off-by: Vitah Lin <vitahlin@gmail.com> Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
This commit is contained in:
parent
710674269e
commit
d79f094b66
@ -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
|
||||
|
35
src/Makefile
35
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))
|
||||
|
10
src/server.c
10
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[] */
|
||||
|
Loading…
x
Reference in New Issue
Block a user