Hexa's Blog

How to configure KeyCloak to support Redash SAML SSO?

27/07/2023 @ Saigon Redash

I. KeyCloak Configuration

Step 1: Create a new realm

First of all, let start with definition of reaml, it’s what I got from KeyCloak official website.

Realms A realm manages a set of users, credentials, roles, and groups. A user belongs to and logs into a realm. Realms are isolated from one another and can only manage and authenticate the users that they control.

Realms (Tiếng Việt): cõi, địa hạt, vương quốc, vùng Một realm quản lý một tập hợp user, thông tin xác thực - credential, role và group. Một user sẽ thuộc một realm, một realm sẽ có nhiều user, user sẽ đăng nhập vào reaml mà nó thuộc về. Một server KeyCloak tạo được rất nhiều realm, và chúng bị cô lập với nhau. Những realm này chỉ có thể quản lý và cho đăng nhập những user mà chúng quản lý.

As the definition of realm , this step is only used for testing only, normaly, if your KeyCloak did create a realm, you can skip this step and go to step 2.

[1] Add a new realm.
[1] Add a new realm.

Step 2: Create new reaml’s client & configure it

[2] Create realm's client
[2] Create realm's client

In new client form, I would like to input the following parameters, then submit.

  • Client ID: redash
  • Client Protocol: saml
  • Client SAML Endpoint: ignored this field.

After that, edit that new client named redash

[3] Edit Redash client
[3] Edit Redash client

Client ID: redash

  • Name: Redash
  • Description: empty
  • Enabled: on
  • Always Display in Console: off
  • Consent Required: off
  • Login Theme: keycloak
  • Client Protocol: saml
  • Include AuthnStatement: on
  • Include OneTimeUse Condition: off
  • Force Artifact Binding: off
  • Sign Documents: off
  • Sign Assertions: on
  • Signature Algorithm: RSA_SHA256
  • SAML Signature Key Name: KEY_ID
  • Canonicalization Method: EXCLUSIVE_WITH_COMMENTS
  • Encrypt Assertions: off
  • Client Signature Required: off
  • Force POST Binding: off
  • Front Channel Logout: off
  • Force Name ID Format: off
  • Allow ECP Flow: off
  • Name ID Format: email
  • Root URL: ignored
  • Valid Redirect URIs: https://redash.local-domain.com/*
  • Base URL: https://redash.local-domain.com/
  • Master SAML Processing URL: https://redash.local-domain.com/saml/callback?org_slug=default
  • IDP Initiated SSO URL Name: ignored
  • Logo URL: ignored
  • Policy URL: ignored
  • Terms of service URL: ignored
  • IDP Initiated SSO Relay State: ignored
[4] Client settings
[4] Client settings

Step 3: Configure client’s mappers

In the saml response that Redash expected to received, it requires

  • First Name (original), this attibute name is FirstName
  • Last Name (original), this attribute name is LastName

However, in the KeyCloak, the attribute names are different from what Redash expected, as a consequence, we need to configure client’s mappers For first name and last name, use Add Builtin feature.

[5] First name and last name mappers
[5] First name and last name mappers
[6] First name and last name mapper detail
[6] First name and last name mapper detail
  • X500 Surname
    • Property: lastName
    • Friendly Name: LastName
    • SAML Attribute Name: LastName
  • X500 GivenName
    • Property: firstName
    • Friendly Name: FirstName
    • SAML Attribute Name: FirstName

II. Redash SAML Configuration

After login using admin credential, go to Settings → General → Saml

  • SAML Enabled: Enable (Dynamic)
  • SAML Metadata URL: https://keyclock.local-domain.com/apps/keycloak/realms/{REALM_NAME}/protocol/saml/descriptor
  • SAML Entity ID: redash
  • SAML NameID Format: urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
[7] Redash’s SAML configuration
[7] Redash’s SAML configuration

You are done! Enjoy!

III Reference

Talend, How to export log in JSON Format?

21/06/2023 @ Saigon Talend

Step 1: Go to File → Project Properties

[1] File → Project Properties
[1] File → Project Properties

Step 2: Go to log4j section and Activate log4j in components (Log4j version: log4j2)

[2] Activate log4j in components
[2] Activate log4j in components

