Skip to content

Commit 1d4d625

Browse files
committed
install, uninstall 추가
1 parent fbec0d3 commit 1d4d625

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ if [[ "$version_info" == *"Maria"* ]]; then
44
else
55
include_dir=$(mysql_config --include)
66
fi
7+
78
export CGO_CFLAGS=$include_dir
8-
go build -buildmode=c-shared -o http.so http.go
9+
go build -buildmode=c-shared -o http.so http.go

http.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type respResult struct {
3434
const optionDescription = `option:
3535
-b Define body input type.(hex: hexdecimal output. ex/[ascii]"Hello" -> 48656c6c6f, b64: base64 encoded, txt(default): text)
3636
-B Define body output type.(hex: hexdecimal output. ex/[ascii]"Hello" -> 48656c6c6f, b64: base64 encoded, txt(default): text)
37-
-c Define result charset when output type was txt. Default charset utf8
3837
-H Pass custom headers to server (H)
3938
-O Define kind of reult.(PROTO, STATUS or STATUS_CODE, HEADER, BODY(default), FULL) ex/-O PROTO|STATUS|HEADER|BODY equal -O FULL
4039
-s Define tls/ssl skip verified true / false

install.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
if [[ $# == 2 || $# == 1 ]]; then
2+
version_info=$(mysql --version)
3+
if [[ "$version_info" == *"Maria"* ]]; then
4+
include_dir=$(mariadb_config --include)
5+
else
6+
include_dir=$(mysql_config --include)
7+
fi
8+
9+
sql_result=$(mysql --user=$1 --password=$2 -s -N -e "SHOW VARIABLES LIKE 'plugin_dir';")
10+
plugin_dir=$(cut -d" " -f2 <<< $sql_result)
11+
12+
export CGO_CFLAGS=$include_dir
13+
go build -buildmode=c-shared -o $plugin_dir"http.so" http.go
14+
rm $plugin_dir"http.h"
15+
16+
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_help RETURNS STRING SONAME 'http.so';"
17+
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_raw RETURNS STRING SONAME 'http.so';"
18+
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_get RETURNS STRING SONAME 'http.so';"
19+
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_post RETURNS STRING SONAME 'http.so';"
20+
21+
echo "Install Success"
22+
else
23+
echo "bash install.sh username password(optional)"
24+
fi
25+

uninstall.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if [[ $# == 2 || $# == 1 ]]; then
2+
mysql --user=$1 --password=$2 -s -N -e "DROP FUNCTION http_help;"
3+
mysql --user=$1 --password=$2 -s -N -e "DROP FUNCTION http_raw;"
4+
mysql --user=$1 --password=$2 -s -N -e "DROP FUNCTION http_get;"
5+
mysql --user=$1 --password=$2 -s -N -e "DROP FUNCTION http_post;"
6+
7+
sql_result=$(mysql --user=$1 --password=$2 -s -N -e "SHOW VARIABLES LIKE 'plugin_dir';")
8+
plugin_dir=$(cut -d" " -f2 <<< $sql_result)
9+
rm $plugin_dir"http.so"
10+
11+
echo "Uninstall Success"
12+
else
13+
echo "bash uninstall.sh username password(optional)"
14+
fi
15+

0 commit comments

Comments
 (0)