forked from axonasif/dotsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bashbox.sh
97 lines (82 loc) · 2.79 KB
/
Bashbox.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
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
NAME="dotfiles"
CODENAME="dotfiles"
AUTHORS=("AXON <[email protected]>")
VERSION="1.0"
DEPENDENCIES=(
std::HEAD
)
REPOSITORY="https://github.com/axonasif/dotfiles.git"
BASHBOX_COMPAT="0.3.9~"
bashbox::build::after() {
local _script_name='install.sh';
local root_script="$_arg_path/$_script_name";
cp "$_target_workfile" "$root_script";
chmod 0755 "$root_script";
#sed -i 's|#!/usr/bin/env bash|#!/usr/bin/bash -i|' "$root_script";
}
bashbox::build::before() {
rm -rf "$_arg_path/.private";
}
live() (
# if test "$1" == "r"; then {
cmd="bashbox build --release";
log::info "Running '$cmd";
$cmd;
# } fi
local duplicate_repo_root="/tmp/.mrroot";
log::info "Creating a clone of $GITPOD_REPO_ROOT at $duplicate_repo_root" && {
rm -rf "$duplicate_repo_root";
cp -ra "$GITPOD_REPO_ROOT" "$duplicate_repo_root";
}
local ide_mirror="/tmp/.idem";
if test ! -e "$ide_mirror"; then {
log::info "Creating /ide mirror";
cp -ra /ide "$ide_mirror";
} fi
log::info "Starting a fake Gitpod workspace with headless IDE" && {
local ide_cmd ide_port;
ide_cmd="$(ps -p $(pgrep -f 'sh /ide/bin/gitpod-code --install-builtin-extension') -o args --no-headers)";
ide_port="33000";
ide_cmd="${ide_cmd//23000/${ide_port}} >/ide/server_log 2>&1";
local docker_args=(
run
--net=host
# Shared mountpoints
-v "$duplicate_repo_root:/$GITPOD_REPO_ROOT"
-v "$duplicate_repo_root:$HOME/.dotfiles"
-v "$ide_mirror:/ide"
-v /usr/bin/gp:/usr/bin/gp:ro
# Environment vars
-e GP_EXTERNAL_BROWSER
-e GP_OPEN_EDITOR
-e GP_PREVIEW_BROWSER
-e GITPOD_ANALYTICS_SEGMENT_KEY
-e GITPOD_ANALYTICS_WRITER
-e GITPOD_CLI_APITOKEN
-e GITPOD_GIT_USER_EMAIL
-e GITPOD_GIT_USER_NAME
-e GITPOD_HOST
-e GITPOD_IDE_ALIAS
-e GITPOD_INSTANCE_ID
-e GITPOD_INTERVAL
-e GITPOD_MEMORY
-e GITPOD_OWNER_ID
-e GITPOD_PREVENT_METADATA_ACCESS
-e GITPOD_REPO_ROOT
-e GITPOD_REPO_ROOTS
-e GITPOD_TASKS
-e GITPOD_THEIA_PORT
-e GITPOD_WORKSPACE_CLASS
-e GITPOD_WORKSPACE_CLUSTER_HOST
-e GITPOD_WORKSPACE_CONTEXT
-e GITPOD_WORKSPACE_CONTEXT_URL
-e GITPOD_WORKSPACE_ID
-e GITPOD_WORKSPACE_URL
# Container image
-it gitpod/workspace-base:latest
# Startup command
/bin/sh -lic "eval \$(gp env -e); $ide_cmd & \$HOME/.dotfiles/install.sh; exec bash -l"
)
docker "${docker_args[@]}";
}
)