In the Log4j template, use the following template.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration >
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout  >
        <pattern>
          { "timestamp":"%d{ISO8601}{GMT+0}", "level":"%level", "category":"%c", "message":"%enc{%m}{JSON}" }%n
        </pattern>
      </PatternLayout>
    </Console>
  </Appenders>

  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="Console" />
    </Root>
  </Loggers>
</Configuration>

Step 3: Create tJava in Talend Job to export log

[3] tJava
[3] tJava
  • Basic settings code:
String message = "Hello World";
log.fatal(message);
log.error(message);
log.warn(message);
log.info(message);
log.debug(message);
log.trace(message);
  • Advanced settings code:
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

You then can RUN your talend job, the output should look like the following.

[4] Basic Run - Console
[4] Basic Run - Console

References

Hướng dẫn cách update firmware cho Ender-3 Pro

20/05/2023 @ Saigon 3D Print

Trong bài hướng dẫn này, chúng ta sẽ tìm cách nâng cấp firmware cho máy in 3D Creality Ender-3 Pro. Trước khi đi vào chi tiết, đây là thông số máy in 3D của tôi trước khi nâng cấp.

  • CPU: ATMEGA1284P
  • Motherboard: Creality3D V1.1.4
  • Version: Melzi 1.1.6.2

Cá nhân tôi khi bắt đầu mò mẫm cài đặt firmware mới, tôi cảm giác mình đang đi vào một cái lỗ thỏ. Đây là những phần việc chính mà chúng ta sẽ làm

  • Cài đặt bootloader cho Creality Ender-3 Pro
  • Cài đặt firmware Marlin cho Creality Ender-3 Pro

Đây là cách các phần cứng nối với nhau.

I. Cài đặt bootloader cho Creality Ender-3 Pro

Ở bước này, tôi sẽ dụng Arduino UNO như một công cụ trung gian để rồi cài đặt bootloader cho máy in 3D.

Để tránh nhầm lẫn, chỉ cắm Arduino UNO vào máy tính, chúng ta chưa kết nối thứ gì vào máy in 3D.

[1] Hardware Links
[1] Hardware Links

Sau khi cắm Arduino UNO vào máy tính, mở phần mềm Arduino IDE, chọn File > Example > 11. ArduinoISP > ArduinoISP.

[2] ArduinoISP
[2] ArduinoISP

Ở mục Tools > Programmer hãy chọn AVRISP mkII . Sau đó, hãy verify và upload sketch này lên Arduino UNO. Lưu ý là vẫn giữ kết nối giữa máy tính và Arduino sau khi upload thành công.

Bây giờ là lúc cắm Arduino UNO vào máy in 3D Creality Ender-3 Pro thông qua cổng ISP. Các linh kiện sẽ kết nối như thế này.

[3] Hardware links
[3] Hardware links

Đây là mạch của máy in 3D.

[4] Creality3D v1.1.4 & ISP jacks
[4] Creality3D v1.1.4 & ISP jacks

Còn đây là mạch Arduino UNO. Khi nối dây, lưu ý là socket số 10 của Arduino sẽ nối vào chân số 3 trên mạch máy in 3D. Các chân còn lại 1, 2, 4, 5, 6 nối như bình thường.

[5] Arduino UNO & ISP jacks
[5] Arduino UNO & ISP jacks

Sau khi kết nối mạch máy in 3D vào Arduino UNO, mặc dù chúng ta không cấp nguồn cho mạch máy in 3D, màn hình vẫn sẽ sáng vì nó lấy điện thông qua Arduino.

Giờ chúng ta quay trở lại với chương trình Arduino IDE để burn bootloader vào mạch máy in 3D thông qua Arduino UNO. Thao tác như sau

  • Tools > Board , chọn Sanguino,
  • Tools > Port, vẫn giữ port cũ, cái mà đang kết nối với Arduino.
  • Tools → Processor, chọn ATmega1284 or ATmega1284P (16MHz)
  • Tools → Programmer, chọn Arduino as ISP (quan trọng)

Sau đó, ấn nút Tools → Burn Bootloader . Lúc này bootloader sẽ được cài vào mạch máy in 3D thông qua Arduino UNO. Màn hình của máy in 3D sẽ có màu xanh, không có chữ gì cả. Đừng lo lắng. Bootloader đã cài đặt thành công rồi. Bây giờ hãy tháo Arduino UNO và cable ISP, vai trò của Arduino UNO đã kết thúc.

