Hexa's Blog

Personal note: Installing a Beam fullnode

30/03/2025 @ Saigon Cryptocurrency Node

I. Systemctl service /etc/systemd/system/beam.service

[Unit]
Description=Beam Node
Requires=network.target

[Service]
WorkingDirectory=/opt/beam-node-7.5.13882/
ExecStart=/opt/beam-node-7.5.13882/beam-node --config_file=/opt/beam-node-7.5.13882/beam-node.cfg
User=nguyenvinhlinh
RemainAfterExit=yes
Restart=on-failure
RestartSec=10
TimeoutStopSec=180

[Install]
WantedBy=multi-user.target#

II. Firewall-cmd service - /etc/firewalld/services/beam.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Beam</short>
  <description>
    P2P: 10000
  </description>
  <port protocol="tcp" port="10000"/>
  <port protocol="udp" port="10000"/>
</service>

III. Beam node config - /opt/beam-node-7.5.13882/beam-node.cfg

################################################################################
# General options:
################################################################################

# port to start server on
port=10000

# log level [info|debug|verbose]
log_level=debug

# file log level [info|debug|verbose]
file_log_level=debug

# old logs cleanup period (days)
log_cleanup_days=5

################################################################################
# Node options:
################################################################################

# node storage path
storage=/opt/beam-node-7.5.13882/data/node.db
network=mainnet

# nodes to connect to
peer=eu-nodes.mainnet.beam.mw:8100
peer=us-nodes.mainnet.beam.mw:8100

# port to start stratum server on
# stratum_port=0

# path to stratum server api keys file, and tls certificate and private key
# stratum_secrets_path=.

# Enforce re-synchronization (soft reset)
# resync=0

# Owner viewer key
# owner_key=

# Standalone miner key
# miner_key=

# password for keys
# pass

# Fork1 height
# Fork1=

# Path to treasury for testing
# treasury_path=

Lắp ráp hệ thống xịt rửa cho sân vườn.

28/03/2025 @ Saigon Projects

Hey hey hey, chào buổi sáng Việt Nam.

Tôi đã lên kế hoạch lắp ráp hệ thống xịt rửa cho sân thượng được một thời gian rồi. Tuy nhiên, mọi việc cứ trôi đi do bận rộn với dự án quản lý dàn đào tiền mã hóa. Đến hôm nay, 27/3/2025 tôi mới có thể thực hiện được với sự giúp đỡ của hai người em trai.

Cảm nhận đầu tiền sau khi sử dụng là nước hơi hơi yếu, cơ mà dùng một lúc thì nó cũng quen, bây giờ thì tôi thấy khá là ổn, vừa phải. Thực ra vệ sinh sân vườn với cái máy bơm tăng áp này là vừa phải, bên cạnh đó nó cũng góp phần tiết kiệm nước. Tôi thích điều này.

Còn gì thích hơn việc mình làm điều mình yêu, và yêu điều mình làm.

[1] Lắp ráp thử nghiệm
[1] Lắp ráp thử nghiệm

Chi phí cho dự án nhỏ này như sau:

Miêu tả Giá tiền
[1] Bộ bơm tăng áp 560,000
++ Bơm tăng áp 12V Sinleader TH2203 96W  
++ Nguồn 12V  
++ Lọc rác  
++ Vòi xịt rửa xe tăng áp  
++ Ống đây áp lực PU 12mm 6m  
++ Tiền ship bên boba.vn 25,000
[2] Thêm 3m ống dây 36,000
[3] Tủ điện ngoài trời 231,200
++ Tiền ship shopee 20,700
[4] Vít nở 6mm x 10 2,000
[5] Dây điện đôi 0.75mm, 3m dây 24,000
[6] Phích cắm 10,000
[7] Mũi khoan tháp 175,000
Tổng cộng 1,083,900

