-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·149 lines (118 loc) · 3.81 KB
/
install.sh
File metadata and controls
executable file
·149 lines (118 loc) · 3.81 KB
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
145
146
147
148
149
#!/bin/sh
# ScreamingFace installer — works via: curl -fsSL <url>/install.sh | sh
#
# Detects OS/arch, downloads the latest release from GitHub, and installs.
# Supports SF_INSTALL_DIR env var for custom install location.
set -eu
REPO="OpenMined/sf-installer"
APP_NAME="ScreamingFace"
# --- Helpers ---
info() { printf ' \033[1;34m>\033[0m %s\n' "$*"; }
ok() { printf ' \033[1;32m✓\033[0m %s\n' "$*"; }
err() { printf ' \033[1;31m✗\033[0m %s\n' "$*" >&2; exit 1; }
need_cmd() {
if ! command -v "$1" > /dev/null 2>&1; then
err "Required command not found: $1"
fi
}
# --- Detect platform ---
detect_os() {
case "$(uname -s)" in
Darwin) echo "mac" ;;
Linux) echo "linux" ;;
*) err "Unsupported OS: $(uname -s). Only macOS and Linux are supported." ;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x64" ;;
arm64|aarch64) echo "arm64" ;;
*) err "Unsupported architecture: $(uname -m)" ;;
esac
}
# --- Fetch latest release tag ---
latest_tag() {
# Use GitHub API to get the latest release tag
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' \
| head -1 \
| sed 's/.*"tag_name": *"\([^"]*\)".*/\1/'
}
# --- Main ---
main() {
need_cmd curl
need_cmd tar
OS="$(detect_os)"
ARCH="$(detect_arch)"
info "Detected platform: ${OS}/${ARCH}"
# Determine version
if [ -n "${SF_VERSION:-}" ]; then
TAG="$SF_VERSION"
info "Using specified version: ${TAG}"
else
info "Fetching latest release..."
TAG="$(latest_tag)"
if [ -z "$TAG" ]; then
err "Could not determine latest release. Set SF_VERSION to install a specific version."
fi
info "Latest version: ${TAG}"
fi
VERSION="${TAG#v}"
# Determine artifact name and install dir
case "$OS" in
mac)
ARTIFACT="ScreamingFace-${VERSION}-${OS}-${ARCH}.zip"
INSTALL_DIR="${SF_INSTALL_DIR:-/Applications}"
;;
linux)
ARTIFACT="ScreamingFace-${VERSION}-${OS}-${ARCH}.tar.gz"
INSTALL_DIR="${SF_INSTALL_DIR:-${HOME}/.local/share/ScreamingFace}"
;;
esac
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/${ARTIFACT}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
# Download
info "Downloading ${ARTIFACT}..."
curl -fsSL "$DOWNLOAD_URL" -o "${TMP_DIR}/${ARTIFACT}"
ok "Downloaded $(du -sh "${TMP_DIR}/${ARTIFACT}" | cut -f1)"
# Install
case "$OS" in
mac)
info "Installing to ${INSTALL_DIR}/${APP_NAME}.app..."
# Remove previous install
if [ -d "${INSTALL_DIR}/${APP_NAME}.app" ]; then
info "Removing previous installation..."
rm -rf "${INSTALL_DIR}/${APP_NAME}.app"
fi
# Unzip to /Applications
unzip -qo "${TMP_DIR}/${ARTIFACT}" -d "$INSTALL_DIR"
# Remove quarantine attribute (app isn't signed yet)
xattr -rd com.apple.quarantine "${INSTALL_DIR}/${APP_NAME}.app" 2>/dev/null || true
ok "Installed to ${INSTALL_DIR}/${APP_NAME}.app"
# Launch
info "Launching ${APP_NAME}..."
open "${INSTALL_DIR}/${APP_NAME}.app"
;;
linux)
info "Installing to ${INSTALL_DIR}..."
mkdir -p "$INSTALL_DIR"
# Extract
tar -xzf "${TMP_DIR}/${ARTIFACT}" -C "$INSTALL_DIR" --strip-components=1
# Symlink to PATH
BIN_DIR="${HOME}/.local/bin"
mkdir -p "$BIN_DIR"
BINARY="$(find "$INSTALL_DIR" -maxdepth 1 -name 'screamingface' -o -name 'ScreamingFace' | head -1)"
if [ -n "$BINARY" ]; then
chmod +x "$BINARY"
ln -sf "$BINARY" "${BIN_DIR}/screamingface"
ok "Symlinked to ${BIN_DIR}/screamingface"
fi
ok "Installed to ${INSTALL_DIR}"
info "Run 'screamingface' to launch (make sure ~/.local/bin is in your PATH)"
;;
esac
echo ""
ok "ScreamingFace ${TAG} installed successfully!"
}
main "$@"