Skip to main content

45 posts tagged with "linux"

View All Tags

· 2 min read

1

default:
cat Makefile

a:
go run cmd/pipeline-demo/main.go

b:
go run cmd/pipeline-demo/main.go

2

demo="Usage: \n\
\# 设置 crontab \n\
\t make crontab proj=xdq type=yy env=test \
"

default:
@echo ${demo}

crontab:
@echo $(proj) $(type) $(env)

3

default:
cat Makefile

build: build-fe build-be build-pkg

build-be:
docker run -it --rm \
-v "$$GOPATH/src":/go/src \
-w /go/src/github.com/zx5435/wolan/cmd/wolan-server \
golang:1.10.2 \
sh -c "CGO_ENABLED=0 GOOS=linux go build -v -installsuffix cgo -o wolan-server"

build-fe:
cd frontend && npm run build

build-pkg:
docker build -f __cicd__/Dockerfile -t zx5435/wolan .

ingress-build:
docker run -it --rm \
-v "$$GOPATH/src":/go/src \
-w /go/src/github.com/zx5435/wolan/cmd/wolan-ingress \
golang:1.10.2 \
sh -c "CGO_ENABLED=0 GOOS=linux go build -v -installsuffix cgo -o wolan-ingress"

ingress-pkg:
docker build -f __cicd__/Dockerfile.ingress -t zx5435/wolan:ingress .

ingress-test:
docker run -it -d --name wolan-ingress -p80:80 -p443:443 zx5435/wolan:ingress

restart: down up

up:
docker stop wolan
docker rm wolan
cd __work__ && docker run -it -d --name wolan -p 4321:23456 \
-v "$$PWD":/app/__work__ \
-v "/var/run/docker.sock:/var/run/docker.sock" \
zx5435/wolan

参考

NAME=timescaledb-postgis
ORG=timescale
PG_VER=pg10
VERSION=$(shell awk -F ':' '/^FROM/ { print $$2 }' Dockerfile | sed "s/\(.*\)-.*/\1/")

default: image

.build_postgis_$(VERSION)_$(PG_VER): Dockerfile
ifeq ($(PG_VER),pg9.6)
docker build --build-arg POSTGIS_VERSION=2.3.7 --build-arg PG_VERSION_TAG=$(PG_VER) -t $(ORG)/$(NAME):latest-$(PG_VER) .
docker tag $(ORG)/$(NAME):latest-$(PG_VER) $(ORG)/$(NAME):latest
else
docker build --build-arg POSTGIS_VERSION=2.4.4 --build-arg PG_VERSION_TAG=$(PG_VER) -t $(ORG)/$(NAME):latest-$(PG_VER) .
endif
docker tag $(ORG)/$(NAME):latest-$(PG_VER) $(ORG)/$(NAME):$(VERSION)-$(PG_VER)
touch .build_postgis_$(VERSION)_$(PG_VER)

image: .build_postgis_$(VERSION)_$(PG_VER)

push: image
docker push $(ORG)/$(NAME):$(VERSION)-$(PG_VER)
docker push $(ORG)/$(NAME):latest-$(PG_VER)
ifeq ($(PG_VER),pg9.6)
docker push $(ORG)/$(NAME):latest
endif


clean:
rm -f *~ .build_postgis_*

.PHONY: default image push clean

grundfos ccm

IMAGE_NS := registry.cn-shanghai.aliyuncs.com/digital-web
#TIME := $(shell date +"%Y%m%d_%H%M%S")
TIME := $(shell date +"%Y%m%d")
VER := ${TIME}_${CI_COMMIT_SHORT_SHA}
VER_RT := $(shell date +"%Y%m%d_%H%M")

default:
cat Makefile

test:
@echo ${VER}

gsc-build-runtime-image:
docker build -f __cicd__/sct.rt.Dockerfile -t ${IMAGE_NS}/sct-rt:${VER_RT} .
docker push ${IMAGE_NS}/sct-rt:${VER_RT}

ccm-build:
echo ${sid} ${env}
docker build -f __cicd__/ccm.code.Dockerfile --build-arg env=${env} -t ${IMAGE_NS}/ccm-code:${VER}_${env} .
docker push ${IMAGE_NS}/ccm-code:${VER}_${env}

