-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins-run
More file actions
executable file
·94 lines (75 loc) · 2.94 KB
/
Copy pathplugins-run
File metadata and controls
executable file
·94 lines (75 loc) · 2.94 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
###
# File: test.sh
# Project: plugin.sunshine
# File Created: Sunday, 9th October 2022 12:39:35 am
# Author: Josh.5 (jsunnex@gmail.com)
# -----
# Last Modified: Sunday, 9th October 2022 6:32:56 pm
# Modified By: Josh.5 (jsunnex@gmail.com)
###
project_base_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Configure enabled services
if [[ -z "${ENABLED_SERVICES:-}" ]]; then
echo "No services are enabled. First populate a 'ENABLED_SERVICES' env variable with a list of services to run."
exit 0
fi
# Export default variables
export HOSTNAME
export PULSE_SERVER=${PULSE_SERVER:-unix:/tmp/pulse/pulse-socket}
# Specify compose command
docker_compose_command="docker compose"
if command -v docker-compose &> /dev/null; then
docker_compose_command="docker-compose"
fi
# Build selection docker-compose overrides based on execution environment
configure() {
pushd "${project_base_path}" &> /dev/null
compose_overrides=""
for service in $(ls ./services/); do
# Ignore anything in this directory that is not a directory
[[ ! -d ./services/${service} ]] && continue
# Check if the given service is configured to be enabled
if [[ "${ENABLED_SERVICES}" == *"${service}"* ]]; then
echo "Enabling service '${service}'"
# Add base compose file
compose_overrides="${compose_overrides} -f ./services/${service}/docker-compose.base.yml"
# Source all env variables
set -a
[[ -f ./services/${service}/base.env ]] && source ./services/${service}/base.env
set +a
# Check for intel hardware
if ls /dev/dri/render* &> /dev/null; then
if [[ -f "./services/${service}/overrides/docker-compose.dev-dri.yml" ]]; then
# Include 'dev-dri' override
compose_overrides="${compose_overrides} -f ./services/${service}/overrides/docker-compose.dev-dri.yml"
fi
fi
# Check for nvidia GPU hardware
nvidia_gpu=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
if [[ ! -z "${nvidia_pci_address}" ]]; then
if [[ -f "./services/${service}/overrides/docker-compose.nvidia.yml" ]]; then
# Include 'nvidia' override
compose_overrides="${compose_overrides} -f ./services/${service}/overrides/docker-compose.nvidia.yml"
fi
fi
fi
done
# Source user environment overrides
set -a
[[ -f /home/default/plugins.env ]] && source /home/default/plugins.env
set +a
popd &> /dev/null
}
# Execute compose arg
exec-compose-command() {
pushd "${project_base_path}" &> /dev/null
echo "Execute 'docker compose ${@}'"
${docker_compose_command} \
-f ./services/docker-compose.yml \
${compose_overrides} \
${@}
popd &> /dev/null
}
configure
exec-compose-command "${@}"