-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·57 lines (52 loc) · 1.17 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
display_help() {
echo "Usage: $0 [OPTIONS]"
echo
echo "Options:"
echo " -d, --distribution <distro> Set the distribution ('arch' or 'debian')"
echo " --desktop Enable desktop mode"
echo " --help Show this help message"
echo
echo "Example usage:"
echo " $0 -d debian"
echo " $0 -d arch --desktop"
exit 0
}
# Function to validate the distribution
validate_distribution() {
if [[ "$1" != "arch" && "$1" != "debian" ]]; then
echo "Error: Invalid distribution. Allowed values are 'arch' or 'debian'."
exit 1
fi
}
# Initialize variables
DESKTOP=false
DISTRIBUTION=""
# Parse the options
while [[ $# -gt 0 ]]; do
case $1 in
--desktop)
DESKTOP=true
shift
;;
-d|--distribution)
DISTRIBUTION="$2"
validate_distribution "$DISTRIBUTION"
shift 2
;;
--help) display_help ;;
*)
echo "Unknown option: $1"
display_help
exit 1
;;
esac
done
if [ -n "$DISTRIBUTION" ]; then
tag="dotfiles-$DISTRIBUTION"
docker build -t "$tag" -f "$DISTRIBUTION.Dockerfile" .
docker run --rm -it "$tag"
else
echo "No distribution specified."
exit 1
fi