-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebdev.sh
More file actions
118 lines (87 loc) · 3.05 KB
/
webdev.sh
File metadata and controls
118 lines (87 loc) · 3.05 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
#!/usr/bin/env bash
# Disable job control
set +m
# This file is the entrypoint for the tool and is required for the self-update
# Get the location of this script
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
# Directory where webdev is located
WEBDEVDIR=$SCRIPTPATH
# run the application and pass all arguments to it
dotnet "$WEBDEVDIR/webdev-tool.dll" "$@"
# Check if the update folder exists
if [ -d "$WEBDEVDIR/update" ]; then
cd $WEBDEVDIR
# Move all files from the update folder to the current one and remove it afterwards
rsync -a --exclude='certs/' --exclude='secrets/' update/* .
# Remove the update folder
rm -rf update
# Set execution rights for the shell script
chmod +x webdev.sh
fi
# Check if we want to start services
if [ -f "$WEBDEVDIR/.services_start" ]; then
startCommand=$(<"$WEBDEVDIR/.services_start")
rm "$WEBDEVDIR/.services_start"
if command -v docker-compose &> /dev/null; then
docker-compose $startCommand
else
docker compose $startCommand
fi
fi
# Check if we want to stop services
if [ -f "$WEBDEVDIR/.services_stop" ]; then
stopCommand=$(<"$WEBDEVDIR/.services_stop")
rm "$WEBDEVDIR/.services_stop"
if command -v docker-compose &> /dev/null; then
docker-compose $stopCommand
else
docker compose $stopCommand
fi
fi
# Check if we want to change the nodejs version
if [ -f "$WEBDEVDIR/.nodejs" ]; then
version=$(<"$WEBDEVDIR/.nodejs")
rm "$WEBDEVDIR/.nodejs"
source /usr/local/share/nvm/nvm.sh
nvm install $version
nvm use $version --save
fi
# Check if we want to start a devcontainer workspace
if [ -f "$WEBDEVDIR/.devcontainer_up" ]; then
rm "$WEBDEVDIR/.devcontainer_up"
devcontainer up --workspace-folder .
fi
if [ -f "$WEBDEVDIR/.workspaces_start" ]; then
# Read the file $WEBDEVDIR/.workspaces_start and iterate over each line
while IFS= read -r line; do
# Check if the line is not empty
if [ -n "$line" ]; then
# Start the workspace
cd "$line" || continue
devcontainer up --workspace-folder .
cd "$WEBDEVDIR" || exit 1
fi
done < "$WEBDEVDIR/.workspaces_start"
rm "$WEBDEVDIR/.workspaces_start"
# Show a summary of the workspaces to help user getting started
WEBDEV_DISABLE_HEADER=1 dotnet "$WEBDEVDIR/webdev-tool.dll" "workspaces-start-summary"
fi
if [ -f "$WEBDEVDIR/.workspaces_tasks" ] && [[ ! "$@" == *"--not-main"* ]]; then
WORKSPACE_DIR=$(pwd)
while IFS= read -r line; do
# Check if the line is not empty
if [ -n "$line" ]; then
# Execute the commands given in the variable
eval "$line"
cd "$WORKSPACE_DIR" || exit 1
fi
done < "$WEBDEVDIR/.workspaces_tasks"
rm "$WEBDEVDIR/.workspaces_tasks"
fi
# Check if we want to open a terminal in the devcontainer
if [ -f "$WEBDEVDIR/.terminal" ]; then
id=$(<"$WEBDEVDIR/.terminal")
rm "$WEBDEVDIR/.terminal"
docker exec -it -w /var/www/html $id bash
fi