-
Notifications
You must be signed in to change notification settings - Fork 4
/
get.sh
executable file
·79 lines (68 loc) · 2.03 KB
/
get.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
#!/usr/bin/env bash
# get.sh [version]
# download and unpack k runtime and dev environment.
# optional version tag is 'yyyy.mm.dd' (nyi).
# default is the latest available version.
# fetches content from shakti.sh into ~/shakti if it exists.
# re-tty (npm 7.*)
t=/dev/tty; exec>$t<$t
k=bin/k
devpath=~/shakti
eula_path=../.shakti.eula.crc
#INSECURE=--insecure
fetch(){
ft=$1; test -z $ft && return
CD=`pwd`; cd $devpath
ts=$ft
if [[ ! -f $ft || -d $devpath ]]; then
ts=19700101
fi
curl -f -z $ts -Ls --create-dirs -o $ft http://shakti.com/$ft && printf "[~] $devpath/$ft\n"
cd $CD
}
if [[ "$EUID" > 0 && -d $devpath ]]; then
paths=`node --no-warnings get.js dev > shakti.lst`; test $? -eq 0 || exit 1
cat shakti.lst | xargs -L1 | while read p ; do fetch $p ; done
fi
IFS=$'\n'
read -d '' -ra x <<< "$(node --no-warnings get.js)"
dist=${x[0]}; eula=${x[1]}
test -z $dist || test -z $eula && exit 1
saved_crc=$(test -f $eula_path && cat $eula_path)
crc=$(printf "$eula" | cksum)
download() {
#printf "downloading $(basename "$dist")..."
#curl -Ls $dist | tar -jxf - "bin/k" && printf "done.\n\n"
mkdir -p bin && curl $INSECURE -Ls $dist > $k && chmod +x $k && echo .z.a|bin/k && echo || exit 1
}
if [ "$crc" == "$saved_crc" ] || [ -n "$CI" ];
then
download
else
#printf "no local crc found.\n"
cols=$(stty size | cut -d ' ' -f 2)
printf "\n\n$eula\n" | fold -s -w $(($cols - 10))
while true
do
printf "\nDo you agree with the terms of the Shakti Software Evaluation Agreement? [y/n] " && read -rn1
case $REPLY in
[yY][eE][sS]|[yY])
printf "$crc" > $eula_path
printf "\n\n"
download
break
;;
[nN][oO]|[nN])
printf "\n\n +------------------------+\n"
printf " | installation aborted |\n"
printf " +------------------------+\n\n"
exit 1
break
;;
*)
printf '\nPlease type "yes" or "no".\n'
;;
esac
done
fi
#:~