http://www.zsythink.net/archives/tag/iptables/
整理中。。
iptable
而我们对iptables 的配置,实际是就是对iptable中 的规则进行增 删 改。
概念:
数据包流向,链,表
1. 数据包流向
2. 链
3. 表
iptable 定义了4种表,缺省是filter, 其他表可用-t 指定
Ubuntu - 64位系统缺失32位共享库
Invocation of this Java Application has caused an InvocationTargetException. This application will now exit. (LAX)
Stack Trace:
java.lang.UnsatisfiedLinkError: /opt/AccuRev/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
#../jre/lib/**i386**/xawt/libmawt.so:libXext.so.6
这个报错表明程序安装目录有一个32位的libmawt.so需要调用32位的共享库libXext.so.6,但是找不到该库。
一般报此错是因为64位系统执行的软件需要32位共享库的支持:
#确认64位内核架构
>dpkg --print-architecture
amd64
#确认‘支持32位’ 是否打开
>dpkg --print-foreign-architectures
i386
#如果没有打开支持32位的功能,需打开
>sudo dpkg --add-architecture i386
安装32位库:
apt-get install libxext6:i386
#安装报错指出的库后,再行,发现已经pass , 继续报其他丢失库,继续安装
apt-get install libxtst6:i386
apt-get install libxi6:i386
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 |
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 对象进行处理。
# configure ,make ,make install
cd jq
autoreconf -i
./configure --disable-maintainer-mode
make
sudo make install
[root@huangbei ~]# chmod +x jq-linux64
[root@huangbei ~]# mv jq-linux64 /usr/bin/jq
[root@huangbei ~]# jq
jq - commandline JSON processor [version 1.6]
Usage: jq [options] <jq filter> [file...]
jq [options] --args <jq filter> [strings...]
jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given
echo ${#Massage}
echo $Massage | awk '{print length($0)}'
[lcf@huangbei ~]$ Massage=" Usage: $0 \${RELEASE_NOTE_FULL_PATH} "
[lcf@huangbei ~]$ echo ${#Massage}
39
[lcf@huangbei ~]$ echo $Massage | awk '{print length($0)}'
37
[lcf@huangbei ~]$ Massage="Usage: $0 \${RELEASE_NOTE_FULL_PATH}"
[lcf@huangbei ~]$ echo ${#Massage}
37
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 里做 判断时[ 左边一直报错,语法无问题,有redhat 里执行没有问题,脚本放到ubuntu 时报错
[: test: unexpected operator
解决:
ubuntu 的shell 默认指向dash , 需要改回bash
sudo dpkg-reconfigure dash
选择 no
rel7.1 默认安装的python 没有连带安装python-pip,需要另装。
#官方源中无python-pip
yum search pip 发现无python-pip
#搜索后发现需要安装第三方软件库
yum -y install epel-release
vi /etc/yum.repos.d/epel.repo
[epel]
baseurl //打开注释
#metalink //注释
yum clean all
yum makecache
yum install python-pip
gitlab 的CI/CD ,即持续集成,持续构建并部署测试的过程,实质上是
1. 将持续集成的过程阶段(编译构建/打包/部署/测试)写在gitlab.yml中
2. 并将准备执行gitlab.yml脚本内容的服务器配置为gitlab服务器的一个runner。
3. 当gitlab 库中的提交时,便会自动触发一次在runner 上的持续集成过程。
注意: gitlab.yml 是一个yaml文件,对缩进非常严格,需要始终使用空格,而非制表符。
https://gitlab.${company}.com/help/ci/yaml/README.md
具体格式及构成可参考gitlab help/ci/yaml/README.md 文件
在库中的根目录下,创建一个名为.gitlab.yml的文件
1. 通过 CI-CD --> jobs --> CI Init 直接编辑初始化文件
2. 在库中的根目录下,创建一个名为.gitlab.yml的文件
在库的设置中Setting--> CI/CD --> runners 展开
使用共享 runner 去运行 : Shared Runners
使用指定 runner 去运行 : Specific Runners //如从新配置一台服务器作为gitlab.yml 中脚本运行的runner,请按如下配置runner执行
安装GitLab Runner
# Linux x86-64
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
赋执行权限
sudo chmod +x /usr/local/bin/gitlab-runner
创建 GitLab CI 用户: