sh CentOS 7:将用户添加到wheel组

add_user_to_wheel.sh
usermod -aG wheel $username

sh Net Core和Nuget命令

disable_package.sh
dotnet sources disable -name NameOfFeed
add_package_to_project.sh
dotnet add package Newtonsoft.Json -s https://www.nuget.org/api/v2/
list_nuget_sources.sh
nuget sources
create_console_application.sh
dotnet new console --name NameOfProject
run_project
dotnet run
build_project.sh
dotnet build
list_sdks.sh
dotnet --list-sdks
list_runtimes.sh
dotnet --list-runtimes
clean_project.sh
dotnet clean
restore_project.sh
dotnet restore
create_project_with_sln.sh
dotnet new sln
add_project_to_sln.sh
dotnet sln solution.sln add project_folder/project.csproj
remove_project_from_sln.sh
dotnet sln solution.sln remove project_folder/project.csproj
add_all_projects_to_sln.sh
dotnet sln solution.sln add **/*.csproj
remove_all_projects_from_sln.sh
dotnet sln todo.sln remove **/*.csproj

sh 查找特定文件,并加以拷贝

find_batch_save
#!usr/bin/bash

for file in $(cat ./to_copy_list.txt);
do find ./ -type f \( -iname 9060419022816256\*.pdf -o -iname 9060419022816256\*.png \
-o -iname 9060419022816256\*_5sent_add.txt  \
-o -iname 9060419022816256\*bch.csv \
-o -iname 9060419022816256\*bch_noshai.csv \
-o -iname 9060419022816256\*_content.csv \
-o -iname 9060419022816256\*_content_front_show.csv \
-o -iname 9060419022816256\*_data_frame_biaoming.csv \
-o -iname 9060419022816256\*_data_frame.csv \
-o -iname 9060419022816256\*_wordplus.xml \
-o -iname 9060419022816256\*_word.xml \
 \)|xargs -t -I {} cp {} to_copy_files/;tar -cvzf to_copy_files.tar.gz to_copy_files/*;done

sh credential_process

credential_process_sts.sh
aws sts assume-role --duration-seconds 900 --role-arn "<roll-arn>" --external-id "<external-id>" --role-session-name AWSCLI-Session | jq ".Credentials + {Version: 1}"

sh 在VMWare下,在Linux中将所有CPU和RAM联机

cpu-mem-online.sh
#!/bin/bash
# Based on script by William Lam - http://engineering.ucsb.edu/~duonglt/vmware/

# Bring CPUs online
for CPU_DIR in /sys/devices/system/cpu/cpu[0-9]*
do
    CPU=${CPU_DIR##*/}
    echo "Found cpu: '${CPU_DIR}' ..."
    CPU_STATE_FILE="${CPU_DIR}/online"
    if [ -f "${CPU_STATE_FILE}" ]; then
        if grep -qx 1 "${CPU_STATE_FILE}"; then
            echo -e "\t${CPU} already online"
        else
            echo -e "\t${CPU} is new cpu, onlining cpu ..."
            echo 1 > "${CPU_STATE_FILE}"
        fi
    else 
        echo -e "\t${CPU} already configured prior to hot-add"
    fi
done

