-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpt.sh
68 lines (47 loc) · 1.68 KB
/
gpt.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
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# 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 gpt is located
GPTDIR=$SCRIPTPATH
# After an update, gpt will be installed in /workspace/.gpt so the update will not be lost after a restart
if [[ $SCRIPTPATH == "/home/gitpod/.gpt" ]] && [ -d "/workspace/.gpt" ] && [ -f "/workspace/.gpt/gitpod-tool.dll" ]; then
GPTDIR="/workspace/.gpt"
fi
# Fix wrong value of GITPOD_REPO_ROOT when openning a Gitpod snapshot
if [ "$GITPOD_REPO_ROOT" == '/workspace' ]; then
export GITPOD_REPO_ROOT="$THEIA_WORKSPACE_ROOT"
fi
# run the application and pass all arguments to it
dotnet "$GPTDIR/gitpod-tool.dll" "$@"
# Check if the update folder exists
if [ -d "/workspace/.gpt/update" ]; then
cd /workspace/.gpt
# Move all files from the update folder to the current one and remove it afterwards
mv update/* .
# Remove the update folder
rm -rf update
# Set execution rights for the shell script
chmod +x gpt.sh
fi
# Check if we want to start services
if [ -f "$GPTDIR/.services_start" ]; then
startCommand=$(<"$GPTDIR/.services_start")
rm "$GPTDIR/.services_start"
docker-compose $startCommand
fi
# Check if we want to stop services
if [ -f "$GPTDIR/.services_stop" ]; then
stopCommand=$(<"$GPTDIR/.services_stop")
rm "$GPTDIR/.services_stop"
docker-compose $stopCommand
fi
# Check if we want to change the nodejs version
if [ -f "$GPTDIR/.nodejs" ]; then
version=$(<"$GPTDIR/.nodejs")
rm "$GPTDIR/.nodejs"
. ~/.nvm/nvm.sh
nvm use $version
nvm alias default $version
fi