-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
42 lines (35 loc) · 1.28 KB
/
deploy.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
# Copyright (c) 2023 kk
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
export deploy_path=${deploy_path:-"$HOME/.krun"}
deploy::install() {
mkdir -pv "${deploy_path}"/bin
mkdir -pv "${deploy_path}"/config
command -v python >/dev/null && curl -s -o "${deploy_path}"/bin/krun https://raw.githubusercontent.com/kevin197011/krun/main/bin/krun ||
curl -s -o "${deploy_path}"/bin/krun https://raw.githubusercontent.com/kevin197011/krun/main/bin/krun-go/krun
chmod +x "${deploy_path}"/bin/krun
}
deploy::config() {
# mac
command -v brew >/dev/null && (grep -q "${deploy_path}/bin" ~/.zshrc || echo "export PATH=\$PATH:${deploy_path}/bin" >>~/.zshrc)
# ubuntu
[[ -f /etc/lsb-release ]] && grep -qi "ubuntu" /etc/lsb-release &&
apt-get update >/dev/null && apt-get install python3 -y && ln -sf /usr/bin/python3 /usr/bin/python
grep -q "${deploy_path}/bin" ~/.bashrc || echo "export PATH=\$PATH:${deploy_path}/bin" >>~/.bashrc
}
deploy::status() {
command -v brew >/dev/null && /bin/zsh || /bin/bash
"${deploy_path}"/bin/krun status
exec bash
}
deploy::uninstall() {
rm -rf "${deploy_path}"
}
deploy::main() {
deploy::install
deploy::config
deploy::status
}
# run main
deploy::main "$@"