package/redis: Add redis system user
PATCH v2 1/4 package/redis: Add redis system user
Add a redis system user and set the home directory to /var/lib/redis
---
Changes v1 -> v2
- Set redis user shell to /bin/false (Suggested by Thomas Petazzoni)
- Removed $(INSTALL) of /var/lib/redis (Suggested by Thomas Petazzoni)
--- package/redis/redis.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/redis/redis.mk +4 -0
@@ -9,6 +9,10 @@ REDIS_SITE = http://download.redis.io/releases REDIS_LICENSE = BSD-3c (core); MIT and BSD family licenses (Bundled components) REDIS_LICENSE_FILES = COPYING +define REDIS_USERS + redis -1 redis -1 * /var/lib/redis /bin/false - Redis Server +endef + # Redis doesn't support DESTDIR (yet, see # https://github.com/antirez/redis/pull/609). We set PREFIX # instead.
Signature · 1 line
2.1.4
PATCH v2 2/4 package/redis: Install /etc/redis.conf to target
Copy redis.conf from the redis release package but adjust some values to sensible defaults using 0003-redis.conf-sane-defaults.patch
The file 0003-redis.conf-sane-defaults.patch originates from the redis package in Arch Linux.
---
0003-redis.conf-sane-defaults.patch is a copy of the file redis.conf-sane-defaults.patch from the Arch Linux redis package. See
https://projects.archlinux.org/svntogit/community.git/tree/trunk/redis.conf-sane-defaults.patch?h=packages/redis&id=b4907d2344855caeadf6c69bc01c403a95f8a4f3
Changes v1 -> v2
- No changes
--- package/redis/0003-redis.conf-sane-defaults.patch | 37 +++++++++++++++++++++++ package/redis/redis.mk | 2 ++ 2 files changed, 39 insertions(+) create mode 100644 package/redis/0003-redis.conf-sane-defaults.patch
package/redis/0003-redis.conf-sane-defaults.patch new file +37 -0
@@ -0,0 +1,37 @@ +Taken from archlinux redis package +See https://projects.archlinux.org/svntogit/community.git/tree/trunk/redis.conf-sane-defaults.patch?h=packages/redis&id=5b2491ea61b746f289acebd12bc66e337d7e5b88 + +Signed-off-by: Martin Bark <[email protected]> + +========================================================================= +diff --git a/redis.conf b/redis.conf +index 6efb6ac..344e021 100644 +--- a/redis.conf ++++ b/redis.conf +@@ -61,7 +61,7 @@ tcp-backlog 511 + # Examples: + # + # bind 192.168.1.100 10.0.0.1 +-# bind 127.0.0.1 ++bind 127.0.0.1 + + # Specify the path for the Unix socket that will be used to listen for + # incoming connections. There is no default, so Redis will not listen +@@ -87,7 +87,7 @@ timeout 0 + # On other kernels the period depends on the kernel configuration. + # + # A reasonable value for this option is 60 seconds. +-tcp-keepalive 0 ++tcp-keepalive 60 + + # Specify the server verbosity level. + # This can be one of: +@@ -184,7 +184,7 @@ dbfilename dump.rdb + # 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/redis/ + + ################################# REPLICATION ################################# +
package/redis/redis.mk +2 -0
@@ -26,6 +26,8 @@ endef define REDIS_INSTALL_TARGET_CMDS $(TARGET_MAKE_ENV) $(MAKE) $(REDIS_BUILDOPTS) -C $(@D) \ LDCONFIG=true install + $(INSTALL) -D -m 0644 $(@D)/redis.conf \ + $(TARGET_DIR)/etc/redis.conf endef $(eval $(generic-package))
Signature · 1 line
2.1.4
PATCH v2 3/4 package/redis: Add systemV init script
In reply to Martin Barkstart-stop-daemon is used to start redis-server as user redis in the background. Once redis-server is running we use redis-cli to shutdown cleanly.
---
Changes v1 -> v2
- Change su - redis -c "/usr/bin/redis-cli shutdown" to just /usr/bin/redis-cli shutdown since redis users shell is now /bin/false. This is ok since redis-cli simply signals redis-server over a socket to shutdown.
--- package/redis/S50redis | 38 ++++++++++++++++++++++++++++++++++++++ package/redis/redis.mk | 5 +++++ 2 files changed, 43 insertions(+) create mode 100644 package/redis/S50redis
package/redis/S50redis new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh +# +# start redis +# + +start() { + echo -n "Starting redis: " + umask 077 + start-stop-daemon -S -q -c redis:redis -b \ + --exec /usr/bin/redis-server -- /etc/redis.conf + [ $? = 0 ] && echo "OK" || echo "FAIL" +} +stop() { + echo -n "Stopping redis: " + /usr/bin/redis-cli shutdown + [ $? = 0 ] && echo "OK" || echo "FAIL" +} +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?
package/redis/redis.mk +5 -0
@@ -30,4 +30,9 @@ define REDIS_INSTALL_TARGET_CMDS $(TARGET_DIR)/etc/redis.conf endef +define REDIS_INSTALL_INIT_SYSV + $(INSTALL) -m 0755 -D package/redis/S50redis \ + $(TARGET_DIR)/etc/init.d/S50redis +endef + $(eval $(generic-package))
Signature · 1 line
2.1.4
PATCH v2 4/4 package/redis: Add systemd service
In reply to Martin Barkredis.service originates from the redis package in Arch Linux.
---
redis.service is copied from the Arch Linux redis package. See
https://projects.archlinux.org/svntogit/community.git/tree/trunk/redis.service?h=packages/redis&id=b4907d2344855caeadf6c69bc01c403a95f8a4f3
Changes v1 -> v2
- No changes
--- package/redis/redis.mk | 8 ++++++++ package/redis/redis.service | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 package/redis/redis.service
package/redis/redis.mk +8 -0
@@ -35,4 +35,12 @@ define REDIS_INSTALL_INIT_SYSV $(TARGET_DIR)/etc/init.d/S50redis endef +define REDIS_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 0644 package/redis/redis.service \ + $(TARGET_DIR)/usr/lib/systemd/system/redis.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -fs ../../../../usr/lib/systemd/system/redis.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/redis.service +endef + $(eval $(generic-package))
package/redis/redis.service new file +22 -0
@@ -0,0 +1,22 @@ +[Unit] +Description=Advanced key-value store +After=network.target + +[Service] +Type=simple +User=redis +Group=redis +ExecStart=/usr/bin/redis-server /etc/redis.conf +ExecStop=/usr/bin/redis-cli shutdown +CapabilityBoundingSet= +PrivateTmp=true +PrivateDevices=true +ProtectSystem=full +ProtectHome=true +NoNewPrivileges=true +RuntimeDirectory=redis +RuntimeDirectoryMode=755 +LimitNOFILE=10032 + +[Install] +WantedBy=multi-user.target
Signature · 1 line
2.1.4
PATCH v2 1/4 package/redis: Add redis system user
In reply to Martin BarkDear Martin Bark,
Quoted 11 lines · Martin Bark
Add a redis system user and set the home directory to
/var/lib/redisSigned-off-by Martin Bark <[email protected]>---
Changes v1 -> v2
- Set redis user shell to/bin/false(Suggested by Thomas Petazzoni)
- Removed $(INSTALL) of/var/lib/redis(Suggested by Thomas Petazzoni)--- package/redis/redis.mk | 4 ++++ 1 file changed, 4 insertions(+)
All four patches applied, thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/4 package/redis: Add redis system user
Quoted 15 lines · Thomas Petazzoni
Dear Martin Bark,
Quoted 11 lines · Martin Bark
Add a redis system user and set the home directory to
/var/lib/redisSigned-off-by Martin Bark <[email protected]>---
Changes v1 -> v2
- Set redis user shell to/bin/false(Suggested by Thomas Petazzoni)
- Removed $(INSTALL) of/var/lib/redis(Suggested by Thomas Petazzoni)--- package/redis/redis.mk | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 3 lines
All four patches applied, thanks!
Thomas
Thanks Thomas
Quoted 4 lines
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com