forked from verily-src/workbench-app-devcontainers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (56 loc) · 1.86 KB
/
install.sh
File metadata and controls
executable file
·73 lines (56 loc) · 1.86 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
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
readonly USERNAME="${USERNAME:-"root"}"
install_gemini_cli() {
local username="${1}"
echo "Installing Gemini CLI..."
if [ "${username}" = "root" ]; then
npm install -g @google/gemini-cli
else
local nvm_dir="${NVM_DIR:-/usr/local/share/nvm}"
local user_home
user_home=$(eval echo "~${username}" 2>/dev/null || echo "/home/${username}")
[ -d "${nvm_dir}" ] && chown -R "${username}:" "${nvm_dir}"
[ -d "${user_home}/.npm" ] && chown -R "${username}:" "${user_home}/.npm"
sudo -u "${username}" env PATH="${PATH}" npm install -g @google/gemini-cli
fi
if which gemini >/dev/null 2>&1; then
echo "Gemini CLI installed successfully!"
return 0
else
echo "ERROR: Gemini CLI installation failed!"
return 1
fi
}
fix_permissions() {
local username="${1}"
if [ "${username}" = "root" ]; then
return 0
fi
local user_home
user_home=$(eval echo "~${username}" 2>/dev/null || echo "/home/${username}")
mkdir -p "${user_home}/.gemini"
printf '{"general.enableAutoUpdate": false, "ui": {"autoThemeSwitching": false, "theme": "ANSI Light"}}\n' > "${user_home}/.gemini/settings.json"
chown -R "${username}:" "${user_home}/.gemini"
}
print_nodejs_requirement() {
cat <<EOF
ERROR: Node.js and npm are required but not found!
Please add the Node.js feature to your devcontainer.json:
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"./.devcontainer/features/gemini-cli": { "username": "your-user" }
}
EOF
exit 1
}
echo "Activating feature 'gemini-cli'"
if ! command -v node >/dev/null || ! command -v npm >/dev/null; then
print_nodejs_requirement
fi
install_gemini_cli "${USERNAME}" || exit 1
fix_permissions "${USERNAME}"
echo "Done!"