-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_offical_plugins.sh
executable file
·165 lines (152 loc) · 2.94 KB
/
get_offical_plugins.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
success() {
COLOR='\033[0;32m'
RESET='\033[0m'
printf "${COLOR}%s${RESET}\n" "$1"
}
warn() {
COLOR='\033[0;33m'
RESET='\033[0m'
printf "${COLOR}%s${RESET}\n" "$1"
}
error() {
COLOR='\033[0;31m'
RESET='\033[0m'
printf "${COLOR}%s${RESET}\n" "$1"
}
check() {
command -v "$1" >/dev/null 2>&1
}
for cmd in wget tar unzip; do
if ! check "$cmd"; then
error "Error: $cmd is not installed. Please install it and try again."
exit 1
fi
done
OS=$(uname)
case $OS in
'Linux')
OS='linux'
;;
'WindowsNT')
OS='windows'
;;
'Darwin')
OS='darwin'
;;
*)
OS='unknown'
;;
esac
ARCH=$(uname -m)
case $ARCH in
'x86_64')
ARCH='x86_64'
;;
'i386')
ARCH='i686'
;;
'i686')
ARCH='i686'
;;
'arm64')
ARCH='aarch64'
;;
'aarch64')
ARCH='aarch64'
;;
*)
ARCH='unknown'
;;
esac
echo OS: $OS
if [ $OS == 'unknown' ]; then
warn "Your OS may not be supported"
fi
echo Arch: $ARCH
if [ $ARCH == 'unknown' ]; then
warn "Your architecture may not be supported"
fi
default=1
if [ $OS == 'linux' ]; then
if [ $ARCH == 'x86_64' ]; then
default=1
elif [ $ARCH == 'i686' ]; then
default=2
elif [ $ARCH == 'aarch64' ]; then
default=3
fi
elif [ $OS == 'windows' ]; then
if [ $ARCH == 'x86_64' ]; then
default=4
fi
elif [ $OS == 'darwin' ]; then
if [ $ARCH == 'x86_64' ]; then
default=5
elif [ $ARCH == 'aarch64' ]; then
default=6
fi
fi
extension=.tar.gz
echo
echo "Choose version:"
echo "1) linux-x86_64"
echo "2) linux-i686"
echo "3) linux-aarch64"
echo "4) windows-x86_64"
echo "5) darwin-x86_64"
echo "6) darwin-aarch64"
read -p "Your choice (default: $default): " choice
if [ -z "$choice" ]; then
choice=$default
fi
case $choice in
'1')
version='linux-x86_64'
;;
'2')
version='linux-i686'
;;
'3')
version='linux-aarch64'
;;
'4')
version='windows-x86_64'
;;
'5')
version='darwin-x86_64'
;;
'6')
version='darwin-aarch64'
;;
*)
error "Error: Unknown choice."
exit 1
;;
esac
if [ $choice == '4' ]; then
extension=.zip
fi
read -p "Download path (default: ./plugin): " path
if [ -z "$path" ]; then
path=./plugin
fi
mkdir -p $path && cd $path
plugins=("monitor" "agent" "task")
for plugin in "${plugins[@]}"; do
echo "Downloading $plugin..."
wget https://github.com/ministruth/$plugin/releases/latest/download/plugin-$version$extension -O plugin-$version$extension
if [ $extension == '.tar.gz' ]; then
tar -xzf plugin-$version$extension
else
unzip plugin-$version$extension
fi
done
mv -f plugin-$version/* .
rm -rf plugin-$version$extension plugin-$version
cd -
echo
success "Download success"
echo Note that you need to put plugin files in your plugin and assets folder:
echo "mv $path/assets/* /path/to/skynet/assets/_plugin && rm -rf $path/assets/"
echo "mv $path/* /path/to/skynet/plugin"