Fork me on GitHub

All Tags:

mindset

devops

book

ci

communication

jenkins

自媒体

hometown

geek life

cloud

Play With Debian

18 Apr 2019

Play With Debian

debian-logo

Records tools installation when playing with Debian.

Git Installation

sudo apt install git
git --version
git config --global user.name "Sammy"
git config --global user.email "sammy@domain.com"


Visual Studio Code Installation

Debian and Ubuntu based distributions

The easiest way to install Visual Studio Code for Debian/Ubuntu based distributions is to download and install the .deb package.

To install old 32 bit version for Linux (ex. version 1.32), you can find it here https://code.visualstudio.com/updates/v1_32


sudo apt install ./<file>.deb

# If you're on an older Linux distribution, you will need to run this instead:
# sudo dpkg -i <file>.deb
# sudo apt-get install -f # Install dependencies

Install using Snapd


sudo apt update
#Enable snapd
sudo apt install snapd -y
# Install Visual Studio Code
sudo snap install code --classic

Chinese Input 中文输入法


sudo apt-get install fcitx
sudo apt-get install fcitx-pinyin

./im-config # 输入法配置工具

Terminal 终端下复制粘贴快捷键

  • 复制 CTRL+SHIFT+C
  • 粘贴 CTRL+SHIFT+V

Games

# supertux
sudo apt-get install supertux

Password Manager

sudo apt-get install keepassx

BitTorrent Client


sudo apt-get install qbittorrent

Mount Network Location

sudo apt-get install cifs-utils smbclient


sudo mkdir /media/Data

# List the share name in remote host with real host ip
smbclient -L //192.168.*.*

sudo mount -t cifs -o username=*** //192.168.*.*/sharename /media/Data/

Claws Mail Setting

IMAP

服务器名称: outlook.office365.com

端口: 993

加密方法: TLS

SMTP

服务器名称: smtp.office365.com

端口: 587

加密方法: STARTTLS

Thunderbird Install

  • Download Thunderbird from the Thunderbird download page to your home directory.
  • Extract the contents of the downloaded file
      tar xjf thunderbird-*.tar.bz2
    
  • To start Thunderbird, run the thunderbird script in the thunderbird folder: ~/thunderbird/thunderbird

  • Create the desktop shortcut launcher

Create a new text file called Thunderbird.desktop in the /home/pi/Desktop/ directory, e.g. /home/pi/Desktop/Thunderbird.desktop, contains the connect below:

[Desktop Entry]
Name=Thunderbird
Comment=Thunderbird Shortcut
Icon=/path/to/a/icon/for/the/Thunderbird/shortcut
Exec=/usr/share/applications/Thunderbird
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

VPN


sudo apt-get install shadowsocks

sslocal -c sslocal.conf # connect to the proxy server.

Firefox Proxy Setting

Firefox Flash Player

Download and execute this shell script fireflashupdatewith the following commands:


wget https://raw.githubusercontent.com/cybernova/fireflashupdate/master/fireflashupdate.sh
chmod +x fireflashupdate.sh
./fireflashupdate.sh

Putty - SSH Client


sudo apt-get install putty

GIMP - Open Source Image Editor

# https://www.gimp.org/
sudo apt-get install gimp

Snapd - Tool to interact with Ubuntu Core Snappy

Snaps are app packages for desktop, cloud and IoT that are easy to install, secure, cross-platform and dependency-free.

sudo apt-get install snapd
sudo reboot
sudo snap install hello-world ## find the snaps to install from store https://snapcraft.io/store

Find - search for files


find . -name "*羽毛球*" # search current path for a file name contains '羽毛球'


List the recently installed packages

# This will list all the packages including the dependencies that were installed recently on your system along with the time of installation.
grep " install " /var/log/dpkg.log

# This will show only the programs that you installed using apt command.
grep " install " /var/log/apt/history.log

多屏幕显示

# 显示可用显示器
xrandr

# 仅在外接VGA显示器显示,关闭笔记本显示器
xrandr --output VGA-1 --auto --output LVDS-1 --off

# 扩屏显示
xrandr --output VGA-1 --auto --right-of LVDS-1

摄像头视频拍照工具

# cheese  一个使用摄像头拍摄录像或照片的工具

sudo apt-get install cheese

Printer Setup

Install HP Linux Image and Printer

https://developers.hp.com/hp-linux-imaging-and-printing/gethplip



sudo apt-get install hplip
sudo apt-get install hplip-gui


Install aria2


sudo apt-get install aria2

aria2c -h

start simplenote


sudo simplenote --no-sandbox

Screenshot Tools

scrot - commandline screenshot tool

In commandline, type ‘scrot’ will take the screenshot, or press ‘PrintScreen’ button will take the screenshot.


scrot
# The screenshot is saved under the specified file name. In addition, the parameters cause the screenshot to be created only after a delay of -d (delay) of 5 seconds. The parameter -c also displays this delay as a countdown. 
scrot -cd 5 screenshot.png

# -s select the region to take screenshots
scrot -s -cd 5 ./images/screenshot.png

gnome-screenshot

Making a Keyboard Shortcut for Gnome Screenshot The one real downside to Gnome Screenshot is that, as soon as you save one picture, the app closes and you need to launch it again for the next capture.

