-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·67 lines (59 loc) · 2.34 KB
/
install
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
#!/usr/bin/env bash
GITHUB_BRANCH="main"
GITHUB_ARCHIVE="https://github.com/csi-lk/jira-aliases/archive/$GITHUB_BRANCH.zip"
INSTALL_PATH="$HOME/.jira-aliases"
grey() {
printf "\e[0;90m%s\e[0m" "$1"
}
green() {
printf "\e[0;32m%s\e[0m" "$1"
}
install_to_path() {
if [[ ":$PATH:" == *":$INSTALL_PATH/bin:"* ]]; then
echo $(grey "|> ja already exists in path, moving on...")
else
echo $(grey "|> adding ja to ~/.bashrc path")
echo "export PATH=\$HOME/.jira-aliases/bin:\$PATH" >>~/.bashrc
if [ -f ~/.zshrc ]; then
echo $(grey "|> adding ja to ~/.zshrc path")
echo "export PATH=\$HOME/.jira-aliases/bin:\$PATH" >>~/.zshrc
fi
export PATH=$HOME/.jira-aliases/bin:$PATH
echo $(green "|> 'ja' added to PATH")
echo $(grey "|> you may need to restart the shell or run 'source ~/.bashrc' for changes to take effect.")
echo $(grey "|> you can add it manually if required by adding:")
echo $(grey " export PATH=\$HOME/.jira-aliases/bin:\$PATH")
fi
}
install() {
set -e # exit if error
echo "$(green "ja") » simple jira aliases $(grey "by Callum Silcock")"
echo $(green "Let's get you setup...")
echo $(grey "|> Downloading Jira Aliases...")
curl -L#o /var/tmp/ja_$$.zip "$GITHUB_ARCHIVE"
echo $(grey "|> Cleaning up existing install...")
if [ -d "$INSTALL_PATH" ]; then
rm -rf "$INSTALL_PATH"
fi
echo $(grey "|> Unzipping...")
unzip -q /var/tmp/ja_$$ -d ~
echo $(grey "|> Moving to $INSTALL_PATH ...")
mv -f ~/jira-aliases-$GITHUB_BRANCH "$INSTALL_PATH"
echo $(grey "|> Setting permissions...")
chmod -v +x "$INSTALL_PATH"/bin/ja
source "$INSTALL_PATH/src/util/config" # Load config
source "$INSTALL_PATH/src/util/version" # Load version
if check_config_exists; then
version=$(get_version_from_remote_manifest)
update_config_value "CURRENT_VERSION" "$version"
echo $(green "|> Successfully upgraded!")
else
echo $(green "|> Successfully installed!")
fi
install_to_path
echo $(grey "------------------------------------------------------------------------------------------")
echo $(green "|> Installation Finished!")
echo $(grey "------------------------------------------------------------------------------------------")
ja -h
}
install