docker creators

This commit is contained in:
2025-01-14 10:25:35 +01:00
parent e1c93e8f98
commit 23c1456e7e
15 changed files with 858 additions and 6 deletions

View File

@@ -297,6 +297,73 @@ remove_all() {
}
# Function to check if a service is running and start it if needed
check_and_start_redis() {
# Normal service management for non-container environments
if [[ "${OSNAME}" == "ubuntu" ]] || [[ "${OSNAME}" == "debian" ]]; then
# Check if running inside a container
if grep -q "/docker/" /proc/1/cgroup || [ ! -d "/run/systemd/system" ]; then
echo "Running inside a container. Starting redis directly."
if pgrep redis-server > /dev/null; then
echo "redis is already running."
else
echo "redis is not running. Starting it in the background..."
redis-server --daemonize yes
if pgrep redis-server > /dev/null; then
echo "redis started successfully."
else
echo "Failed to start redis. Please check logs for details."
exit 1
fi
fi
return
fi
if systemctl is-active --quiet "redis"; then
echo "redis is already running."
else
echo "redis is not running. Starting it..."
sudo systemctl start "redis"
if systemctl is-active --quiet "redis"; then
echo "redis started successfully."
else
echo "Failed to start redis. Please check logs for details."
exit 1
fi
fi
elif [[ "${OSNAME}" == "darwin"* ]]; then
if brew services list | grep -q "^redis.*started"; then
echo "redis is already running."
else
echo "redis is not running. Starting it..."
brew services start redis
fi
elif [[ "${OSNAME}" == "alpine"* ]]; then
if rc-service "redis" status | grep -q "running"; then
echo "redis is already running."
else
echo "redis is not running. Starting it..."
rc-service "redis" start
fi
elif [[ "${OSNAME}" == "arch"* ]]; then
if systemctl is-active --quiet "redis"; then
echo "redis is already running."
else
echo "redis is not running. Starting it..."
sudo systemctl start "redis"
fi
else
echo "Service management for redis is not implemented for platform: $OSNAME"
exit 1
fi
}
# Handle remove if requested
if [ "$REMOVE" = true ]; then
remove_all
@@ -390,6 +457,8 @@ if ! command_exists v; then
exit 1
fi
check_and_start_redis
if [ "$HEROLIB" = true ]; then
hero_lib_get
~/code/github/freeflowuniverse/herolib/install_herolib.vsh