2019-10-12 14:46:06    229    0    0

http://www.zsythink.net/archives/tag/iptables/

 

整理中。。

iptable

  • iptable 按设置的规则执行
  • 规则规定了 源地址 目标地址 传输协议 服务类型 等
  • 数据包如果符合这些规则,就进行对应的操作
  • 操作的类型的 放行(accept),拒绝(reject),丢弃(drop)

 

而我们对iptables 的配置,实际是就是对iptable中 的规则进行增 删 改。

 

 

概念:

数据包流向,链,表

 

1. 数据包流向

 

2. 链

 

3. 表

iptable 定义了4种表,缺省是filter, 其他表可用-t 指定

2019-10-12 10:22:29    318    0    0

Ubuntu - 64位系统缺失32位共享库

报错

  1. Invocation of this Java Application has caused an InvocationTargetException. This application will now exit. (LAX)
  2. Stack Trace:
  3. java.lang.UnsatisfiedLinkError: /opt/AccuRev/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
  4. at java.lang.ClassLoader$NativeLibrary.load(Native Method)
  5. #../jre/lib/**i386**/xawt/libmawt.so:libXext.so.6
  6. 这个报错表明程序安装目录有一个32位的libmawt.so需要调用32位的共享库libXext.so.6,但是找不到该库。

解决思路

一般报此错是因为64位系统执行的软件需要32位共享库的支持:

  1. #确认64位内核架构
  2. >dpkg --print-architecture
  3. amd64
  4. #确认‘支持32位’ 是否打开
  5. >dpkg --print-foreign-architectures
  6. i386
  7. #如果没有打开支持32位的功能,需打开
  8. >sudo dpkg --add-architecture i386

安装32位库:

  1. apt-get install libxext6:i386
  2. #安装报错指出的库后,再行,发现已经pass , 继续报其他丢失库,继续安装
  3. apt-get install libxtst6:i386
  4. apt-get install libxi6:i386
? svn ? ? shell ?    2019-10-12 10:00:26    1778    1    0

svn 强制提交日志

分析:

检查时间:提交前

效果:日志符合要求成功提交,日志不符合要求给出提示,并中断提交。

 

适用钩子脚本:svn -> hooks -> pre-commit (commit 前触发执行的脚本),当svn 有commit 请求时,会触发执行pre-commit(shell脚本),当这个脚本以非0退出时,中断commit , 当脚本正常退出时,允许commit.

 

进入版本库配置目录hooks ,可见模板 pre-commit.tmpl ,复制为pre-commit 。

root@tclserver:/var/svn/svn_dir/Auto_script/hooks# ll
-rwxr-xr-x 1 root root 3350 Apr 6 2017 pre-commit*
-rwxr-xr-x 1 root root 3510 Feb 6 2017 pre-commit.tmpl*


 pre-commit.tmpl 原模板的内容分析

# PRE-COMMIT HOOK
#
# The pre-commit hook is invoked before a Subversion txn is
# committed.  Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] TXN-NAME     (the name of the txn about to be committed)
#   ........
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
 grep "[a-zA-Z0-9]" > /dev/null |
? gitlab ?    2019-09-18 13:45:21    283    0    0
? shell ? ? gitlab ?    2019-09-18 10:38:35    671    0    0

JQ URL

https://stedolan.github.io/jq/download/
https://stedolan.github.io/jq/manual/#Invokingjq
这是一个开源工具,用于处理json 。

前言

"The API uses JSON to serialize data. You don’t need to specify .json at the end of an API URL."

在linux 下使用gitlab API 返回json 对象,经常使用python处理返回结果。 如果只是单纯地使用shell脚本中,常将其当作文本,并用sed ,grep,cut分解。但是因为它不是准确地分解对象中的组成,而是简单地通过关键字进行筛选和切割,所以经常会有遗漏或不够准确。

在linux 中安装jq , 可以在shell 中直接使用jq 对json 对象进行处理。

安装jq

下载 jq 源码包编译安装
  1. # configure ,make ,make install
  2. cd jq
  3. autoreconf -i
  4. ./configure --disable-maintainer-mode
  5. make
  6. sudo make install

下载二进制文件直接使用

  1. [root@huangbei ~]# chmod +x jq-linux64
  2. [root@huangbei ~]# mv jq-linux64 /usr/bin/jq
  3. [root@huangbei ~]# jq
  4. jq - commandline JSON processor [version 1.6]
  5. Usage: jq [options] <jq filter> [file...]
  6. jq [options] --args <jq filter> [strings...]
  7. jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
  8. jq is a tool for processing JSON inputs, applying the given
? shell ?    2019-09-10 15:18:37    407    0    0


