file check

This commit is contained in:
Shihaam Abdul Rahman 2023-10-05 23:58:26 +05:00
parent dccebf189c
commit 251003985b
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
2 changed files with 67 additions and 1 deletions

View File

@ -1,3 +1,15 @@
# container-compose
neither docker-compose or podman-compose supports building multi arch images and push them to registrar. this is a bash script to attempt to fix it and add support for it.
neither docker-compose or podman-compose supports building multi arch images and push them to registrar. this is a bash script to attempt to fix it and add support for it.
This script checks if current dir has one of these files, in this oder
```text
compose.yaml
compose.yml
docker-compose.yaml
docker-compose.yml
podman-compose.yaml
container-compose.yaml
container-compose.yml
```

54
container-compose Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
check_file() {
local file=""
local opt
local OPTARG
local OPTIND=1
# Check if -f flag is provided
while getopts ":f:" opt; do
case $opt in
f)
file="$OPTARG"
;;
\?)
echo "Usage: $0 [-f file]"
return 1
;;
:)
echo "Option -$OPTARG requires an argument."
return 1
;;
esac
done
# Check if file is provided, if not look for default files
if [ -z "$file" ]; then
if [ -f "compose.yaml" ]; then
file="compose.yaml"
elif [ -f "compose.yml" ]; then
file="compose.yml"
elif [ -f "docker-compose.yaml" ]; then
file="docker-compose.yaml"
elif [ -f "docker-compose.yml" ]; then
file="docker-compose.yml"
elif [ -f "podman-compose.yaml" ]; then
file="podman-compose.yaml"
elif [ -f "container-compose.yaml" ]; then
file="container-compose.yaml"
elif [ -f "container-compose.yml" ]; then
file="container-compose.yml"
else
echo "no compose.yaml, compose.yml, docker-compose.yaml, docker-compose.yml, podman-compose.yaml, container-compose.yaml or container-compose.yml file found, pass files with -f"
return 1
fi
elif [ ! -f "$file" ]; then
echo "File $file not found."
return 1
fi
# Output the file being used
echo "Using $file"
}
check_file "$@"