-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·74 lines (56 loc) · 2.01 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env sh
# installs fox.sh as fox into /usr/local/bin
# files: fox.sh
# ----- exit script on error
set -e
# ----- variables using env
FOX_AVATAR="[fox]"
FOX_PATH="${HOME}/.fox"
# ----- functions
# checking and assigning sudo if user not root
echo ":: checking sudo ::"
if [[ $(id -u) != 0 ]]; then
if command -v sudo >/dev/null 2>&1; then
echo ":: sudo exists ::"
# SUDO="sudo"
else
echo ":: sudo not installed or no admin privileges detected ::"
# SUDO=""
# exit 1
fi
fi
# checking os
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo ":: linux debian detected - ok ::"
elif [[ "${OSTYPE}" == "darwin"* ]]; then
echo ":: mac os darwin detected - ok ::"
elif [[ "${OSTYPE}" == "cygwin" ]]; then
echo ":: cygwin detected - aborting ::"
exit 1;
elif [[ "${OSTYPE}" == "freebsd"* ]]; then
echo ":: freebsd detected - aborting ::"
exit 1;
else
echo ":: os not supported - aborting ::"
exit 1;
fi
# install new project files
echo ":: installing butlerfox ${FOX_AVATAR} to ${FOX_PATH} ::"
mkdir -pv ${FOX_PATH}/bin
curl -L https://raw.githubusercontent.com/mirageglobe/butlerfox/master/dist/fox-latest.sh -o ${FOX_PATH}/bin/fox
curl -L https://raw.githubusercontent.com/mirageglobe/butlerfox/master/dist/.fox.bash -o ${FOX_PATH}/.fox.bash
echo ":: symlinking/setting butlerfox ${FOX_AVATAR} ::"
chmod u+x ${FOX_PATH}/
chmod -R u+x ${FOX_PATH}/bin/
# updating fox path by regex "/.fox/.bash"
# grep -qxF 'export PATH="$HOME/.tools/bin:$PATH"' ${HOME}/.bashrc || echo '\nexport PATH="$HOME/.tools/bin:$PATH"' >> ${HOME}/.bashrc
# grep -q (quiet) -x (entire line match)
grep -q ".fox.bash" "${HOME}/.bashrc" && echo "[fox] found bash path. skipping update." || echo '[ -f ~/.fox/.fox.bash ] && source ~/.fox/.fox.bash' >> ${HOME}/.bashrc
# summary
cat << EOM
${FOX_AVATAR} sir, i have prepared a summary
:: summary ::
installed butlerfox into ${FOX_PATH}/bin/fox
to uninstall, delete binary ${FOX_PATH}/fox
${FOX_AVATAR} sir, all complete. you may need to restart shell for your path to update
EOM