file check
This commit is contained in:
parent
dccebf189c
commit
251003985b
14
README.md
14
README.md
@ -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
54
container-compose
Executable 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 "$@"
|
Loading…
x
Reference in New Issue
Block a user