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
620d325fdc
commit
ba0c93cbdf
@ -183,6 +183,11 @@ In order to install Valkey 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 Valkey, but if you are installing
|
||||
|
37
src/Makefile
37
src/Makefile
@ -325,10 +325,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
|
||||
|
||||
SERVER_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
|
||||
@ -529,6 +552,18 @@ install: all
|
||||
@ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_CHECK_RDB_NAME)
|
||||
@ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_CHECK_AOF_NAME)
|
||||
@ln -sf $(SERVER_NAME) $(INSTALL_BIN)/$(ENGINE_SENTINEL_NAME)
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(SERVER_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CLI_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_BENCHMARK_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CHECK_RDB_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_CHECK_AOF_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(ENGINE_SENTINEL_NAME),$(INSTALL_BIN))
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_BIN)/{$(SERVER_NAME),$(ENGINE_BENCHMARK_NAME),$(ENGINE_CLI_NAME),$(ENGINE_CHECK_RDB_NAME),$(ENGINE_CHECK_AOF_NAME),$(ENGINE_SENTINEL_NAME)}
|
||||
@rm -f $(INSTALL_BIN)/{$(SERVER_NAME),$(ENGINE_BENCHMARK_NAME),$(ENGINE_CLI_NAME),$(ENGINE_CHECK_RDB_NAME),$(ENGINE_CHECK_AOF_NAME),$(ENGINE_SENTINEL_NAME)}
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(SERVER_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CLI_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_BENCHMARK_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_RDB_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_AOF_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_SENTINEL_NAME))
|
10
src/server.c
10
src/server.c
@ -7001,6 +7001,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