Browse Source

增加oss命令以及修改配置文件

郭超 4 years ago
parent
commit
73e490fad7
4 changed files with 90 additions and 8 deletions
  1. BIN
      .DS_Store
  2. 1 1
      crowd-service/.env
  3. 7 7
      crowd-service/docker-compose-multi.yml
  4. 82 0
      shell/oss.sh

BIN
.DS_Store


+ 1 - 1
crowd-service/.env

@@ -11,7 +11,7 @@ MYSQL_ROOT_PASSWORD=Customs2019
 MYSQL_DATABASE=crowd-test-service
 
 ## redis.env
-REDIS_TAG=3.2.0
+REDIS_TAG=latest
 
 ## main_site_backend.env
 MAINSITE_BACKEND_TAG=latest

+ 7 - 7
crowd-service/docker-compose-multi.yml

@@ -2,7 +2,7 @@ version: "3"
 services:
   mysql:
     restart: always
-    container_name: mysql
+    container_name: crowd_mysql
     image: "crowd-mysql:${DB_TAG}"
     volumes:
       - ${FILE_STORE_BASE_PATH}/${DB_STORE_DIR}:/var/lib/mysql
@@ -13,8 +13,8 @@ services:
       - MYSQL_DATABASE=${MYSQL_DATABASE}
   redis:
     restart: always
-    container_name: redis
-    image: "redis:${REDIS_TAG}"
+    container_name: crowd_redis
+    image: "crowd-mysql:${REDIS_TAG}"
     depends_on:
       - mysql
     ports:
@@ -25,8 +25,8 @@ services:
     container_name: crowd_backend
     image: "crowd-backend:${MAINSITE_BACKEND_TAG}"
     depends_on:
-      - mysql
-      - redis
+      - crowd_mysql
+      - crowd_redis
       - crowd_user
     ports:
       - 8080:8080
@@ -51,8 +51,8 @@ services:
     container_name: crowd_user
     image: "crowd-user:${MAINSITE_BACKEND_TAG}"
     depends_on:
-      - mysql
-      - redis
+      - crowd_mysql
+      - crowd_redis
     ports:
       - 8081:8081
     command: java -jar --spring.profiles.active=private-cloud --host=http://47.98.174.59  --redirect.url=http://47.98.174.59  --default.goto=http://47.98.174.59  --default.login=http://47.98.174.59:8081/page/login --website.domainName=47.98.174.59 mooctest-user-server.jar  > nohub.out  ##-Dhost需要根据实际地址修改

+ 82 - 0
shell/oss.sh

@@ -0,0 +1,82 @@
+#!/bin/bash
+
+host="oss-cn-shanghai.aliyuncs.com"
+inner_host="oss-cn-shanghai-internal.aliyuncs.com"
+bucket="third-part-tool"
+Id="LTAI4FdrT3HsfdR5edBVN7ws"
+Key="yroxrpm46DzTyzHrLBZzS3MRNIicP6"
+# 参数1,PUT:上传,GET:下载
+method=$1
+# 参数2,上传时为本地源文件路径,下载时为oss源文件路径
+source=$2
+# 参数3,上传时为OSS目标文件路径,下载时为本地目标文件路径
+dest=$3
+
+osshost=$bucket.$inner_host
+#osshost=$bucket.$host
+# 校验method
+if test -z "$method"
+then
+    method=GET
+fi
+
+if [ "${method}"x = "get"x ] || [ "${method}"x = "GET"x ]
+then
+    method=GET
+elif [ "${method}"x = "put"x ] || [ "${method}"x = "PUT"x ]
+then
+    method=PUT
+else
+    method=GET
+fi
+
+#校验上传目标路径
+if test -z "$dest"
+then
+    dest=$source
+fi
+
+echo "method:"$method
+echo "source:"$source
+echo "dest:"$dest
+
+#校验参数是否为空
+if test -z "$method" || test -z "$source" || test -z "$dest"
+then
+    echo $0 put localfile objectname
+    echo $0 get objectname localfile
+    exit -1
+fi
+
+if [ "${method}"x = "PUT"x ]
+then
+    resource="/${bucket}/${dest}"
+    contentType=`file -ib ${source} |awk -F ";" '{print $1}'`
+    dateValue="`TZ=GMT date +'%a, %d %b %Y %H:%M:%S GMT'`"
+    stringToSign="${method}\n\n${contentType}\n${dateValue}\n${resource}"
+    signature=`echo -en $stringToSign | openssl sha1 -hmac ${Key} -binary | base64`
+    echo $stringToSign
+    echo $signature
+    url=http://${osshost}/${dest}
+    echo "upload ${source} to ${url}"
+    curl -i -q -X PUT -T "${source}" \
+      -H "Host: ${osshost}" \
+      -H "Date: ${dateValue}" \
+      -H "Content-Type: ${contentType}" \
+      -H "Authorization: OSS ${Id}:${signature}" \
+      ${url}
+else
+    resource="/${bucket}/${source}"
+    contentType=""
+    dateValue="`TZ=GMT date +'%a, %d %b %Y %H:%M:%S GMT'`"
+    stringToSign="${method}\n\n${contentType}\n${dateValue}\n${resource}"
+    signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${Key} -binary | base64`
+    url=http://${osshost}/${source}
+    echo "download ${url} to ${dest}"
+    curl --create-dirs \
+      -H "Host: ${osshost}" \
+      -H "Date: ${dateValue}" \
+      -H "Content-Type: ${contentType}" \
+      -H "Authorization: OSS ${Id}:${signature}" \
+      ${url} -o ${dest}
+fi