Linux~sh script a bit of your own summary

Source: Internet
Author: User
Tags dotnet docker ps docker compose

From the. Netcore Open source project, Eshoponcontainers, its deployment is cross-platform, can be deployed on Linux,docker, run on Linux it can also write some integrated small scripts, This is an SH script that engineers provide us with a deployment release scenario

#!/bin/Bashdeclare-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 forProjectinch "${projectlist[@]}" DoEcho-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 popddone# 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)-ffi# No need to build the images, Docker build or Docker compose will# DoThatusingThe images and containers definedinchThe Docker-compose.yml file.

The above solution mainly embodies the release of some of the commands used, such as arrays, traversal, conditional statements, delete files, publish statements, etc., I write my own practice practiced hand

Declare-a arr= (12345) forIinch "${arr[@]}" Do if[$i = =2]then Echo"A is equal to 2"ElseEcho"a is not equal to 2"Fidonedeclare-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') forProjectinch "${projectlist[@]}" DoEcho-E"\e[33m working in directory $ (PWD)/$project"Echo-E"\e[33m\tremoving old publish output" Done

When you write the sh file, be aware that Linux and Windows are not the same as the carriage return, we can download notepad++ this tool for transcoding.

Linux~sh script a bit of your own summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.