ccm-deploy:
echo ${sid} ${env}
docker build -f __cicd__/gim.code.Dockerfile --build-arg env=${env} -t ${IMAGE_NS}/gim-code:${VER}_${env} .
docker push ${IMAGE_NS}/gim-code:${VER}_${env}
docker exec -w /www/env/sandbox/6.2.0.${sid}_ccm tf_tf_1 terraform apply -auto-approve -var sha=${VER}_${env}

· 2 min read

查看帮助(h) 新建分区(n) 删除分区(d) 查看分区情况(p) 写分区表并退出(w)

mount

# 首先检查是否有硬盘未被挂载
fdisk -l

# 在分别输入n、p、1、2048、1048575999、w
fdisk /dev/vdb

# 对 1 分区格式化
mkfs.ext4 /dev/vdb1

# 新建目录
mkdir disk2

# 分区信息
cat /etc/fstab
echo '/dev/vdb1 /www ext4 defaults 0 0' >> /etc/fstab

# 加载新建分区 reload
mount -a
/etc/sysconfig/network-scripts/ifcfg-eth0 /etc/resolv.conf

7709f5e8-0d1a-4a02-8dde-aca8214bc46c

vi /etc/grub.d/40_custom
menuentry 'Install haikang'{
search --no-floppy --fs-uuid --set=root 7709f5e8-0d1a-4a02-8dde-aca8214bc46c
loopback loop /CentOS-7.6-hik-r5-patch3.iso
linux16 (loop)/isolinux/vmlinuz linux repo=hd:/dev/disk/by-uuid/7709f5e8-0d1a-4a02-8dde-aca8214bc46c:/ nouveau.modeset=0
initrd16 (loop)/isolinux/initrd.img
}
将以上命令中的 08879471-79d3-4d98-9380-c40bb4bc300b替换为记录的UUID(注意是两处),并保证CentOS-7-x86_64-Minimal-1804.iso镜像名称和下载的一致。

vi /etc/default/grub
修改或添加GRUB_DEFAULT=saved 为 GRUB_DEFAULT="CentOS-7-x86_64-Minimal-1804.iso" 注意和下载的镜像名称一致

umount

yum install -y psmisc # fuser
fuser -km /mountdata/ # 释放链接
umount /mountdata # folder name
umount -f /mountdata

· 2 min read

无密码登录

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

pem

ssh-keygen -t rsa -P '' -f ~/.ssh/id_zyj
openssl rsa -in ~/.ssh/id_zyj -outform pem > id_zyj.pem
chmod 700 id_zyj.pem

autossh 内网穿透

https://www.cnblogs.com/kwongtai/p/6903420.html

# 在inner机器用777远端开启9292
ssh -fCNR 9292:localhost:777 root@101.132.151.41
# mysql 代理
ssh -fNg -L 3307:10.10.75.22:3306 -p 22 root@101.1.5.53

# ssh -fCNR [B机器IP或省略]:[B机器端口]:[A机器的IP]:[A机器端口] [登陆B机器的用户名@服务器IP]
# autossh
autossh -f -M Bport监控 -fCNR Bport:Aip:Aport root@Bip
autossh -f -M 6023 -fCNR 6022:localhost:22 -p1022 root@101.132.77.68 # 远程ssh
autossh -f -M 7002 -fCNR 7001:localhost:7003 -p1022 root@101.132.77.68
autossh -f -M 7778 -fCNR 7777:localhost:777 root@101.132.151.41

修改ssh默认端口

vi /etc/ssh/sshd_config
Port 1022
PermitRootLogin yes
service sshd restart

expect iterm 登录

set user zhaoyujie
set password qwerqwer
set timeout -1

spawn ssh -p2222 -i ~/Desktop/docs/zhaoyujie-jumpserver.pem $user@47.101.140.238
expect "*assword:*"
send "$password\r"
# expect "Opt>*"
# send "\r"
interact
#expect eof

vpn

https://www.jianshu.com/p/4801adfcd07e

· One min read
svn checkout https://svn.coding.net/zx5435/pan/pan-test
svn status
svn add read.md
svn commit -m 'c1'