包含行首尾的空格

  1. echo ${#Massage}

不包含行首尾的空格

  1. echo $Massage | awk '{print length($0)}'

示例

  1. [lcf@huangbei ~]$ Massage=" Usage: $0 \${RELEASE_NOTE_FULL_PATH} "
  2. [lcf@huangbei ~]$ echo ${#Massage}
  3. 39
  4. [lcf@huangbei ~]$ echo $Massage | awk '{print length($0)}'
  5. 37
  1. [lcf@huangbei ~]$ Massage="Usage: $0 \${RELEASE_NOTE_FULL_PATH}"
  2. [lcf@huangbei ~]$ echo ${#Massage}
  3. 37
? gitlab ?    2019-09-05 15:05:35    1301    0    0


User setting and access

 

User Settings

登录gitlab.XX-company.com 之后在页面右上角头像处点击∨展开菜单,进入setting。

可以设置相关用户信息,常用的包括profile(基本配置),Account(帐户),Preferences(偏好设置),密码,SSH Keys,Notifications(邮件通知范围),Active Session(有效的连接)


Profile

可以在profile 里修改头像,邮箱,状态,及各平台关联帐号

 

Account

可以在account里修改用户名,用户名标识着与用户id 唯一关联的名称空间。一般不建议修改,如果修改,可能引起一些未知的影响,如必要修改,请严格按照修改页面的learn more 到“changing-your-username”根据提示做足步骤。

https://gitlab.XX-company.com/help/user/profile/index#changing-your-username

 

Notifications

全局通知设置:先在全局设置里可以设置通知的级别,然后在然后组/项目里分别设置为不同级别。默认为全局设置,展开可选其他。

 

Password

密码页面,修改密码后,会收到一个邮件,点击链接可以使用新密码登录(稍有延迟)

 

SSH Keys

SSH密钥允许您在计算机和GitLab之间建立安全连接,使用较多的情况是,当我们使用SSH 来 Clone 一个项目时,需要先在gitlab里配置好ssh keys。

一般我们在项目主页里展开clone 选项时,有两种方式,一种是clone with SSH,一种是Clone with HTTPS

 

当我们使用clone with SSH 时,我们需要先配置好ssh keys。

https://gitlab.XX-company.com/help/ssh/README#generating-a-new-ssh-key-pair

步骤是,先在一台linux 设备上生成一个密钥对,公钥拷到gitlab设置页面里,私钥放到需要clone 项目的设置上的默认ssh 配置路径。然后就可以直接使用这样的链接进行clone

Git clone git@gitlab.XX-company.com:vmc/products.git

 

另有直接使用用户/密码

? shell ?    2019-07-10 15:19:11    473    0    0

 

shell 里做 判断时[ 左边一直报错,语法无问题,有redhat 里执行没有问题,脚本放到ubuntu 时报错

[: test: unexpected operator​

 

解决:

ubuntu 的shell 默认指向dash , 需要改回bash

sudo dpkg-reconfigure dash

选择 no

2019-07-05 17:16:06    370    0    0

rel7.1 默认安装的python 没有连带安装python-pip,需要另装。

1.安装epel库

  1. #官方源中无python-pip
  2. yum search pip 发现无python-pip
  3. #搜索后发现需要安装第三方软件库
  4. yum -y install epel-release
  5. vi /etc/yum.repos.d/epel.repo
  6. [epel]
  7. baseurl //打开注释
  8. #metalink //注释
  9. yum clean all
  10. yum makecache

2.安装 pip

  1. yum install python-pip
? gitlab ?    2019-03-27 14:56:31    495    0    0

写在前面

gitlab 的CI/CD ,即持续集成,持续构建并部署测试的过程,实质上是
1. 将持续集成的过程阶段(编译构建/打包/部署/测试)写在gitlab.yml中
2. 并将准备执行gitlab.yml脚本内容的服务器配置为gitlab服务器的一个runner。
3. 当gitlab 库中的提交时,便会自动触发一次在runner 上的持续集成过程。


创建 gitlab-ci.yml

注意: gitlab.yml 是一个yaml文件,对缩进非常严格,需要始终使用空格,而非制表符。
https://gitlab.${company}.com/help/ci/yaml/README.md
具体格式及构成可参考gitlab help/ci/yaml/README.md 文件

  1. 在库中的根目录下,创建一个名为.gitlab.yml的文件
  2. 1. 通过 CI-CD --> jobs --> CI Init 直接编辑初始化文件
  3. 2. 在库中的根目录下,创建一个名为.gitlab.yml的文件

配置库的CI/CD

  1. 在库的设置中Setting--> CI/CD --> runners 展开
  2. 使用共享 runner 去运行 Shared Runners
  3. 使用指定 runner 去运行 Specific Runners //如从新配置一台服务器作为gitlab.yml 中脚本运行的runner,请按如下配置runner执行

配置 Runner

https://docs.gitlab.com/runner/install/

安装GitLab Runner

  1. # Linux x86-64
  2. sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

赋执行权限

  1. sudo chmod +x /usr/local/bin/gitlab-runner

创建 GitLab CI 用户:

7/12