This repository was archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusdocker.sh
More file actions
executable file
·122 lines (103 loc) · 2.47 KB
/
Copy pathusdocker.sh
File metadata and controls
executable file
·122 lines (103 loc) · 2.47 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
# Define REAL PATH
if hash realpath 2>/dev/null; then
USD_DIR=`realpath $0`
USD_DIR=`dirname $USD_DIR`
else
USD_DIR="$(dirname "$(readlink -f "$0")")"
fi
if [ ! -f "$USD_DIR/usdocker.sh" ]
then
echo "Cannot detect realpath :("
exit
fi
USD_INCLUDE="$USD_DIR/include"
USD_SCRIPTS="$USD_DIR/scripts"
USD_DOCS="$USD_DIR/docs"
source "$USD_INCLUDE/usdocker.include.sh"
if [ -z "$USD_BASE" ]; then
if [ ! -z "$DOCKER_HOST" ]; then
USD_BASE="/mnt/c"
else
USD_BASE="${HOME}"
fi
fi
USD_HOME="${USD_BASE}/.usdocker"
mkdir -p "$USD_HOME"
USD_DATA="${USD_BASE}/.usdocker_data"
mkdir -p "$USD_DATA"
setupEnvironment environment TZ `getLocalTimeZone`
setupEnvironment environment CONTAINER_NAME_SUFFIX -container
setupEnvironment environment MAPPING_DIR_FROM /mnt/c/
setupEnvironment environment MAPPING_DIR_TO C:/
source "$USD_HOME/environment"
if [ -z "$1" ]
then
showHeader
echo "Usage:"
echo " - usdocker <script> <command> [args]"
echo
echo "Where <scripts> are:"
find "${USD_SCRIPTS}/." -maxdepth 1 ! -name '.*' -type d -exec basename "{}" \; | sort | sed -e 's/^/ - /'
echo " - self-update"
echo
exit 1
fi
if [ "$1" == "env" ]
then
printGlobalEnvironment
exit
fi
if [ "$1" == "self-update" ]
then
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
cd $USD_DIR
git pull
exit
fi
USD_SERVICE="$1"
USD_LABEL="${1^^}"
if [ ! -d "$USD_SCRIPTS/$USD_SERVICE" ]
then
showHeader
echo "Useful Script Service '$USD_SERVICE' does not exists"
echo
exit 1
fi
shift
if [ -z "$1" ]
then
showHeader
echo Usage:
echo " - usdocker $USD_SERVICE <command>"
echo
echo "The commands available for $USD_SERVICE service are:"
find "${USD_SCRIPTS}/$USD_SERVICE/." -maxdepth 1 ! -name '.*' -name '*.sh' -type f -exec basename "{}" \; | sort | cut -d'.' -f1 | sed -e 's/^/ - /'
echo
echo "Documentation"
echo
cat "${USD_DOCS}/$USD_SERVICE.md"
echo
exit 1
fi
if [ "$1" == "env" ]
then
printServiceEnvironment
exit
fi
USD_COMMAND="$1"
if [ ! -f "$USD_SCRIPTS/$USD_SERVICE/$USD_COMMAND.sh" ]
then
showHeader
echo "Useful Script commans 'usdocker $USD_SERVICE $USD_COMMAND' does not exists"
echo
exit 1
fi
shift
if [ "$USD_SERVICE" != ".autocomplete" ] && [ "$USD_SERVICE" != "docker" ]; then
checkDockerInstalled
fi
source "${USD_SCRIPTS}/${USD_SERVICE}/${USD_COMMAND}.sh"