Posts in category “Linux”

Attention: the first definition is used when you have more than one same host label in your .ssh/config file

I originally thought the later should be used. I was wrong.

Bash script for checking telnet service status


cat monitor.sh 
#!/bin/bash
source /etc/profile
cd /home/koala/Vagrant/windows-server-2019
(echo > /dev/tcp/192.168.178.220/23) > /dev/null 2>&1
if [ $? -ne 0 ]; then
  vagrant halt
  vagrant up
fi

How to use Jenkins to deploy a Node.JS backend project?

  1. Checkout code

  2. Set correct config file

  3. Scp to the remote machine

  4. Run deploy.sh on the remote machine by ssh

    • docker-compose build --no-cache
    • docker-compose down
    • docker-compose up -d

sshPublisher setup

  1. Manage Jenkins -> Config System
  • Find Publish over SSH
  • Add New Server, test connection
  1. Write directive in Jenkins file
            sshPublisher(
                continueOnError: false, failOnError: true,
                publishers: [
                 sshPublisherDesc(
                  configName: "yt-files-${BRANCH}",
                  verbose: true,
                  transfers: [
                   sshTransfer(
                    sourceFiles: "**/**",
                    remoteDirectory: "./publish/${BRANCH}",
                    removePrefix: '',
                    remoteDirectorySDF: false,
                    cleanRemote: true,
                    execCommand: "cd ./publish/${BRANCH} && bash deploy.sh ${BRANCH}"
                   )
                  ])
                ]
            )

要在Jenkins中新增对一个仓库的发布,需要以下步骤

  1. 创建流水线, 添加Git仓库,Credentials

  2. 为各分支添加必要的配置文件(不方便加入版本控制的机密信息)

  3. 写 Jenkinsfile

转换 gbk txt文件为 utf-8 编码

这都是为了看《非正常人类异闻录》

iconv -c -f gbk -t utf-8 待转文件名 > target.txt

-c 的意思是在输出文本中忽略非法的字符序列

Reference

然而都弄好了,即没有认真看那本书。不喜欢那种风格,没办法

设置mysql用户密码时小心 # 字符

我喜欢用 .my.cnf 配置 mysql 的登录信息,这样我执行一些命令的时候就不用在命令行上提供密码。但今天我被自己设置的”高强度密码“坑到了

简而言之,如果你的密码里有#字符,请用双引号把整个密码括起来,要知道没有被引号括起来的 #字符,标识后面的都是注释。哈