30 lines
597 B
Bash
30 lines
597 B
Bash
#!/bin/bash
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 <service_name>"
|
|
exit 1
|
|
fi
|
|
|
|
SERVICE_NAME=$1
|
|
TEMPLATE="service.template"
|
|
TARGET="compose.yaml"
|
|
|
|
if [ ! -f "$TEMPLATE" ]; then
|
|
echo "Error: Template file '$TEMPLATE' not found!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$TARGET" ]; then
|
|
echo "Error: Target file '$TARGET' not found!"
|
|
exit 1
|
|
fi
|
|
|
|
sed -e "s/{{SERVICE_NAME}}/$SERVICE_NAME/g" "$TEMPLATE" >> "$TARGET"
|
|
|
|
echo "Service '$SERVICE_NAME' successfully added to $TARGET"
|
|
|
|
docker compose create $SERVICE_NAME
|
|
docker compose start $SERVICE_NAME
|
|
|
|
echo "docker container created and started"
|