Remove Redis PATH from environment

One of customers HAA server in the cluster is down.

Issue Description

This article describes how to remove the Redis PATHs from the root PATH.

Background

The Redis install puts a PATH variable in the roots PATH variables. Since these directories are not owned by Root, security compliance may see this as a potential security issue. This is not an issue, the directory is owned by redislabs which has no login. However, we can remove the path if needed so it does not show up on audits and no exception is needed.

Resolution

**Don't run the restore unless needed.

# backup files
sudo cp /etc/profile.d/redislabs_env.sh ~/root/
sudo cp /etc/opt/redislabs/redislabs_env_config.sh ~/root/

Exporter wrapper scripts

for f in /opt/redislabs/bin/wrap_{node,statsd,cert,process}_exporter.sh; do
sudo cp "$f" ~/root/
done

Make the update

sudo sed -i 's|^(append_path_if_missing PATH ${bindir})|#\1|' /etc/profile.d/redislabs_env.sh
sudo sed -i '/^PATH=".redislabs./ s/^/#/' /etc/opt/redislabs/redislabs_env_config.sh
for f in /opt/redislabs/bin/wrap_{node,statsd,cert,process}_exporter.sh; do
sudo sed -i 's|^source wrap_exporter.sh|source ${bindir}/wrap_exporter.sh|' "$f"
done

Restore if needed

sudo cp ~/root/redislabs_env.sh /etc/profile.d/redislabs_env.sh
sudo cp ~/root/redislabs_env_config.sh /etc/opt/redislabs/redislabs_env_config.sh

Restore exporter wrapper scripts

for f in wrap_{node,statsd,cert,process}_exporter.sh; do
sudo cp ~/root/$f /opt/redislabs/bin/$f
done