Sh脚本一点温馨的计算,run起来之后执行多条命令

从.netCore开源项目来看,eShopOnContainers来说,它的配备是跨平台的,能够配备在linux,docker上,在linux上运营它也足以写一些并入的小本子,这是微信工程师为大家提供二个布局发布方案的SH脚本

Linux~Sh脚本一点谈得来的下结论,linuxsh脚本

从.netCore开源项目来看,eShopOnContainers来说,它的安插是跨平台的,能够布署在linux,docker上,在linux上运维它也得以写一些合并的小本子,那是微信工程师为大家提供1个布署发表方案的SH脚本

#!/bin/bash
declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

# Build SPA app
# pushd $(pwd)../src/Web/WebSPA
# npm run build:prod

for project in "${projectList[@]}"
do
    echo -e "\e[33mWorking on $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
    pushd $(pwd)/$project
    rm -rf obj/Docker/publish
    echo -e "\e[33m\tRestoring project"
    dotnet restore
    echo -e "\e[33m\tBuilding and publishing projects"
    dotnet publish -o obj/Docker/publish
    popd
done

# remove old docker images:
images=$(docker images --filter=reference="eshop/*" -q)
if [ -n "$images" ]; then
    docker rm $(docker ps -a -q) -f
    echo "Deleting eShop images in local Docker repo"
    echo $images
    docker rmi $(docker images --filter=reference="eshop/*" -q) -f
fi

# No need to build the images, docker build or docker compose will
# do that using the images and containers defined in the docker-compose.yml file.

Sh脚本一点温馨的计算,run起来之后执行多条命令。地点的消除重庆大学反映了发布时用的有的指令,如数组,遍历,条件语句,删除文件,宣布语句等,我要好写练了练手

declare -a arr=(1
2
3
4
5
)
for i in "${arr[@]}"
do 
if [ $i == 2 ]
then
   echo "a is equal to 2"
else
   echo "a is not equal to 2"
fi

done


declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

for project in "${projectList[@]}"
do
    echo -e "\e[33m工作在目录 $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
done

大家在写SH文件时要留心,linux与windows的回车符分歧,大家得以下载notepad++那些工具来拓展转码。

从.netCore开源项目来看,eShopOnContainers来说,它的布局是跨平台的,能够配备在linux,docker上,在linu…

从.netCore开源项目来看,eShopOnContainers来说,它的布局是跨平台的,能够配备在linux,docker上,在linux上运营它也能够写一些集成的小本子,这是微信工程师为大家提供贰个计划揭橥方案的SH脚本

近年在搞jenkins pipeline的安插工作,而在对.net
core进行安插时不期望安装dotnet
sdk,为了移植性更好,打算直接选用aspnetcore的docker镜像,通过docker去run它,而在那几个时刻现身了2个题材
docker run
aspnetcore:2.0随后要是愿意同时施行八个sh命令出现了难点,还非要写个本子文件,那是父辈不喜欢的!

#!/bin/bash
declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

# Build SPA app
# pushd $(pwd)../src/Web/WebSPA
# npm run build:prod

for project in "${projectList[@]}"
do
    echo -e "\e[33mWorking on $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
    pushd $(pwd)/$project
    rm -rf obj/Docker/publish
    echo -e "\e[33m\tRestoring project"
    dotnet restore
    echo -e "\e[33m\tBuilding and publishing projects"
    dotnet publish -o obj/Docker/publish
    popd
done

# remove old docker images:
images=$(docker images --filter=reference="eshop/*" -q)
if [ -n "$images" ]; then
    docker rm $(docker ps -a -q) -f
    echo "Deleting eShop images in local Docker repo"
    echo $images
    docker rmi $(docker images --filter=reference="eshop/*" -q) -f
fi

# No need to build the images, docker build or docker compose will
# do that using the images and containers defined in the docker-compose.yml file.
#!/bin/bash
declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

# Build SPA app
# pushd $(pwd)../src/Web/WebSPA
# npm run build:prod

for project in "${projectList[@]}"
do
    echo -e "\e[33mWorking on $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
    pushd $(pwd)/$project
    rm -rf obj/Docker/publish
    echo -e "\e[33m\tRestoring project"
    dotnet restore
    echo -e "\e[33m\tBuilding and publishing projects"
    dotnet publish -o obj/Docker/publish
    popd
done

# remove old docker images:
images=$(docker images --filter=reference="eshop/*" -q)
if [ -n "$images" ]; then
    docker rm $(docker ps -a -q) -f
    echo "Deleting eShop images in local Docker repo"
    echo $images
    docker rmi $(docker images --filter=reference="eshop/*" -q) -f
fi

# No need to build the images, docker build or docker compose will
# do that using the images and containers defined in the docker-compose.yml file.
docker run aspnetcore:2.0 ls && ls

亚洲必赢app官方下载,地点的缓解重庆大学反映了公布时用的有的指令,如数组,遍历,条件语句,删除文件,发布语句等,笔者要好写练了练手

地点的消除根本突显了发布时用的有些限令,如数组,遍历,条件语句,删除文件,公布语句等,小编要好写练了练手

结果是首先个ls呈现的是容器里的情节,而第3个ls展现的是本地centos的始末,那不是父辈希望的!

declare -a arr=(1
2
3
4
5
)
for i in "${arr[@]}"
do 
if [ $i == 2 ]
then
   echo "a is equal to 2"
else
   echo "a is not equal to 2"
fi

done


declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

for project in "${projectList[@]}"
do
    echo -e "\e[33m工作在目录 $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
done
declare -a arr=(1
2
3
4
5
)
for i in "${arr[@]}"
do 
if [ $i == 2 ]
then
   echo "a is equal to 2"
else
   echo "a is not equal to 2"
fi

done


declare -a projectList=(
    '../src/Services/Catalog/Catalog.API'
    '../src/Services/Basket/Basket.API'
    '../src/Services/Ordering/Ordering.API'
    '../src/Services/Identity/Identity.API'
    '../src/Web/WebMVC'
    '../src/Web/WebSPA'
    '../src/Web/WebStatus'
)

for project in "${projectList[@]}"
do
    echo -e "\e[33m工作在目录 $(pwd)/$project"
    echo -e "\e[33m\tRemoving old publish output"
done

亚洲必赢app官方下载 1

大家在写SH文件时要专注,linux与windows的回车符不等同,大家能够下载notepad++这一个工具来进展转码。

世家在写SH文件时要专注,linux与windows的回车符不雷同,大家得以下载notepad++那些工具来进展转码。

二叔希望三个ls,即多条sh命令都在容器里推行,这样就幸免了新加SH文件的苦闷!

接下来大伯找了一些素材,幸运的是,被五叔找到了!

docker run 5800 sh -c "ls && echo '-------' &&  ls"

实质上,就是在run前边加了二个sh -c命令,前面一直加多条语句即可!

亚洲必赢app官方下载 2

本次是本身梦想的结果,终于得以了,现在不要建立SH文件了,本来就不该建立结余的文书,呵呵

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图