Simplify startup script
Browse files
start.sh
CHANGED
|
@@ -14,12 +14,14 @@ sleep 20
|
|
| 14 |
# 等待密码生效
|
| 15 |
sleep 5
|
| 16 |
|
| 17 |
-
# 获取token
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if [ -n "$TOKEN" ]; then
|
| 21 |
-
# 创建
|
| 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
|