Open GoodM4ven opened 2 months ago
here it with a check first:
#!/bin/bash
# Path to the Memcached configuration file
CONFIG_FILE="/etc/memcached.conf"
# Function to check if the IPv6 configuration path exists
ipv6_config_path_exists() {
if [ -f "/proc/sys/net/ipv6/conf/all/disable_ipv6" ]; then
return 0 # True, path exists
else
return 1 # False, path does not exist
fi
}
# Check if the configuration file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "Configuration file does not exist: $CONFIG_FILE"
exit 1
fi
# Check if the IPv6 configuration path exists and update the configuration accordingly
if ! ipv6_config_path_exists; then
echo "IPv6 configuration path does not exist. Assuming IPv6 is not configured."
# Backup the original configuration file
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
# Comment out the IPv6 address
sed -i '/-l 127.0.0.1, ::1/s/^/#/' "$CONFIG_FILE"
# Restart Memcached service
systemctl restart memcached.service
# Check the status of the Memcached service
systemctl status memcached.service
else
echo "IPv6 configuration is available. No changes needed in the configuration."
fi
the service will not start if ipv6 is not set on the system
just disable using v6 and call it a day.
something like is: