-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathlazy_install.sh
More file actions
executable file
·57 lines (45 loc) · 1.61 KB
/
Copy pathlazy_install.sh
File metadata and controls
executable file
·57 lines (45 loc) · 1.61 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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
set -o xtrace
trap 'echo -e "Aborted, error $? in command: $BASH_COMMAND"; trap ERR; exit 1' ERR
sudo apt install -y wget jq lsb-release tar
#GH_PROXY=https://tvv.tw/
#GH_PROXY=https://gh-proxy.com/
[[ -n ${1:-} ]] && GH_PROXY=${1:-} && \
if ! [[ "$GH_PROXY" =~ ^https://.*/$ ]]; then
GH_PROXY=https://${GH_PROXY}/
fi
_REPO=boypt/openssh-deb
_LATEST_API=https://api.github.com/repos/${_REPO}/releases/latest
if [[ -n ${GH_PROXY:-} ]] && ! [[ $_LATEST_API =~ ^${GH_PROXY}.* ]]; then
_LATEST_API="${GH_PROXY}${_LATEST_API}"
fi
_WORKDIR=$(mktemp -d)
_CN=$(lsb_release -sc)
_AR=$(dpkg --print-architecture)
_TARGET_ARCH="${_AR}"
pushd $_WORKDIR
TAR_URL=$(wget -O- "$_LATEST_API" \
| jq -r ".assets[] | select(.name | contains(\"${_CN}\") and contains(\"${_TARGET_ARCH}\") and (endswith(\".tar.gz\"))) | .browser_download_url" | head -n 1)
if [[ -z "$TAR_URL" ]]; then
echo "Error: No matching release package found for ${_CN}-${_TARGET_ARCH}."
exit 1
fi
if [[ -n ${GH_PROXY:-} ]] && ! [[ "$TAR_URL" =~ ^${GH_PROXY}.* ]]; then
TAR_URL=$(echo "$TAR_URL" | sed "s|https://github.com|${GH_PROXY:-}https://github.com|g")
fi
wget -O- "$TAR_URL" | tar -xzf -
if [[ $(find . -type f -name "*.deb" | wc -l) -gt 0 ]]; then
echo "> These DEBs are going to be installed... Ctrl+C to interrupt"
find . -type f -name "*.deb" -print
sleep 3
find . -type f -name "*.deb" -print | xargs sudo apt install -y
else
echo "Error: No .deb packages found inside the archive."
exit 1
fi
popd
[[ -d $_WORKDIR ]] && rm -rfv $_WORKDIR
ssh -V