forked from 2rebi/mysql_udf_http_golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
25 lines (20 loc) · 1.01 KB
/
install.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
if [[ $# > 0 ]]; then
version_info=$(mysql --version)
if [[ "$version_info" == *"Maria"* ]]; then
include_dir=$(mariadb_config --include)
else
include_dir=$(mysql_config --include)
fi
sql_result=$(mysql --user=$1 --password=$2 -s -N -e "SHOW VARIABLES LIKE 'plugin_dir';")
plugin_dir=$(cut -d" " -f2 <<< $sql_result)
export CGO_CFLAGS=$include_dir
go build -buildmode=c-shared -o $plugin_dir"http.so" http.go
rm $plugin_dir"http.h"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_help RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_raw RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_get RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_post RETURNS STRING SONAME 'http.so';"
echo "Install Success"
else
echo "bash install.sh username password(optional)"
fi