Để khoan 2 cái lỗ tròn cho dây nước vào và ra, tôi buộc lòng phải mua mũi khoan tháp của shop MR.DIY. Họ bán một bộ 3 mũi khoan tháp là 175,000 VND. Tính ra, mỗi lỗ khoan, có giá trị là hơn 85,000. Đây là những cái lỗ đắt nhất mà tôi từng phải khoan.

Lúc đang chưa có việc làm, mấy thứ tốn tiền hay xảy ra!

Trò đời nó hay thế lắm, nhưng tội cái, tôi lại yêu một cái lỗ hoàn hảo.

[2] 3 mũi khoan tháp với giá 175,000
[2] 3 mũi khoan tháp với giá 175,000

Và còn đây là kết quả, thực sự rất hài lòng.

[3] Thùng điện gắn ngoài trời
[3] Thùng điện gắn ngoài trời
[4] Vòi nước tăng áp này ổn phết. 7/10 điểm
[4] Vòi nước tăng áp này ổn phết. 7/10 điểm

Đặc biệt là cái máy bơm này nó có cảm biến hay sao ý, khi mà tôi khóa nước ở vòi tăng áp, động cơ nó tự động ngắt. Khá là thú vị. Tôi chắc chắn sẽ tìm hiểu cái này.

Lời kết: Cá nhân tôi, tôi nghĩ rằng sẽ tuyệt hơn nếu mà có hệ thống vệ sinh thụ động, ví dụ là hệ thống nước bao xung quanh sân.

Ấn nút là nó xả nước đẩy sân. Tôi chỉ cần gạt nước đi là xong. Kết thúc câu chuyện.

Và, con đường OVER ENGINEER chả bao giờ kết thúc cả.

Cách lưu trữ với tar command

27/03/2025 @ Saigon cheatsheet

Xin chào, khi tôi quyết định viết bài này, tôi buộc lòng phải thừa nhận, tôi không thể nhớ command cũng như các tham số của tar. Bài viết này là dành cho tôi, xem lại sử dụng lệnh tar.

1. Cách tạo lưu trữ (archive) và nén

$ tar -cJvf file_name.tar.xz directory_full_path

Giải thích các tham số:

  • -c: tạo archive‌/lưu trữ
  • -J: nén với định dạng xz, mục đích của nó là giảm dung lượng file lưu trữ. Không có cũng được.
  • -v: verbose, hiện thông tin chi tíết khi chạy lệnh. Không có cũng được.
  • -f: tên file file_name.tar.xz

2. Cách mở lưu trữ (extract)

$ tar -xvf file_name.tar.xz

Giải thích các tham số:

  • -x: extract, mở lưu trữ
  • -v: verbose, hiện thông tin chi tíết khi chạy lệnh. Không có cũng được.
  • -f: tên file file_name.tar.xz

3. References

How to copy files from docker build to host machine?

27/03/2025 @ Saigon etc

This guide is all about copy/extract file from docker build process, then copy it to host machine.

This method is very useful when you have to release/package .rpm file for further usage, but in this post, I will use mkdocs for example, I build mkdocs html files with docker, then copy those html files to host machine.

There are two things to consider:

  • Dockerfile
  • And Build Command for that Dockerfile

I. Dockerfile

The key note is line number 8 and 9

1
2
3
4
5
6
7
8
9
FROM python:3.13.0 AS build

WORKDIR /opt/mining_rig_monitor_document_src
COPY . /opt/mining_rig_monitor_document_src
RUN pip install -r requirements.txt
RUN mkdocs build -c

FROM scratch AS release
COPY --from=build /opt/mining_rig_monitor_document_src/site /

RUN mkdocs build -c will create a directory named site which stores all html files. Then, from scratch image, we copy all thoses html files to /

II. Docker build command

This following command will copy all files from release stage to nginx-dist. The most important is environment variable DOCKER_BUILDKIT=1

$ DOCKER_BUILDKIT=1 docker build -f  Dockerfile --target=release --output nginx-dist .
➜ mining_rig_monitor_document (master) ✗ pwd
/home/nguyenvinhlinh/Projects/mining_rig_monitor_document


