分类: Linux Development

  • acme.sh with Google SSL certificate

    Acme.sh issue SSL certificate with Google

    Install acme.sh

        sudo su
        source ~/env.sh
        env|grep proxy|grep http
    
        curl https://get.acme.sh|sh
        exit
        sudo su
        source ~/env.sh
        source /root/.acme.sh/acme.sh.env
        acme.sh --set-default-ca --server google

    Generae EAB:

    # Must install Google Cloud SDK first
    gcloud publicca external-account-keys create

    Register Account:

    acme.sh --register-account -m admin@zhenglei.net --server google --eab-kid "your KeyId" --eab-hmac-key "your b64MacKey"

    Issue:

    sudo su
       
       # Stop services listen 80/443 port
       #/opt/local/etc/init.d/openresty stop
      
       source ~/env.sh
       source /root/.acme.sh/acme.sh.env
    
       # Only have IP v6 public Address
       acme.sh  --issue  -d blog.zhenglei.net  --standalone --listen-v6

  • Install Google Cloud SDK on Debian system

    Install google-cloud-cli

    sudo su
    
    source ~/proxy.sh
    env|grep proxy|grep http
    
    apt-get update
    apt-get install apt-transport-https ca-certificates gnupg  curl socat
    
    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
    
    echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
    
    apt-get update
    apt install google-cloud-cli
    gcloud init
  • Install music-tag-web on debian system

    Remote debian system

    ssh remote.zhenglei.net
    sudo su
    docker pull xhongc/music_tag_web:latest
    docker images
    docker save -o music_tag_web.tar  xhongc/music_tag_web:latest
    

    Local debian system

    ssh local.zhenglei.net
    scp remote.zhenglei.net:/${YOUR_PATH}/remote.zhenglei.net .
    sudo su
    docker load < music_tag_web.tar
    docker image ls

    Launch

    sudo su
    ./music_tag_web.sh
    
    cat music_tag_web.sh
    
    #!/bin/bash
    PORT=8001:8001
    DATA=/Music
    CFG=/docker/music/config
    
    MTAG=xhongc/music_tag_web:latest
    
    if [ ! -d ${CFG} ];then
      mkdir -p ${CFG}
    fi
    
    if [ ! -d ${DATA} ];then
      mkdir -p ${DATA}
    fi
    
    docker run -d -p ${PORT} -v ${DATA}:/app/media -v ${CFG}:/app/data --restart=always ${MTAG}
    

    Verify

    http://yor_ip:8001

    default login: admin:admin

    Stop

    sudo su
    docker stats
    docker stop  $(docker ps -q)

    Install ffmpeg

    sudo apt-get instgall ffmpeg
    which ffmpeg
    # cd ${CFG}/bin
    cd /docker/music/config/bin
    sudo ln /usr/bin/ffmpeg
  • Install docker on Debian

    sudo apt update
    
    sudo apt upgrade
    
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg2
    
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
    
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
    
    sudo apt update
    sudo apt install docker-ce
    
    
    sudo usermod -aG docker $USER
    
    
  • Increasing the amount of inotify watchers for debian

    sudo cat /proc/sys/fs/inotify/max_user_watches

    sudo sh -c “echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf”

    sudo sysctl -p

    sudo cat /proc/sys/fs/inotify/max_user_watches

  • 给家中的服务器, 分配 IPv6公网地址

    条件:

    中国电信光猫, Openwrt 路由器, 阿里云域名

    Step 1: 路由器升级, 最新版 OpenWrt / 23.05.03

    Step 2: 从电信获得 宽带帐号/宽带密码

    Step 3: 设置光猫为Bridge 模式

    Step 4: 路由器 Lan 接口 IPv4 地址设置为 10.0.0.1

    Step 5: 路由器 Wan 接口 修改为 PPPoE 模式, PAP/CHAP username/password 填入从电信获得的 宽带帐号/宽带密码

    Step 6: 因为PPPoE 拨号会同时获得 IPv4 和 IPv6地址,wan6 接口没用,删除wan6接口

    Step 7: 重起wan接口,会自动拨号,若成功,自动增加wan_6虚拟接口,IPv6 和IPv6-PD

    Step 8: 修改Lan接口Advanced Setting:

    Delegate IPv6 prefixes = yes

    IPv6 assignment length = 60

    IPv6 prefix filter = wan_6

    Step 9: 修改路由器 network/dhcp/Static Leases, 为每个IPv6公网网卡增加一项纪录:

    包括: Hostname, Mac 地址,IPv4,IPv6-Suffix,

    为方便记忆,我选择 IPv4 最后一栏与IPv6-Suffix 相同,

    比如,mpd IPv4=10.0.0.222, mpd的IPv6-Suffix 设置为0222

    Step 10: 根据应用需要,修改基于端口的防火墙:Network/Firewall/TrafficRules 增加纪录

    至此,路由器设置完毕

    域名更新

    由于每次拨号,都会获得一个不同的IPv6-PD值

    可以使用脚本程序,监控路由器中的IPv6-PD值,若有变化,调用域名服务商的API接口,更新IPv6值

    https://github.com/zhengleic/ddns-aliyun

    存在问题

    发现重新拨号,IPv6-PD变化后,应用服务器可以自动获得新的IPv6,并访问外部网络,但无法从外部网络访问应用服务器

    原因不详, 应用服务器为Debian 10

    解决办法:

    更新域名后,同时将应用服务器的网卡down/up一次: ifdown dev / ifup dev

  • NAS DIY: HP ML310e Gen8 V2 + TrueNas v13

    Hardware:

    HP ML310e Gen8 V2

    Update system software with SPP gen8.1

    Update iLO4 to v2.8.1

    CPU:

    E3-1220L V3 @1.10GHz

    RAM:

    32G ECC DDR3 @1.35V / 1066MHz

    System Disk:

    32G T-Flash Card + 32G USB Disk

    Hrad disk drivers

    6 LFF SATA

    Software:

    TruenNAS – Core – 13.0 – U2

    Power Consumption

    28W ( Without hard driver )

    TCO: RMB 1326.8

    HP ML310e Gen8 V2 X1 638

    Samsung 8G 2RX8 PC3-12800E X4 397

    Intel E3-1220L V3 X1 130

    SanDisk 32GB USB3.1 CZ430 X1 35.9

    SanDisk Ultra 64GB Micro SD X1 35.9

    Toolfree MRA190 5.25=>3.5 X2 90

  • Update iLO4 to the latest version

    To have HTML5 console supported in ILO4, we must to update iLO4 to the new version on HP ML310e Gen8 V2

    Go to the HPE support center: support.hpe.com

    Search iLO4

    Select HPE Integrated Lights-Out 4 (iLO 4)

    Select Driver and Software

    Download ilO4 2.81 of Online ROM Flash Component for Windows x64 – HPE Integrated Lights-Out 4 —— cp051874.exe

    Execute the cp051874.exe under windows, extract the firmware bin file, instead of install

    Launch a browser, such as firefox, and login into the iLO4 of ML310e Gen8 V2

    Go to Administration / Firmware, select the download bin file, and updating

  • HP ML310e gen8 V2 system update

    The latest SPP for HP ML310e gen8 V2 is SPP Gen 8.1 (SPPGen81.4.iso)

    iLO4 will be updated to v2.55 by this SPP

  • Deploy draw.io app website on local LAN

    Create a new ESXi host with 2G RAM/ 20G disk, Debian 10

    # Install java JRE

    sudo apt install openjdk-11-jre
    java –version

    # Install apache ant

    wget https://downloads.apache.org/ant/binaries/apache-ant-1.10.12-bin.tar.xz
    tar xvfJ apache-ant-1.10.12-bin.tar.xz
    sudo mv apache-ant-1.10.12/ /usr/local/ant
    sudo bash -c ” cat >>/etc/profile ” << EOF
    ANT_HOME=”/usr/local/ant”
    PATH=”$PATH:/usr/local/ant/bin”
    export ANT_HOME
    export PATH
    EOF
    source /etc/profile
    ant –version

    # Install Tomcat

    sudo apt-get install tomcat9 tomcat9-admin

    http://127.0.0.1:8080/
    http://${SERVER_IP}:8080/
    ls -l /var/lib/tomcat9/webapps/ROOT/

    # Build drawio, war package

    wget https://github.com/jgraph/drawio/archive/refs/tags/v17.1.3.tar.gz
    tar xvfz v17.1.3.tar.gz
    cd drawio-17.1.3
    ( cd etc/build && ant war )

    # Install drwaio

    sudo cp build/draw.war /var/lib/tomcat9/webapps

    http://127.0.0.1:8080/draw
    http://${SERVER_IP}:8080/draw

    # Change draw as the root of tomcat

    cd /var/lib/tomcat9/webapps
    sudo rm -rf ROOT
    sudo mv draw.war ROOT.war

    http://127.0.0.1:8080
    http://${SERVER_IP}:8080

    # Change tomcat to the http default port: 80

    sudo grep 8080 /etc/tomcat9/*
    sudo sed -i “s/8080/80/g” /etc/tomcat9/server.xml

    http://127.0.0.1
    http://${SERVER_IP}