II. Cài đặt firmware Marlin cho máy in 3D

Bước đầu tiên, hãy download Marlin Firmware va Marlin Configration ở link dưới đây https://marlinfw.org/meta/download/

[6] Marlin Firmware Downloads
[6] Marlin Firmware Downloads

Từ bây giờ, tôi sẽ gọi thư mục sau khi giải nén MarlinFirmware.zip là thư mục MarlinFirmware, còn thư mục sau khi giải nén MarlinConfiguration.zipMarlinConfiguration.

Trong thư mục MarlinFirmware, sẽ có một thư mục con tên là Marlin hãy copy những file sau từ MarlinConfiguration/config/examples/Creality/Ender-3 Pro/CrealityV1, vào thư mục này:

  • _Bootscreen.h
  • Configuration.h
  • Configuration_adv.h
  • _Statusscreen.h Trong thư mục MarlinFirmware , Edit file platformio.ini , thay đổi default_envs = melzi_optimized Tôi sẽ giả định rằng bạn đã cài đặt xong phần mềm python và platformio. Trong thư mục MarlinFirmware, hãy chạy lệnh sau để compile firmware mới, ở thời điểm tôi viết bài này, phiên bản marlin là 2.0.9.6
$ platformio run

--------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/sanguino_atmega1284p.html
PLATFORM: Atmel AVR (3.4.0) > Sanguino ATmega1284p (16MHz)
HARDWARE: ATMEGA1284P 16MHz, 16KB RAM, 124KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
 - framework-arduino-avr @ 5.1.0
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
Converting Marlin.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- U8glib-HAL @ 0.5.2
|-- SPI @ 1.0
|-- Wire @ 1.0
Building in release mode
Compiling .pio/build/melzi_optimized/src/src/inc/Warnings.cpp.o
Linking .pio/build/melzi_optimized/firmware.elf
Checking size .pio/build/melzi_optimized/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  29.4% (used 4820 bytes from 16384 bytes)
Flash: [==========]  99.6% (used 126450 bytes from 126976 bytes)
======================================================================================

Environment      Status    Duration
---------------  --------  ------------
melzi_optimized  SUCCESS   00:00:07.384

Firmware đã được build xong, nó nằm ở .pio/build/melzi_optimized/firmware.hex

Bây giờ chúng ta sẽ nối máy tính với máy in 3D thông qua cổng mini USB và upload firmware.

platformio run --target upload -v

Tôi sử dụng -v (verbose), nó sẽ hiển thị chính xác command mà platformio sử dụng để upload firmware lên mạch máy in 3D. Command đó nằm ở dòng thứ 6.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload(["upload"], [".pio/build/melzi_optimized/firmware.hex"])
Auto-detected: /dev/ttyUSB0

avrdude -v -p atmega1284p -C /home/nguyenvinhlinh/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P /dev/ttyUSB1 -U flash:w:.pio/build/melzi_optimized/firmware.hex:i

avrdude: Version 6.3, compiled on Sep 12 2016 at 15:21:49
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/nguyenvinhlinh/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/home/nguyenvinhlinh/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600

Khả năng rất cao là chạy lệnh platformio run --target upload -v không thành công, nó chí build xong firmware chứ ko có upload được. Error log như sau:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xdb
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xdb

Lý do bị lỗi này là vì baud rate -b 57600 không chính xác , Để khắc phục lỗi này, bạn chỉnh sửa -b 115200 sau đó chạy lại trên terminal. Command sẽ trông như sau.

avrdude -v -p atmega1284p -C /home/nguyenvinhlinh/.platformio/packages/tool-avrdude/avrdude.conf \
        -c arduino -b 115200 -D -P /dev/ttyUSB1 -U flash:w:.pio/build/melzi_optimized/firmware.hex:i

Đến đây là đã kết thúc quá trình upload firmware mới lên máy in 3D Creality Ender-3 Pro. Trên máy in 3D, nó sẽ yêu cầu bạn initialize lại EPROOM, bạn hãy đồng ý. Nếu không hãy làm như sau Configuration > Advanced Settings > Initialize EPROOM. Sau đó, hãy kiểm tra version About Printer > Printer Info , nó sẽ là 2.0.9.6.

[7] Ender-3 Pro - Marlin 2.0.9.6
[7] Ender-3 Pro - Marlin 2.0.9.6

Talend, Overriding context params when deployment

