-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
installer
executable file
·56 lines (48 loc) · 1.27 KB
/
installer
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
#!/bin/bash
# Install:
# $ curl -sSL https://hedzr.com/bash.sh/installer | sudo bash -si
# $ curl -sSL https://hedzr.com/bash.sh/installer | sudo bash -s
#
#
#
#
#
#
#
#set -e
#set -x
echo "Install....$0 $@"
OPS_NAME="${OPS_NAME:-bash.sh}"
URL_BASE="${OPS_URL_BASE:-https://hedzr.com/bash/$OPS_NAME/}"
INSTALL_PREFIX="${INSTALL_TARGET:-/usr/local/bin}"
INSTALL_TARGET="$INSTALL_PREFIX"
N=""
function self_download() {
if [ -z $# ]; then
false
elif [ $# -gt 1 ]; then
echo "try"
for file in $*; do
self_download $file
done
else
local context=$1
local cdir=$(dirname $context)
local cname=$(basename $context)
if [[ $context != */* ]]; then
cdir="."
cname=$context
fi
echo "#### Downloading $context... dir: $cdir, name: $cname, @: $INSTALL_TARGET, PWD: $PWD"
[ ! -d $INSTALL_TARGET/$cdir ] && mkdir -p $INSTALL_TARGET/$cdir
#curl -sSL https://ops.suweia.net/suwei-init/$context -o $INSTALL_TARGET/$cdir/$cname
wget -q $URL_BASE/$context -O $INSTALL_TARGET/$cdir/$cname
[ "$N" == "" ] && N=$INSTALL_TARGET/$cdir/$cname
fi
}
self_download "bash.config" && ln -s "$INSTALL_TARGET/$OPS_NAME" "$INSTALL_TARGET/ops"
cat <<EOF
====================================================================
'$OPS_NAME' was installed as '$N'.
All folks, Enjoy it!
EOF