#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: https://mirrors.slickstack.io/bash/ss-install-redis-config.txt ######################## #### path: /var/www/ss-install-redis-config ######################################################## #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Reinstalls the Redis module config files based on ss-config (idempotent) ############# #### module version: Redis 5.0.x ################################################################### #### sourced by: ss-install, ss install redis ###################################################### #### bash aliases: ss install redis config ######################################################### #################################################################################################### ## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ## ## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ## ## source ss-config ## source /var/www/ss-config ## source ss-functions ## source /var/www/ss-functions ## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS #################################################################################################### #### TABLE OF CONTENTS (SS-Install-Redis-Config) ################################################### #################################################################################################### ## this is a brief summary of the different code snippets you will find in this script ## ## each section should be commented so you understand what is being accomplished ## ## A. Touch Timestamp File ## B. Message (Begin Script) #################################################################################################### #### A. SS-Install-Redis-Config: Touch Timestamp File ############################################## #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## ss_touch "${TIMESTAMP_SS_INSTALL_REDIS_CONFIG}" #################################################################################################### #### B. SS-Install-Redis-Config: Message (Begin Script) ############################################ #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## ss_echo "${COLOR_INFO}Running ss-install-redis-config... ${COLOR_RESET}" #################################################################################################### #### SS-Install-Redis-Config: Install Redis (Object Cache) ######################################### #################################################################################################### ## here we install redis-server (no client) for use in WordPress object caching (only) ## ## this Redis server package also includes the Redis CLI command line tools ## ## NEEDS TO BE IMPROVED AND EXPANDED ## ## configure redis-server for object caching only ## sed -i '/maxmemory.*bytes.*/c\maxmemory 256mb' "$PATH_REDIS_CONF" sed -i '/maxmemory-policy noeviction/c\maxmemory-policy allkeys-lru' "$PATH_REDIS_CONF" sed -i '/always-show-logo yes/c\always-show-logo no' "$PATH_REDIS_CONF" ## systemd since 16.04 LTS ## # sed -i '/supervised no/c\supervised systemd' "$PATH_REDIS_CONF" # sed -i '/logfile/c\logfile /var/www/logs/redis.log' "$PATH_REDIS_CONF" # sed -i '/dir /c\dir /tmp' "$PATH_REDIS_CONF" #################################################################################################### #### SS-Install-Redis: Reset Permissions (Redis) ################################################### #################################################################################################### ## run ss-perms-redis-config ## source "$PATH_SS_PERMS_REDIS_CONFIG" #################################################################################################### #### SS-Install-Redis: Purge Cache (Redis) ######################################################### #################################################################################################### ## run ss-purge-redis ## source "$PATH_SS_PURGE_REDIS" #################################################################################################### #### PLACEHOLDER: Reset Permissions (SlickStack Scripts) ########################################### #################################################################################################### ## we include this permissions reset in all cron jobs and bash scripts for redundancy ## ## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ## ## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS ## SNIPPET: ss bash scripts, ss cron jobs ## UPDATED: 02JUL2022 chown root:root /var/www/ss* ## must be root:root chown root:root /var/www/crons/*cron* ## must be root:root chown root:root /var/www/crons/custom/*cron* ## must be root:root chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: https://serverfault.com/questions/893066/redis-not-starting-with-systemctl ## Ref: https://stackoverflow.com/questions/48496250/redis-fails-to-start-with-error-redis-server-service-failed-at-step-namespace ## Ref: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-20-04 ## Ref: https://ostoday.org/linux/when-did-ubuntu-switch-to-systemd.html ## Ref: https://www.pcworld.com/article/2895517/ubuntu-just-switched-to-systemd-the-project-sparking-controversy-throughout-linux.html ## Ref: https://github.com/redis/redis/issues/5869 ## Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=883576 ## Ref: https://askubuntu.com/questions/839363/16-04-01-lts-on-aws-redis-no-longer-working ## SS_EOF