12/05/2023 @ Saigon Talend

In this tutorial, I would like to introduce a new topic - How to override context params when deploy talend job. In general, there are two method

  • config via file.
  • config by passing parameter in shell script.

Before going further with these two method, I would like to establish a list of context variable and write a small tJava code to print out these context variables.

Variable Name Variable Type Value
var_1 String var_1_original_content
_var_2 String var_2_original_content
var_3 Password password
var_4 int - Integer 1
var_5 float - Float 2.2
var_6 double - Double 3.3
var_7 Date 2023-05-11 00:00:00
[1] Context
[1] Context

Then, I create a new tJava component with the following content.

System.out.println("Hello World!");
String var1 = context.var_1;
String var2 = context._var_2;
String var3 = context.var_3;
Integer var4 = context.var_4;
Float var5 = context.var_5;
Double var6 = context.var_6;
Date var7 = context.var_7;

System.out.println("context.var_1: "  + var1);
System.out.println("context._var_2: " + var2);
System.out.println("context.var_3: "  + var3);
System.out.println("context.var_4: "  + var4);
System.out.println("context.var_5: "  + var5);
System.out.println("context.var_6: "  + var6);
System.out.println("context.var_7: "  + var7);

Now, I build job, choose Override parameter’s value, for quick value defining, I choose Value from selected context, and Finish. A zip file will be generated and it’s ready to execute.

[2] Build Step 1
[2] Build Step 1
[3] Build Step 2
[3] Build Step 2
[4] Build Step 3
[4] Build Step 3

After you extract the zip file, you gonna see file directory tree like this.

[5] Extracted directory
[5] Extracted directory

To execute the job, in my case, you need to run the following command. And, as you can see, our context parameters has been printed well.

$ pwd
C:\Users\Nguyen Vinh Linh\Temporary\etl_01_test_override_context_params_1.0\etl_01_test_override_context_params

$ .\etl_01_test_override_context_params\etl_01_test_override_context_params_run.ps1
Hello World!
context.var_1: var_1_original_content
context._var_2: var_2_original_content
context.var_3: original_password
context.var_4: 1
context.var_5: 2.2
context.var_6: 3.3
context.var_7: Thu May 11 00:00:00 ICT 2023

Now, we are ready to go the main part - Config runtime parameters via file & executable scripts.

I. Config with file.properties

Open Default.properties with your your favorite text editor and edit this file to update context params.

#this is context properties
#Thu May 11 12:51:57 ICT 2023
_var_2=var_2_original_content
var_1=var_1_original_content
var_3=enc\:routine.encryption.key.v1\:yw2kFUbYTflWCDmJafHrHq1+vdJ6QPYjQebpT0pO1NcoDTJc5A++/y67rudl
var_4=1
var_5=2.2
var_6=3.3
var_7=2023-05-11 00\:00\:00

At this step, it’s important to escape special character if you play with datetime type. In my case, it’s var_7.

II. Config with executable scripts (.bat, .ps1, .sh)

This is my content of files

  • etl_01_test_override_context_params_run.ps1
$fileDir = Split-Path -Parent $MyInvocation.MyCommand.Path
cd $fileDir
java '-Dtalend.component.manager.m2.repository=%cd%/../lib' '-Xms256M' '-Xmx1024M' -cp '.;../lib/routines.jar;../lib/log4j-slf4j-impl-2.13.2.jar;../lib/log4j-api-2.13.2.jar;../lib/log4j-core-2.13.2.jar;../lib/jboss-marshalling-2.0.12.Final.jar;../lib/dom4j-2.1.3.jar;../lib/slf4j-api-1.7.29.jar;../lib/crypto-utils-0.31.12.jar;etl_01_test_override_context_params_1_0.jar;' context_params_test.etl_01_test_override_context_params_1_0.etl_01_test_override_context_params --context=Default $args

$args will pass all arguments to running script.

  • etl_01_test_override_context_params_run.sh
