This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
share.sh
executable file
·144 lines (120 loc) · 4.01 KB
/
share.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
# This script installs scs.
#
# Quick install: `curl https://onboardbase.github.io/secure-share-sh/ | bash`
#
# This script will install share to the directory you're in. To install
# somewhere else (e.g. /usr/local/bin), cd there and make sure you can write to
# that directory, e.g. `cd /usr/local/bin; curl https://onboardbase.github.io/secure-share-sh/ | sudo bash`
#
# Found a bug? Report it here: https://github.com/onboardbase/secure-share/issues
#
# Acknowledgments:
# - getmic.ro: https://github.com/benweissmann/getmic.ro
# - eget: https://github.com/zyedidia/eget
set -e -u
githubLatestTag() {
finalUrl=$(curl "https://github.com/$1/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
printf "%s\n" "${finalUrl##*v}"
}
platform=''
machine=$(uname -m)
executable="scs"
# Check the GETSHARE_PALTFORM is set
if [ "${GETSHARE_PLATFORM:-x}" != "x" ]; then
platform="$GETSHARE_PLATFORM"
else
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
"linux")
case "$machine" in
"arm64"* | "aarch64"* ) platform='aarch64-linux' ;;
"arm"* | "aarch"*) platform='aarch64-linux' ;;
*"86") platform='x86_64-linux' ;;
*"64") platform='x86_64-linux' ;;
esac
;;
"darwin")
case "$machine" in
"arm64"* | "aarch64"* ) platform='x86_64-macos' ;;
*"64") platform='x86_64-macos' ;;
esac
;;
"msys"*|"cygwin"*|"mingw"*|*"_nt"*|"win"*)
case "$machine" in
*"86") platform='x86_64-windows' ;;
*"64") platform='x86_64-windows' ;;
esac
;;
esac
fi
if [ "$platform" = "" ]; then
cat << 'EOM'
/=====================================\\
| COULD NOT DETECT PLATFORM |
\\=====================================/
Uh oh! We couldn't automatically detect your operating system.
To continue with installation, please choose from one of the following values:
- x86_64-linux
- aarch64-linux
- x86_64-macos
- x86_64-windows
Export your selection as the GETSHARE_PLATFORM environment variable, and then
re-run this script.
For example:
$ export GETSHARE_PLATFORM=linux_amd64
$ curl https://woke.build/share | bash
EOM
exit 1
else
printf "Detected platform: %s\n" "$platform"
fi
TAG=$(githubLatestTag onboardbase/secure-share)
if [ "$platform" = "x86_64-windows" ]; then
extension='zip'
else
extension='tar.gz'
fi
printf "Latest Version: %s\n" "$TAG"
printf "Downloading https://github.com/onboardbase/secure-share/releases/download/v%s/secure-share-v%s-%s.%s\n" "$TAG" "$TAG" "$platform" "$extension"
curl -L "https://github.com/onboardbase/secure-share/releases/download/v$TAG/secure-share-v$TAG-$platform.$extension" > "share.$extension"
case "$extension" in
"zip") unzip -j "$executable.$extension" -d "secure-share-v$TAG-$platform" ;;
"tar.gz") tar -xvzf "$executable.$extension" "secure-share-v$TAG-$platform/share" ;;
esac
mv "secure-share-v$TAG-$platform/$executable" ./$executable
rm "$executable.$extension"
rm -rf "secure-share-v$TAG-$platform"
##Make share globally executable
# Check the operating system
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows
bin_dir="$HOME/bin"
executable_path="$bin_dir/$executable"
# Create the bin directory if it doesn't exist
if [ ! -d "$bin_dir" ]; then
mkdir "$bin_dir"
fi
# Copy the executable to the bin directory
cp "$executable" "$executable_path"
# Set executable permissions
chmod +x "$executable_path"
# Add the bin directory to the PATH environment variable
echo "export PATH=\$PATH:$bin_dir" >> "$HOME/.bashrc"
elif [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
# Linux or macOS
executable_path="/usr/local/bin/$executable"
# Copy the executable to the /usr/local/bin directory
sudo cp "$executable" "$executable_path"
# Set executable permissions
sudo chmod +x "$executable_path"
else
# Unsupported operating system
echo "Unsupported operating system: $OSTYPE"
exit 1
fi
rm -rf $executable
cat <<-'EOM'
scs has been downloaded and is now globally accessible.
You can run it with:
scs --help
EOM