# Bring all new Memory online
for RAM in $(grep line /sys/devices/system/memory/*/state)
do
    echo "Found ram: ${RAM} ..."
    if [[ "${RAM}" == *":offline" ]]; then
        echo "Bringing online"
        echo $RAM | sed "s/:offline$//"|sed "s/^/echo online > /"|source /dev/stdin
    else
        echo "Already online"
    fi
done

sh preview_stash

保存自https://stackoverflow.com/questions/3573623/is-it-possible-to-preview-stash-contents-in-git

previtew_stash.sh
git stash show -p stash@{2}

sh 丢弃多个stashes

multiple_stash_drop.sh
for n in {0..5}; do git stash drop; done

sh Sed删除Line.sh

Sed Delete A Line.sh
sed -i '/pattern/d' file

sh file.sh中的Sed替换模式

Sed Substitute Pattern in file.sh
sed -i.bak 's/pattern1/pattern2/g' file

sh AKS,ACR,ACI

docs.md
# Kubernetes cluster architecture

A Kubernetes cluster is divided into two components:
- Cluster master nodes provide the core Kubernetes services and orchestration of application workloads.
- Nodes run your application workloads.

![arch](https://docs.microsoft.com/en-us/azure/aks/media/concepts-clusters-workloads/cluster-master-and-nodes.png)

# Nodes and node pools

To run your applications and supporting services, you need a Kubernetes node. 

An AKS cluster has one or more nodes, which is an Azure virtual machine (VM) 
that runs the Kubernetes node components and container runtime.

![nodes](https://docs.microsoft.com/en-us/azure/aks/media/concepts-clusters-workloads/aks-node-resource-interactions.png)
create kubernetes cluster.sh
az group create --name myResourceGroup --location eastus

# create cluster
az aks create \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --node-count 1 \
    --enable-addons monitoring \
    --generate-ssh-keys

# install kubectl
az aks install-cli

# download credentials and configurs Kubernetes CLI to use them
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster

# verify the connection
kubectl get nodes

# Deploy the application using the kubectl apply
kubectl apply -f app.yaml

# Delete cluser by deleting resource group
az group delete --name myResourceGroup --yes --no-wait
create image using docker.sh
# Dockerfile:
FROM node:8.9.3-alpine
RUN mkdir -p /usr/src/app
COPY ./app/ /usr/src/app/
WORKDIR /usr/src/app
RUN npm install
CMD node /usr/src/app/index.js

# create the container image and tag it as aci-tutorial-app
docker build ./aci-helloworld -t aci-tutorial-app

# Use the docker images command to see the built image:
docker images

# Your newly built image should appear in the list
# REPOSITORY          TAG       IMAGE ID        CREATED           SIZE
# aci-tutorial-app    latest    5c745774dfa9    39 seconds ago    68.1 MB

# run locally
#   -d lets the container run in the background
#   -p maps port 8080 on your computer to port 80 in the container
docker run -d -p 8080:80 aci-tutorial-app
create acr.sh
az group create --name myResourceGroup --location eastus

# create registry
az acr create --resource-group myResourceGroup --name <acrName> --sku Basic --admin-enabled true

# log in to registry before pushing images to it
az acr login --name <acrName>

# get the full login server name for ACR - required for tagging
az acr show --name <acrName> --query loginServer --output table
# e.g. <acrName>.azurecr.io

# tag image ready for push to ACR
docker tag aci-tutorial-app <acrName>.azurecr.io/aci-tutorial-app:v1

# Verify tagging
docker images
# REPOSITORY                              TAG       IMAGE ID        CREATED           SIZE
# aci-tutorial-app                        latest    5c745774dfa9    39 minutes ago    68.1 MB
# <acrName>.azurecr.io/aci-tutorial-app   v1        5c745774dfa9    7 minutes ago     68.1 MB

# push to ACR
docker push <acrName>.azurecr.io/aci-tutorial-app:v1

# list images in ACR
az acr repository list --name <acrName> --output table
# Result
# ----------------
# aci-tutorial-app

# To see the tags for a specific image, use the az acr repository show-tags command.
az acr repository show-tags --name <acrName> --repository aci-tutorial-app --output table
# Result
# --------
# v1
deploy to ACI.sh
# use the az container create command to deploy the container
az container create --resource-group myResourceGroup \
    --name aci-tutorial-app \
    --image <acrName>.azurecr.io/aci-tutorial-app:v1 \
    --cpu 1 --memory 1 --registry-login-server <acrName>.azurecr.io \
    --registry-username <service-principal-ID> \
    --registry-password <service-principal-password> \
    --dns-name-label <aciDnsLabel> \
    --ports 80

# view the state of the deployment
az container show --resource-group myResourceGroup --name aci-tutorial-app --query instanceView.state
"Running"

# view app
az container show --resource-group myResourceGroup --name aci-tutorial-app --query ipAddress.fqdn
"aci-demo.eastus.azurecontainer.io"

# view logs
az container logs --resource-group myResourceGroup --name aci-tutorial-app