#!/bin/sh
cd `dirname $0`
ROOT_PATH=`pwd`
java -Dtalend.component.manager.m2.repository=$ROOT_PATH/../lib -Xms256M -Xmx1024M -cp .:$ROOT_PATH:$ROOT_PATH/../lib/routines.jar:$ROOT_PATH/../lib/log4j-slf4j-impl-2.13.2.jar:$ROOT_PATH/../lib/log4j-api-2.13.2.jar:$ROOT_PATH/../lib/log4j-core-2.13.2.jar:$ROOT_PATH/../lib/jboss-marshalling-2.0.12.Final.jar:$ROOT_PATH/../lib/dom4j-2.1.3.jar:$ROOT_PATH/../lib/slf4j-api-1.7.29.jar:$ROOT_PATH/../lib/crypto-utils-0.31.12.jar:$ROOT_PATH/etl_01_test_override_context_params_1_0.jar: context_params_test.etl_01_test_override_context_params_1_0.etl_01_test_override_context_params --context=Default "$@"

$@ similar to $args but in shell script, it will pass all arguments to running script.

To override context parameters, I just need to add --context_param var_1=var_1_value when execute the script. For example

#Powershell
$ .\etl_01_test_override_context_params\etl_01_test_override_context_params_run.ps1 --context_param var_1=var1 --context_param _var_2=var2 --context_param var_3=new_password --context_param var_7="2023-05-3 23:59:59"

Hello World!
context.var_1: var1
context._var_2: var2
context.var_3: new_password
context.var_4: 1
context.var_5: 2.2
context.var_6: 3.3
context.var_7: Wed May 03 23:59:59 ICT 2023
#Bash
$ .\etl_01_test_override_context_params\etl_01_test_override_context_params_run.sh --context_param var_1=var1 --context_param _var_2=var2 --context_param var_3=new_password --context_param var_7="2023-05-3 23:59:59"

Hello World!
context.var_1: var1
context._var_2: var2
context.var_3: new_password
context.var_4: 1
context.var_5: 2.2
context.var_6: 3.3
context.var_7: Wed May 03 23:59:59 ICT 2023

Good luck!

How to install Talend Open Studio on Fedora 37?

08/05/2023 @ Saigon Talend

Step 1: Install java-11-openjdk

Due to Talend Open Studio prerequisites link, we need to install OpenJDK 11 (recommended distribution: Zulu) or OracleJDK 11. In this tutorial, I used OpenJDK 11 provided by Fedora package repository.

[1] Talend Open Studio prerequisites
[1] Talend Open Studio prerequisites

Package information:

$ sudo dnf info java-11-openjdk

Installed Packages
Name         : java-11-openjdk
Epoch        : 1
Version      : 11.0.18.0.10
Release      : 1.fc37
Architecture : x86_64
Size         : 1.2 M
Source       : java-11-openjdk-11.0.18.0.10-1.fc37.src.rpm
Repository   : @System
From repo    : updates
Summary      : OpenJDK 11 Runtime Environment
URL          : http://openjdk.java.net/
License      : ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and
               GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public
               Domain and W3C and zlib and ISC and FTL and RSA
Description  : The OpenJDK 11 runtime environment.

Package installation:

$ sudo dnf install java-11-openjdk

Step 2: Setup java with alternatives command

In this step, we use command alternatives to set java version systemwide, java-11-openjdk.x86_64 is selected with option 3.

sudo alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/bin/java)
   2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b09-2.fc37.x86_64/jre/bin/java)
 + 3           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.fc37.x86_64/bin/java)

Enter to keep the current selection[+], or type selection number: 3

Step 3: Set JAVA_HOME

I used shell named zsh, I will configure JAVA_HOME in .zshrc file which located in ~/.zshrc. If you use bash, you will need to configure .bashrc. You can trace the java home path using alternatives in Step 2. For me, the value is /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.fc37.x86_64

export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.fc37.x86_64

Step 4: Download, Extract and Execute Talend Open Studio

After download Talend Open Studio TOS_DI-20211109_1610-V8.0.1.zip, and extract, you gonna see a list of file & directory.