➜ mining_rig_monitor_document (master) ✗ tree -L 1
.
├── Dockerfile
├── docs
├── mkdocs.yml
├── nginx-dist      <<-- your files from docker build
├── readme.md
├── requirements.txt
└── wireframe

A new lightning system for K1 Max

26/03/2025 @ Saigon Projects

1. Introduction

I am the owner of a K1 Max 3D printer, the built-in lightning system is not good enought for me. In fact, it’s quite dark.

This project aims at improving the lightning system for K1 Max 3D printer! I designed the lightning frame myself with Plasticity, due to limited size of K1 Max, I have split the whole big model into 8 parts, then print them one by one.

In addition, there are holes to use LED bars with zip ties, no messy with double-size tapes. You gonna be surprise while cleaning a mess of double-size tapes, and I hate it.

[1] 3D design
[1] 3D design
[2] Light's ON/OFF
[2] Light's ON/OFF
[3] Finished Product
[3] Finished Product

2. 3D files

[4] 3D files
[4] 3D files

Main Components

3. Where is the model?

I sell this model on https://cults3d.com/. If you are interest, I also willing to receive in Monero(XMR) instead of USD/VND.

How to create .rpm package for elixir project?

21/03/2025 @ Saigon Elixir

Step 1. Prepare source code tarball

In this step, I would like to use my repo named ASIC Sentry for example

$ git clone https://github.com/nguyenvinhlinh/ASIC-Sentry/ asic-sentry
$ cd asic-sentry
$ git checkout v1.0.0
$ cd ..
$ mv asic-sentry asic-sentry-1.0.0
$ tar -cJvf asic-sentry-1.0.0.tar.xz asic-sentry-1.0.0

For tar command:

  • -c: create a new archive
  • -J: filter the archive through xz
  • -v: verbose
  • -f: use archive file or device ARCHIVE

Now your source code tarball is ready for next step!

Step 2. Setup $HOME/rpmbuild directory

Use this command to create a directory structure for rpmbuild

$ rpmdev-setuptree

$ tree $HOME/rpmbuild
/home/nguyenvinhlinh/rpmbuild
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS

Step 3. Copy source code tarball to SOURCES.

$ tree $HOME/rpmbuild
/home/nguyenvinhlinh/rpmbuild
├── BUILD
├── BUILDROOT
├── readme.md
├── RPMS
├── SOURCES
│   └── asic-sentry-1.0.0.tar.xz <----- your tarball here!
├── SPECS
│   ├── asic-sentry-1.0.0.spec
└── SRPMS

Step 3. Create new SPECS/.spec file

Ignore this step if you modify existing one!

$ cd SPECS;
$ rpmdev-newspec;

Update:

  • Version
  • Release
  • Source0

This is an example of mine asic-sentry-1.0.0.spec

Name: asic-sentry
Version: 1.0.0
Release:        1%{?dist}
Summary: ASIC Sentry is a monitoring software designed to collect and send operational logs from ASIC Miners to a Mining Rig Monitor

License: GNU General Public License v3.0
URL: https://github.com/nguyenvinhlinh/ASIC-Sentry
Source0: asic-sentry-1.0.0.tar.xz

%description
ASIC Sentry is a monitoring software designed to collect and send operational logs from ASIC Miners to a Mining Rig Monitor

%global debug_package %{nil}

%prep
%autosetup

%build
cd assets;
npm install;
cd ..;
mix deps.get --only prod
MIX_ENV=prod mix compile
MIX_ENV=prod mix assets.deploy
MIX_ENV=prod mix release


