GoodM4ven / lara-stacker

Develop Laravel full-stack applications locally.
MIT License
1 stars 0 forks source link

memcached might need disabling ipv6 #22

Open GoodM4ven opened 2 months ago

GoodM4ven commented 2 months ago

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:

#!/bin/bash

# Path to the Memcached configuration file
CONFIG_FILE="/etc/memcached.conf"

# Check if the configuration file exists
if [ ! -f "$CONFIG_FILE" ]; then
    echo "Configuration file does not exist: $CONFIG_FILE"
    exit 1
fi

# 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
GoodM4ven commented 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