-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d707d9
commit db6c8a4
Showing
2 changed files
with
32 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,55 @@ | ||
#!/bin/bash | ||
|
||
function scr_install | ||
{ | ||
set -e | ||
install() { | ||
set -e | ||
|
||
# Set variables | ||
# Set variables | ||
|
||
local destination_path="/tmp" | ||
local bin_path="/usr/local/bin" | ||
local stitchocker_stable_release="1.2.1" | ||
local stitchoker_uri="https://raw.githubusercontent.com/alexaandrov/stitchocker/$stitchocker_stable_release/stitchocker.sh" | ||
local stitchocker_name="stitchocker" | ||
local stitchocker_tmp_path="$destination_path/$stitchocker_name.sh" | ||
local stitchocker_bin_path="$bin_path/$stitchocker_name" | ||
|
||
local destination_path="/tmp" | ||
local bin_path="/usr/local/bin" | ||
local stitchocker_stable_release="1.2.0" | ||
local stitchoker_uri="https://raw.githubusercontent.com/alexaandrov/stitchocker/$stitchocker_stable_release/stitchocker.sh" | ||
local stitchocker_name="stitchocker" | ||
local stitchocker_tmp_path="$destination_path/$stitchocker_name.sh" | ||
local stitchocker_bin_path="$bin_path/$stitchocker_name" | ||
info "Downloading $stitchocker_name $stitchocker_stable_release" | ||
|
||
scr_info "Downloading $stitchocker_name $stitchocker_stable_release" | ||
local http_code=$(curl -H 'Cache-Control: no-cache' --url $stitchoker_uri --output $stitchocker_tmp_path --write-out "%{http_code}") | ||
echo | ||
|
||
echo | ||
local http_code=$(curl -H 'Cache-Control: no-cache' --url $stitchoker_uri --output $stitchocker_tmp_path --write-out "%{http_code}") | ||
if [[ $http_code != 200 ]]; then | ||
error "An error occurred while downloading the $stitchocker_name. Try again later or manually download the $stitchocker_name." | ||
fi | ||
|
||
if [[ $http_code != 200 ]]; then | ||
scr_error "An error occurred while downloading the $stitchocker_name. Try again later or manually download the $stitchocker_name." | ||
fi | ||
echo | ||
info "Installing $stitchocker_name" | ||
|
||
scr_info "Installing $stitchocker_name" | ||
if [[ -f $stitchocker_bin_path ]]; then | ||
info "Removing previous version" | ||
rm -f $stitchocker_bin_path | ||
fi | ||
|
||
if [[ -f $stitchocker_bin_path ]]; then | ||
scr_info "Removing previous version" | ||
rm -f $stitchocker_bin_path | ||
fi | ||
mv $stitchocker_tmp_path $stitchocker_bin_path | ||
|
||
mv $stitchocker_tmp_path $stitchocker_bin_path | ||
chmod +x $stitchocker_bin_path | ||
|
||
chmod +x $stitchocker_bin_path | ||
|
||
scr_info "Installation complete!" | ||
scr_info "Run $stitchocker_name -h to see the help" | ||
echo | ||
scr_info "Your $($stitchocker_name --version)" | ||
info "Installation complete!" | ||
info "Run $stitchocker_name -h to see the help" | ||
info "Your $($stitchocker_name --version)" | ||
} | ||
|
||
function scr_info { | ||
info() { | ||
local green=$(tput setaf 2) | ||
local reset=$(tput sgr0) | ||
echo -e "${green}$@${reset}" | ||
echo | ||
} | ||
|
||
function scr_error { | ||
error() { | ||
local red=$(tput setaf 1) | ||
local reset=$(tput sgr0) | ||
echo >&2 -e "${red}$@${reset}" | ||
exit 1 | ||
} | ||
|
||
scr_install "$@" | ||
install "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters