-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsk-install.sh
executable file
·46 lines (37 loc) · 2.24 KB
/
jsk-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
#!/usr/bin/env bash
# ====================================================== project information ===
# author : jimmy mg lim (mirageglobe@gmail.com)
# source : https://github.com/mirageglobe/swissknife
# version : 0.2.0
# --------------------------------------------------------------------- main ---
# this is an example script to install an application into /usr/local/bin
# /usr/local/bin/ is normally in your $PATH
# it installs either from local cloned repo or remote github service
# installs samurai into /usr/local/bin
# files: samurai / samurai-mac.py / samurai-linux.py
readonly SUDO_REQUIRED=true
readonly APP_NAME=samurai
if [[ $SUDO_REQUIRED ]]; then
if [[ $(id -u) != 0 ]]; then
# check for sudo
if command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
echo >&2 "==> sudo not found. abort script $0."; exit 1;
fi
fi
fi
if git ls-files >& /dev/null && [[ -f samurai.py ]]; then
# install from local repo
$SUDO cp ./samurai /usr/local/bin/samurai || { echo "failed to install samurai into /usr/local/bin."; exit 1; }
$SUDO cp ./samurai-mac.py /usr/local/bin/samurai-mac.py || { echo "failed to install samurai-mac.py into /usr/local/bin."; exit 1; }
$SUDO cp ./samurai-linux.py /usr/local/bin/samurai-linux.py || { echo "failed to install samurai-linux.py into /usr/local/bin."; exit 1; }
else
# install from remote github repo
$SUDO curl -L https://raw.githubusercontent.com/mirageglobe/samurai/master/samurai -o /usr/local/bin/samurai && $SUDO chmod +x /usr/local/bin/samurai || { echo "failed to install samurai into /usr/local/bin."; exit 1; }
$SUDO curl -L https://raw.githubusercontent.com/mirageglobe/samurai/master/samurai-mac.py -o /usr/local/bin/samurai-mac.py && $SUDO chmod +x /usr/local/bin/samurai-mac.py || { echo "failed to install samurai-mac.py into /usr/local/bin."; exit 1; }
$SUDO curl -L https://raw.githubusercontent.com/mirageglobe/samurai/master/samurai-linux.py -o /usr/local/bin/samurai-linux.py && $SUDO chmod +x /usr/local/bin/samurai-linux.py || { echo "failed to install samurai-linux.py into /usr/local/bin."; exit 1; }
fi
echo "installed $APP_NAME into /usr/local/bin.";
echo "to uninstall, delete samurai / samurai-mac.py / samurai-linux.py from folder /usr/local/bin";
exit 0;