bhgi commited on
Commit
55dbddd
·
verified ·
1 Parent(s): 52caf7a

Simplify startup script

Browse files
Files changed (1) hide show
  1. start.sh +6 -4
start.sh CHANGED
@@ -14,12 +14,14 @@ sleep 20
14
  # 等待密码生效
15
  sleep 5
16
 
17
- # 获取token
18
- TOKEN=$(curl -s http://localhost:5244/api/auth/login -H "Content-Type: application/json" -d '{"username":"admin","password":"114114aa"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['token'])" 2>/dev/null)
 
 
19
 
20
  if [ -n "$TOKEN" ]; then
21
- # 创建S3存储
22
- curl -s -X POST http://localhost:5244/api/admin/storage/create -H "Content-Type: application/json" -H "Authorization: $TOKEN" -d '{"mount_path":"/hi168s3","driver":"S3","addition":"{\"bucket\":\"hi168-29132-0136saow\",\"endpoint\":\"https://s3.hi168.com\",\"access_key_id\":\"CYUQCHOIAH41GJHK3Y4H\",\"secret_access_key\":\"Ubd1B6JzXRbipWsHDHcc99OAfJvjOf8CpNkUx9YM\",\"force_path_style\":true,\"sign_url_expire\":4}"}'
23
  fi
24
 
25
  wait $PID
 
14
  # 等待密码生效
15
  sleep 5
16
 
17
+ # 获取token (使用grep和sed)
18
+ RESP=$(curl -s http://localhost:5244/api/auth/login -H "Content-Type: application/json" -d '{"username":"admin","password":"114114aa"}')
19
+
20
+ TOKEN=$(echo "$RESP" | grep -o '"token":"[^"]*"' | sed 's/"token":"//;s/"//')
21
 
22
  if [ -n "$TOKEN" ]; then
23
+ # 创建存储
24
+ curl -s -X POST http://localhost:5244/api/admin/storage/create -H "Content-Type: application/json" -H "Authorization: $TOKEN" -d '{"mount_path":"/hi168s3","driver":"S3","cache_expiration":30,"status":"work","addition":"{\"bucket\":\"hi168-29132-0136saow\",\"endpoint\":\"https://s3.hi168.com\",\"region\":\"auto\",\"access_key_id\":\"CYUQCHOIAH41GJHK3Y4H\",\"secret_access_key\":\"Ubd1B6JzXRbipWsHDHcc99OAfJvjOf8CpNkUx9YM\",\"force_path_style\":true,\"sign_url_expire\":4}"}'
25
  fi
26
 
27
  wait $PID