In fact, you can change the configuration so PrtSrc launches Gnome Screenshot instead of Scrot. In short, you must

  1. Open the /etc/xdg/openbox/lxde-pi-rc.xml file for editing.

sudo nano /etc/xdg/openbox/lxde-pi-rc.xml

  1. Add the following code somewhere under the section.
gnome-screenshot --interactive</command>

That will assign Gnome Screenshot to CTRL + ALT + PrtScr, but you can also override the regular PrtSrc command that launches Scrot by editing it in this section.

sudo apt install gnome-screenshot

# open it in terminal
gnome-screenshot --interactive
gnome-screenshot -i

MOUSE WITHOUT BORDERS : Barrier

Ubuntu/Debian/Raspbian: Build from source https://github.com/debauchee/barrier/wiki/Building-on-Linux

    sudo apt update && sudo apt upgrade
    sudo apt install git cmake make xorg-dev g++ libcurl4-openssl-dev \
                    libavahi-compat-libdnssd-dev libssl-dev libx11-dev \
                    libqt4-dev qtbase5-dev
    git clone git@github.com:debauchee/barrier.git
    # this builds from master,
    # you can get release tarballs instead
    # if you want to build from a specific tag/release
    cd barrier
    ./clean_build.sh
    cd build
    sudo make install  # installs to /usr/local/ 
    barrier

Labs: Jenkins Embeddable Build Status

03 Apr 2019

Labs: Jenkins Embeddable Build Status

Jenkins exposes the current status of your build as an icon in a fixed URL. You can put this URL into other sites (such as GitHub README) so that people can see the current state of the build.

  • Install “Embeddable Build Status Plugin” at Jenkins -> Plugin Manager
  • Go to your job view, and click the “Embeddable Build Status” on the left.
  • Get the Markdown format link and put it into your README.md

Docker On Docker

02 Apr 2019

Labs: Pipeline with Dockerfile to run in the Slave Agent Node

Now you have Jenkins installed, If you have a Jenkinsfile try to run stage in a dedicated docker container instance, You have two options to resolve the dependency to docker.


 pipeline {
        //  agent  any

    stages {
        stage('Spell Check') {
                agent {
                    dockerfile {
                        filename 'Dockerfile.mdspell'
                        args '-u="root"'
                        }
                }
        }
    }

 }

Install Docker Within Jenkins Master

Slave Agent Node With Docker installed

For my case, I have Jenkins running as a Docker container in an Azure Ubuntu Linux VM, so in the VM host I already have Docker installed. But within the container of Jenkins, the docker is not installed.

So I specify another VM host with Docker installed as a slave agent node to the Jenkins Master host (192.168.1.1:8080). The Jenkins Master will assign pipeline jobs to the slave agent node to run.

  • Go to Jenkins-> Manage Jenkins-> Manage Node {Your-Jenkins-Root-URL}/computer/new and give the node a named “docker-agent”
  • Configure as below and Save.

    Add Node

  • Check the Node Log {Your-Jenkins-Root-URL}/computer/docker-agent/log to make sure the agent connected.

Notes: during my setting up, the log remind me to install Java in the slave agent node.


sudo apt install openjdk-8-jdk


Labs: GitHub Push触发Jenkins自动构建

01 Apr 2019

Labs: GitHub Push触发Jenkins自动构建

GitHub上配置Jenkins的webhook地址

  • Step 1: 假设Jenkins所在服务器的地址是:192.168.0.1,端口为8080,那么webhook地址就是 http://192.168.0.1:8080/github-webhook/

  • Step 2: GitHub -> Settings -> Webhooks -> Add webhook and fill Payload URL with the webhook address in step 1.

Troubleshoot

  • Error: We couldn’t deliver this payload: Failure when receiving data from the peer.

    Make sure the port of the Jenkins Server allow the inbound from GitHub. If the Jenkins Server is hosted in Azure VM, define an inbound port rule to allow traffic from GitHub Server.

Generate Personal Access Token

当Jenkins 接收到来之GitHub的webhook 的通知后,Jenkins需要访问GitHub repository的时候,有的操作是需要授权的,所以我们要在GitHub上生成授权的token给Jenkins使用,这就是Personal access tokens.

Jenkins配置

  • Manage Jenkins->Configure System -> Add GitHub Server
  • Fill “API URL” with https://api.github.com, “Credentials” Choose “Add”

    Add GitHub Server

  • In The pop up form,”Kind” Choose ”Secret text”,”Secret”填入前面在GitHub上生成的Personal access tokens.

  • 填写完毕后,点击Configure System页面中右侧的”Test connection”按钮.

The Sre Workbook Reading Notes

30 Mar 2019

Reading Notes: The Site Reliability Workbook: Practical Ways to Implement SRE

Chapter 8 On Call

Google’s on-call practice:

  • Make sure never achieve reliability at the expense of an on-call engineer’s health.
  • SRE work should be a healthy mix of duties: on-call and project work.
  • Google SRE target a maximum of two incidents per on-call shift.
  • cash compensation for on-call.

The responsibilities of on-call engineers:

  • The on-call engineer minimizes user impact first, then makes sure the issues are fully addressed.
  • At the start of each shift, the on-call engineer reads the handoff from the previous shift.
  • At the end of the shift, the on-call engineer sends a handoff email to the next engineer on-call.