$ ls -l
total 280
drwxr-xr-x. 1    136 Aug 26  2014 about_files
drwxr-xr-x. 1    660 May  8 17:00 configuration
drwxr-xr-x. 1   7170 Nov  9  2021 features
-rwxr-xr-x. 1    605 Nov  9  2021 license.txt
-rwxr-xr-x. 1  11840 Nov  9  2021 NOTICE.txt
drwxr-xr-x. 1    112 Nov  9  2021 p2
drwxr-xr-x. 1  59446 Nov  9  2021 plugins
drwxr-xr-x. 1      0 May  8 16:26 temp
-rwxr-xr-x. 1  80160 Jun 11  2021 TOS_DI-linux-gtk-aarch64
-rwxr-xr-x. 1    259 Nov  9  2021 TOS_DI-linux-gtk-aarch64.ini
-rwxr-xr-x. 1  74675 Aug 20  2014 TOS_DI-linux-gtk-x86_64
-rwxr-xr-x. 1    259 Nov  9  2021 TOS_DI-linux-gtk-x86_64.ini
drwxr-xr-x. 1     16 Oct 29  2021 TOS_DI-macosx-cocoa-aarch64.app
drwxr-xr-x. 1     16 Oct 29  2021 TOS_DI-macosx-cocoa.app
-rwxr-xr-x. 1    410 Nov  9  2021 TOS_DI-macosx-cocoa.ini
-rwxr-xr-x. 1  91512 Aug 19  2021 TOS_DI-win-x86_64.exe
-rwxr-xr-x. 1    259 Nov  9  2021 TOS_DI-win-x86_64.ini
drwxr-xr-x. 1     76 May  8 16:27 workspace

You need to execute this file named TOS_DI-linux-gtk-x86_64 and done. Good luck.

[2] Open Talend Open Studio
[2] Open Talend Open Studio

How to fix csgo_linux64 has stopped working

01/05/2023 @ Saigon CSGO

Sometimes, playing CSGO on Fedora (Gnome) gives you this message.

csgo_linux64 has stopped working
csgo_linux64 has stopped working

It’s because GNOME detects csgo_linux64 process unresponsive. You can fix this issue by setting the timeout to 0, by default, it’s 5000 milliseconds.

$ gsettings set org.gnome.mutter check-alive-timeout 0

How to copy files from docker image to host machine?

30/04/2023 @ Saigon Linux

Step 1: Prepare dockerfile

In this post, I would like to take an example building html file for jekyll blog.

from ruby:3.2.0 as build

WORKDIR /opt/nguyenvinhlinh.github.io
COPY . /opt/nguyenvinhlinh.github.io

RUN bundle config set --local deployment true
RUN bundle install
RUN bundle exec jekyll build --destination=/opt/nguyenvinhlinh.github.io/dist

FROM scratch as release
COPY --from=build  /opt/nguyenvinhlinh.github.io/dist /

The build step will make statis file in /opt/nguyenvinhlinh.github.io/dist, then at release stage, it copies all files from that dist directory to /

Step 2: Execute docker build command

$ mkdir -p /var/tmp/nguyenvinhlinh.github.io-dist
$ docker build -f Dockerfile  --target=release --output type=local,dest=/var/tmp/nguyenvinhlinh.github.io-dist .

[+] Building 29.7s (12/12) FINISHED
 => [internal] load .dockerignore                                                                                        0.0s
 => => transferring context: 120B                                                                                        0.0s
 => [internal] load build definition from Dockerfile                                                                     0.0s
 => => transferring dockerfile: 424B                                                                                     0.0s
 => [internal] load metadata for docker.io/library/ruby:3.2.0                                                            1.8s
 => [1/5] FROM docker.io/library/ruby:3.2.0@sha256:98e340a1e5a9a61ee0c30e464a058da093ab8179460ed096a2a763a3abaa6c47      0.0s
 => CACHED [2/5] WORKDIR /opt/nguyenvinhlinh.github.io                                                                   0.0s
 => [internal] load build context                                                                                        0.1s
 => => transferring context: 103.72kB                                                                                    0.0s
 => [build 3/6] COPY . /opt/nguyenvinhlinh.github.io                                                                     0.1s
 => [build 4/6] RUN bundle config set --local deployment true                                                            0.7s
 => [build 5/6] RUN bundle install                                                                                      23.7s
 => [build 6/6] RUN bundle exec jekyll build --destination=/opt/nguyenvinhlinh.github.io/dist                            2.6s
 => [release 1/1] COPY --from=build  /opt/nguyenvinhlinh.github.io/dist /                                                0.2s
 => exporting to client                                                                                                  0.2s
 => => copying files 12.10MB

In this step, the key point here is about to copy all files from stage named release to host directory at /var/tmp/nguyenvinhlinh.github.io-dist.

Good luck, have fun!

References

How to delete journalctl log safely?

29/04/2023 @ Saigon Linux

