-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstart.sh
More file actions
74 lines (67 loc) · 2.06 KB
/
start.sh
File metadata and controls
74 lines (67 loc) · 2.06 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Script to start Docker Compose with current user permissions
# Exit on error
set -e
# Warning about experimental status
echo "⚠️ WARNING: This script is experimental ⚠️"
echo "If you encounter any issues, you can run the following command directly:"
echo "UID=$(id -u) GID=$(id -g) docker compose up"
echo
# Function to display help message
show_help() {
echo "Usage: $0 [OPTIONS]"
echo
echo "Start the just-chat application using Docker or Podman"
echo
echo "Options:"
echo " -d, --detach Run containers in the background"
echo " -h, --help Show this help message"
echo
echo "Examples:"
echo " $0 # Run in foreground mode"
echo " $0 --detach # Run in background mode"
echo
}
# Default to attached mode
DETACH_MODE=""
# Process command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-d|--detach)
DETACH_MODE="-d"
shift
;;
-h|--help)
show_help
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
echo "Starting just-chat application..."
echo "Will attempt to run using Docker or fall back to Podman if available"
echo "---------------------------------------------------------------------"
# Check if Docker is installed
if command -v docker &> /dev/null; then
echo "Using Docker"
if [ -n "$DETACH_MODE" ]; then
echo "Running in detached mode"
fi
# Use USER_ID and GROUP_ID directly
USER_ID=$(id -u) GROUP_ID=$(id -g) docker compose up $DETACH_MODE
# If Docker is not available, try Podman
elif command -v podman &> /dev/null; then
echo "Docker not found, falling back to Podman"
if [ -n "$DETACH_MODE" ]; then
echo "Running in detached mode"
fi
# Use USER_ID and GROUP_ID directly
USER_ID=$(id -u) GROUP_ID=$(id -g) podman-compose up $DETACH_MODE
else
echo "Error: Neither Docker nor Podman is installed or in PATH"
exit 1
fi