-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: huyikun.hyk <[email protected]>
- Loading branch information
huyikun.hyk
committed
Feb 26, 2024
1 parent
60405d1
commit 1e0fad3
Showing
1 changed file
with
35 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,44 @@ | ||
set -e # 报错后不继续执行 | ||
#!/bin/bash | ||
|
||
# 执行命令并捕获输出 | ||
VERSION_OUTPUT=$(s -v) | ||
version=$5 | ||
# valid_version=( | ||
# v3.0.0 | ||
# v3.0.1 | ||
# v3.0.2 | ||
# ) | ||
# if [[ "${valid_version[@]}" =~ "${version}" ]]; then | ||
if [ ! -f "/usr/local/bin/s" ]; then | ||
set -e # 报错后不继续执行 | ||
|
||
# 检查输出是否包含版本号的格式 | ||
if [[ $VERSION_OUTPUT ]]; then | ||
EXTRACTED_CONTENT=$(echo "$VERSION_OUTPUT" | sed -n 's/start:\([^,]*\),.*/\1/p;q') | ||
echo "Version output is valid: $EXTRACTED_CONTENT" | ||
else | ||
echo 'Serverless-devs installing.' | ||
npm install -g @serverless-devs/s@${version} | ||
curl "https://images.devsapp.cn/bin/s/${version}" --output /usr/local/bin/s | ||
chmod 777 /usr/local/bin/s | ||
echo 'Serverless-devs has been installed successfully.' | ||
# curl "https://images.devsapp.cn/bin/s/${version}" --output /usr/local/bin/s | ||
# chmod 777 /usr/local/bin/s | ||
fi | ||
|
||
echo '################################################' | ||
s config add --AccountID $1 --AccessKeyID $2 --AccessKeySecret $3 -a $4 -f | ||
echo '################################################' | ||
echo 'The access has been configured automatically, use "s config get" to check.' | ||
# else | ||
# echo $version "is not valid, please choose correct version." | ||
|
||
|
||
# # version=$5 | ||
# # valid_version=( | ||
# # v3.0.0 | ||
# # v3.0.1 | ||
# # v3.0.2 | ||
# # ) | ||
# # if [[ "${valid_version[@]}" =~ "${version}" ]]; then | ||
# echo 'Serverless-devs installing.' | ||
# npm install -g @serverless-devs/s@${version} | ||
# echo 'Serverless-devs has been installed successfully.' | ||
# # curl "https://images.devsapp.cn/bin/s/${version}" --output /usr/local/bin/s | ||
# # chmod 777 /usr/local/bin/s | ||
# fi | ||
# echo '################################################' | ||
# s config add --AccountID $1 --AccessKeyID $2 --AccessKeySecret $3 -a $4 -f | ||
# echo '################################################' | ||
# echo 'The access has been configured automatically, use "s config get" to check.' | ||
# # else | ||
# # echo $version "is not valid, please choose correct version." | ||
# # fi |