First of all, it’s important to know how much space has been used for journalctl log. There are many method to get this information, in this post, I would like to introduce two method.

  • Disk Usage (du command), given that logs stored in /var/log/journal. You can use this following command.
$ du --human-readable --summarize /var/log/journal
3.0G	/var/log/journal

$ du -sh /var/log/journal
3.0G	/var/log/journal
  • Using journalctl --disk-usage
$ journalctl --disk-usage
Archived and active journals take up 2.8G in the file system.

Now, come back to our main topic - deleting journalctl log safely.

  • Delete log data by time, in this example, it only keeo 7-day old data.
$ journalctl --vacuum-time=7d
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/f5393db751dc400898dc12ef55768680.
Vacuuming done, freed 0B of archived journals from /var/log/journal.
  • Delete log data by disk usage, in the following example, it only keeps data up 1GB. This command uses G for Gigabyte, M for Megabyte, K for Kilobyte.
$ journalctl --vacuum-size=1G
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/f5393db751dc400898dc12ef55768680.

Sơ đồ điện của mạch điều tốc

28/04/2023 @ Saigon Mining Rig

Sơ đồ điện của mạch điều tốc
Sơ đồ điện của mạch điều tốc

Dynex mining configuration - VGA 3080

08/03/2023 @ Saigon Mining Rig

1. Running bat script - run.bat

a. Dynex Solver 2.2.5

:loop
C:\Users\CHANGE_ME\Desktop\Software\dynexsolve_windows2.2.5\DynexSolveVS.225.exe ^
  -mallob-endpoint https://dnx.sg.ekapool.com ^
  -mining-address WALLET_ADDRESS ^
  -stratum-url POOL_URL -stratum-port POOL_PORT -no-cpu -multi-gpu ^
  -stratum-password WORKER_NAME -adj 1.0898 -sync
goto loop
:exitloop

Example:

:loop
C:\Users\LacLongQuan\Desktop\Software\dynexsolve_windows2.2.5\DynexSolveVS.225.exe ^
  -mallob-endpoint https://dnx.sg.ekapool.com ^
  -mining-address XwnTnXV7cSEQszHqM3xihWZp6MiP6n8vqggLFH15VMEBDnpkBKnv1Cz7wn5L18uVrwMDFhdhB2fV3fSTZ7MexKDJ1ZgGx9ZCC ^
  -stratum-url dnx.sg.ekapool.com -stratum-port 19666 -no-cpu -multi-gpu ^
  -stratum-password LAC-LONG-QUAN -adj 1.0898 -sync
goto loop
:exitloop

b. SRBMiner 2.2.1

SRBMiner-MULTI.exe ^
  --algorithm dynex ^
  --disable-cpu ^
  --gpu-id 0 ^ :: enable/disable gpu
  --mallob-endpoint https://dnx.sg.ekapool.com ^
  --pool dnx.sg.ekapool.com:19666 ^
  --wallet WALLET-ADDRESS
  --password WORKER-NAME

Example:

setx GPU_MAX_HEAP_SIZE 100
setx GPU_MAX_USE_SYNC_OBJECTS 1
setx GPU_SINGLE_ALLOC_PERCENT 100
setx GPU_MAX_ALLOC_PERCENT 100
setx GPU_MAX_SINGLE_ALLOC_PERCENT 100

@echo off
cd %~dp0
cls

SRBMiner-MULTI.exe ^
--algorithm dynex ^
--disable-cpu ^
--gpu-id 0 ^
--mallob-endpoint https://dnx.sg.ekapool.com ^
--pool dnx.sg.ekapool.com:19666 ^
--wallet XwnTnXV7cSEQszHqM3xihWZp6MiP6n8vqggLFH15VMEBDnpkBKnv1Cz7wn5L18uVrwMDFhdhB2fV3fSTZ7MexKDJ1ZgGx9ZCC ^
--password AU-CO
pause

2. Nvidia Overclock script - oc.bat

  • Locked GPU Clock: 1760MHz
  • Locked Memory Clock: 5000MHz
  • Power Limit: 135W
nvidia-smi -lgc 1760
nvidia-smi -lmc 5000
nvidia-smi -pl 135

3. Result

  • Hashrate for a 3080 GPU: 240H/s
  • Power Consumption: 115W
  • Temperature: 46C
  • Dynex chips: 334
Dynex Solver 2.2.5
Dynex Solver 2.2.5