-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall.sh
executable file
·57 lines (47 loc) · 1.87 KB
/
install.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
#!/bin/sh
if [ $(uname) != 'Linux' ]; then
echo "This script is designed for linux only, sorry!"
exit 1
fi
set -e
RED='[1;31m'
GREEN='[1;32m'
YELLOW='[1;33m'
CYAN='[1;36m'
BOLD='[1m'
RESET='[0m'
printf '\n%b' $CYAN && cat << 'EOF'
▪ ▄▄
▪ ██ ██▌
▄█▀▄ ▐█·▐█·
▐█▌.▐▌▐█▌.▀
▀█▄▀▪▀▀▀ ▀
EOF
printf '%b' $RESET
if [ $(id -u) = 0 ]; then
printf "%bwarning:%b please don't run random scripts you find on the internet as root!\n" $YELLOW $RESET
printf '%bsudo or doas will be used when elevated privileges are required%b\n' $BOLD $RESET
exit 1
fi
if !command -v cargo >/dev/null 2>&1; then
printf '%berror:%b can not find %bcargo%b in your $PATH, please ensure it is correctly installed\n' $RED $RESET $BOLD $RESET
exit 1
fi
if command -v sudo >/dev/null 2>&1; then
PRIV_ESC='sudo'
elif command -v doas >/dev/null 2>&1; then
PRIV_ESC='doas'
else
printf '%berror:%b can not find %bsudo%b or %bdoas%b in your $PATH, one of these is required\n' $RED $RESET $BOLD $RESET $BOLD $RESET
exit 1
fi
cd "$(dirname "$0")"
printf '%bSTEP 1:%b %bbuilding the binary%b (this may take a few minutes)\n\n' $GREEN $RESET $BOLD $RESET
cargo build --release
command -v strip >/dev/null 2>&1 && strip -s ./target/release/oi
printf '\n%bSTEP 2:%b %bcopying files%b (elevated privileges are required)\n\n' $GREEN $RESET $BOLD $RESET
$PRIV_ESC install -Dvm755 ./target/release/oi /usr/local/bin/oi
$PRIV_ESC install -Dvm644 ./etc/completions/_oi /usr/share/zsh/site-functions/_oi
$PRIV_ESC install -Dvm644 ./etc/completions/oi.bash /usr/share/bash-completion/completions/oi
$PRIV_ESC install -Dvm644 ./etc/completions/oi.fish /usr/share/fish/vendor_completions.d/oi.fish
printf '\n%bDONE:%b %bthanks for testing! %b<3%b (this repo is no longer needed and can be deleted)\n' $GREEN $RESET $BOLD $RED $RESET