%install
mkdir -p %{buildroot}/opt/asic_sentry
cp -r _build/prod/rel/asic_sentry/* %{buildroot}/opt/asic_sentry


%files
...
... A long list of installed files.
...

%changelog
* Tue Feb 04 2025 Nguyen Vinh Linh <nguyenvinhlinh93@gmail.com>
- Support KS5L asic

Step 3. Run rpmbuild

$ cd SPECS;
$ rpmbuild -bb asic-sentry-1.0.0.spec

Gonna see error:

ERROR   0002: file '/opt/asic_sentry/lib/crypto-5.5/priv/lib/crypto.so' contains an invalid runpath '/usr/local/lib64'

crypto is an erlang module. I dont know how to modify it. this is a work around!

$ cd SPECS;
$ export QA_RPATHS=$(( 0x0001|0x0002 ))
$ rpmbuild -bb asic-sentry-1.0.0.spec

Step 4. Provide %files

Those file would be listed after running rpmbuild -bb asic-sentry-1.0.0.spec.

Append it and re-run rpmbuild -bb asic-sentry-1.0.0.spec to make rpm.

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /opt/asic_sentry/bin/migrate
   /opt/asic_sentry/bin/migrate.bat
   /opt/asic_sentry/bin/asic_sentry
   /opt/asic_sentry/bin/asic_sentry.bat
   /opt/asic_sentry/bin/server

Check out RPMS directory! RPM should be there!

➜ rpmbuild (master) ✗ tree -L 3
.
├── BUILD
├── BUILDROOT
├── readme.md
├── RPMS
│   └── x86_64
│       ├── asic-sentry-1.0.0-1.fc40.x86_64.rpm <----------- your file here!
│       ├── asic-sentry-debuginfo-1.0.0-1.fc40.x86_64.rpm
│       └── asic-sentry-debugsource-1.0.0-1.fc40.x86_64.rpm
├── SOURCES
│   └── asic-sentry-1.0.0.tar.xz
├── SPECS
│   ├── asic-sentry-1.0.0.spec
└── SRPMS

References

How to install open-webui for llama model on Fedora?

31/12/2024 @ Saigon LLM

This guide is about installing open-webui on fedora.

1. Update python & pip

$ dnf update python -y
$ pip install --upgrade pip

2. Install open-webui guide

  • Create directory /opt/open-webui
$ mkdir /opt/open-webui
$ cd /opt/open-webui
  • change ownership to your user, do not run with root due to security issue.
$ chown nguyenvinhlinh:nguyenvinhlinh -Rv /opt/open-webui/
  • Setup virtual environment (venv) & install open-webui (do not run as root)
$ python -m venv open-webui-env
$ source open-webui-env/bin/activate
$ pip install open-webui

3. Start open-webui server (do not run as root)

$ open-webui serve
  • Server should be available on http://127.0.0.1:8080
  • All data (sqlite, uploads, cache, db) can be found at /opt/open-webui/open-webui-env/lib/python3.12/site-packages/open_webui/data
open-webui on Chrome
open-webui on Chrome

4. Install Ollama software guide

$ curl -fsSL https://ollama.com/install.sh | sh
$ ollama --version

5. Using ollama to pull/download model

$ ollama pull llama3.2

6. Running with systemd service /etc/systemd/system/open-webui.service

[Unit]
Description=Open WebUI (LLAMA)
After=network.target

[Service]
WorkingDirectory=/opt/open-webui
ExecStart=/opt/open-webui/open-webui-env/bin/open-webui serve
User=nguyenvinhlinh
RemainAfterExit=yes
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start open-webui service

$ systemctl enable open-webui
$ systemctl start  open-webui

References

MessBox, my new plastic product

05/12/2024 @ Saigon 3D PrintProjects

I am having a mess table with full of wires. This product is all about to help me clean it up abit.

Btw, if you wonder what is my board. it’s KVM switch. it helps me switch my combo of keyboard+mouse+display with a click!

This is my before image.

[1] Before installation
[1] Before installation
[2] Inside the box
[2] Inside the box
[3] After installation
[3] After installation

There are two type of box

Type Width height
A 2 cm 1 cm
B 2.5 cm 1.5 cm
[4] Type A
[4] Type A
[5] Type B
[5] Type B

Installing Woodpecker natively on Fedora 41

02/12/2024 @ Saigon Linux

Keynotes:

1. Download and install

You can use curl or wget to download from woodpecker releases. Then use

$ rpm install file.rpm

2. Systemd - /etc/systemd/system/woodpecker-server.service

[Unit]
Description=Woodpecker Server
After=network.target

[Service]
WorkingDirectory=/opt/woodpecker-server
EnvironmentFile=/opt/woodpecker-server/woodpecker-server.conf
ExecStart=woodpecker-server
User=root
RemainAfterExit=yes
Restart=on-failure
RestartSec=10
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

3. Config - /opt/woodpecker-server/woodpecker-server.conf

I config to use Gitlab Login - Single Sign On. Plese check this link for more detail.

Github SSO use three variables:

  • WOODPECKER_GITHUB
  • WOODPECKER_GITHUB_CLIENT
  • WOODPECKER_GITHUB_SECRET
WOODPECKER_HOST=https://woodpecker.homelab
WOODPECKER_GITHUB=true
WOODPECKER_GITHUB_CLIENT=XXX
WOODPECKER_GITHUB_SECRET=XXX
WOODPECKER_OPEN=false

WOODPECKER_SERVER_CERT=/opt/woodpecker-server/ssl/woodpecker.homelab.bundle.crt
WOODPECKER_SERVER_KEY=/opt/woodpecker-server/ssl/woodpecker.homelab.key
WOODPECKER_DATABASE_DRIVER=sqlite3
WOODPECKER_DATABASE_DATASOURCE=/opt/woodpecker-server/db/woodpecker.sqlite

4. Firewall-cmd service - /etc/firewalld/services/woodpecker-server.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Woodpecker Server</short>
  <description>This option allows woodpecker to use tcp port 443 HTTPS</description>
  <port protocol="tcp" port="443"/>
</service>

5. Test script before using systemd

Write this script and execute it.

$ export WOODPECKER_HOST=https://woodpecker.homelab

$ export WOODPECKER_GITHUB=true
$ export WOODPECKER_GITHUB_CLIENT=XXX
$ export WOODPECKER_GITHUB_SECRET=XXX

$ export WOODPECKER_OPEN=true

$ export WOODPECKER_SERVER_CERT=/opt/woodpecker/ssl/woodpecker.homelab.bundle.crt
$ export WOODPECKER_SERVER_KEY=/opt/woodpecker/ssl/woodpecker.homelab.key

$ export WOODPECKER_DATABASE_DRIVER=sqlite3
$ export WOODPECKER_DATABASE_DATASOURCE=/opt/woodpecker/db/woodpecker.sqlite
$ export WOODPECKER_LOG_LEVEL=debug

$ woodpecker-server

For ssl certificate generator, follow this guide Cách làm Certificate Authority cấp SSL nội bộ.

6. References

SELinux, cannot login to shell after enable it

30/11/2024 @ Saigon Linux

After along time disable SELinux, now you might want to enable it in Enforcing mode. After OS boot, in terminal, you may not login even though you did enter correct username/password. It’s because your files not to be labeled or labeled with SELinux context not matching the install policy.

The solution is that you ask SELinux to re-label in the next reboot. Enter the following command.

$ touch /.autorelabel

Then reboot!

In case you forget to do it. you need to go to rescue mode while booting the system, the GRUB2 menu will be displayed. To boot the system into rescue mode using bash follow these steps:

  • Select the boot entry you wish to edit with the arrow keys.
  • Select the entry you wish to edit by pressing e.
  • Use the arrow keys to go to select the line beginning with linux, linux16, or linuxefi.
  • Go the the end of that line and include a space and the following rw init=/bin/bash. If your disk is encrypted, you may need to add plymouth.enable=0
  • Press Ctrl-x or F10 to boot the entry
  • Then enter command line touch /.autorelabel and reboot!

Good luck!

Refereces: