Thinstation + iPxe + http

Ushbu maqola sizga yupqa mijozlar uchun dasturiy ta’minotni kompilyatsiya qilishga yordam beradi. Yupqa mijoz yordamida foydalanuvchilar RDP/Citrix/VMview xizmatlariga va boshqa protokollarga ulanishlari mumkin. Muallif kompilyatsiya uchun CentOS 8, Server nashridan foydalangan.

Thinstation

Thinstation 6.2 — bu yupqa mijoz (USB/HDD/PXE) da ishga tushadigan Linux distributivi. Bu tarmoq yordamchi dasturlaridan tashqari deyarli hamma narsa olib tashlangan soddalashtirilgan Linux. Distributivni ishga tushirish uchun bitta protsessor va 2 GB operativ xotira yetarli. Eski kompyuterlar uchun Thinstation 5.1 yaxshi tanlov bo’lib, atigi 512 MB operativ xotira talab qiladi.

Paketlarni tayyorlash

Centos 8 da chroot oldindan o’rnatilganligi sababli, o’rnatishdan oldin boshqa bog’liqliklar yo’q.

Manba kodini yuklab olish

Thinstation ombori taxminan 1,3 GB hajmga ega, shuning uchun agar sizda internet aloqasi sekin bo’lsa, sabrli bo’ling.

 cd /opt
git clone --depth 1 git://github.com/Thinstation/thinstation.git
cd thinstation 

Konfiguratsiya

Thinstation omborini yuklab olgandan so’ng, biz chroot muhitini yaratishimiz kerak. Bu taxminan 10-15 daqiqa davom etadi.

 ./setup-chroot 

Chroot muhitiga kirgandan so’ng, thinstation tasvirini yaratish uchun zarur bo’lgan konfiguratsiya fayllarini tayyorlashingiz kerak.
Bir nechta yig’ish variantlari mavjud:

 iso syslinux pxe refind grub 

Bizning holatimizda, biz faqat pxe versiyasini kompilyatsiya qilamiz.
Avvalo, xatoliklar yuz berganda asl sozlamalarni tiklashingiz mumkin bo’lgan asl conf faylini yo’qotmaslik uchun build.conf faylidan build.conf.example fayliga havolani olib tashlashingiz kerak.

 cd build
rm -rf build.conf
cp build.conf.example build.conf 

Keling, build.conf faylidagi umumiy parametrlarni ko’rib chiqaylik.

 nano build.conf 

Uskuna moduli kompyuterlar yoki yupqa mijozlar uchun oldindan o’rnatilgan konfiguratsiyalarni tanlash uchun javobgardir. Keyinchalik kerak bo’ladi.

 machine MyMachineName 

Wi-Fi konfiguratsiyasi

Agar qurilmangizda Wi-Fi bo’lsa, wpa_supplicant funksiyasini yoqishingiz kerak

 package wpa_supplicant
 

Fayl tizimini qo’llab-quvvatlash

Funktsiyani yanada kengaytirish uchun biz cifs, nfs va ntfs modullarini qo’shamiz.

 module usb-storage
module isofs                    # ISO9960 file system support for CDRoms
module udf                      # CDRom UDF file system support
module vfat                     # Fat and VFat file system support
module ntfs                    # NTFS file system support
module ext4                     # Ext4 file system support
module nfs                     # NFS file system support
module cifs                    # CIFS support (use either this or smbfs - not both) 

Biz tftpd/http orqali qo’shimcha konfiguratsiya fayllarini yuklash uchun netfiles-ni faollashtiramiz, keyinchalik ulardan foydalanish qulayligi uchun foydalanamiz.

 package netfiles 

Bizning holatimizda biz ish stolini yupqa mijozlarda ishlatmasligimiz sababli, ingliz tilidan tashqari barcha keraksiz lokalizatsiyalarni olib tashlaymiz.

 package locale-en_US  # English-US 

Ilovalar vaqti keldi.
Mening holatimda, menga faqat freerdp kerak, chunki biz faqat RDP orqali serverga ulanishni amalga oshiramiz.

 package freerdp                 # X RDP Client - fork of rdesktop
#package rdesktop               # X RDP client for Windows Terminal Services (ver 1.7)
#package vncviewer              # VNC client (vncviewer)
#package xorg7vnc               # Remote Control Client Workstation
#package ica                    # Citrix ICA client support
#package tarantella             # Tarantella client support
#package xnest                  # XDM in a window client
#package urxvt                  # Light Xterm Client (vt102)
#package xterm                  # Xterm Client (vt220)
#package ssh                    # Secure Shell client
#package tn5250                 # 5250 terminal emulator
#package dillo                  # Dillo light web browser
#package thinlinc               # Cendio ThinLinc client support
#package nx                     # No Machine NX client
#package 2x                     # 2X client
#package spice                  # Redhat Spice Client
#package java                   # Java runtime
#package firefox                # Firefox current Web Browser
#package chrome                 # Google Chrome Web Browser
#package chromium               # Chromium Web Browser
#package kiosk                  # Rkiosk Plugin for Firefox
#package flash                  # Flash Current
#package filezilla              # FileZilla FTP Client for X
#package git                    # GIT Version Control System
#package gparted                # Gnome Partition Manager
#package open-vm-tools
#package vboxguest
#package medit                  # Notepad
#package mplayer                # DVD and video player
#package vmview                    # VMware Open-View Client, PCOIP
#package xbmc                   # XBMC Media Center for X
#package evince                 # X PDF Viewer
#package openkiosk              # OpenKiosk is a cross platform kiosk web browser based on Mozilla Firefox
#package xdmcp-connect          # Simple connection to XDMCP server 

Yupqa mijozga masofaviy kirish uchun www paketini yoqing (bu foydali bo’lishi mumkin)

 package www
package lighttpd
 

Keyingi qadam parollarni o’zgartirish va yuklash rejimini tanlashdir.
Agar fastboot rejimi yoqilgan bo’lsa, yuklangan OS dan alohida fayl yaratiladi va yuklanadi. Taxminan aytganda, bu squashfs ga siqilgan /lib katalogidir.
Aks holda, barcha fayllar initrd tasviriga qo’shiladi.

 param fastboot       true                               # Mangles the filesystem a special way as to improve boot speed and reduce
                                                        # memory utilization. Cool/Dangerous . Harder to dubug other packages. (Finishing Touch)
                                                        # Set to 'true' to enable or 'lotsofmem' for slightly slower booting but no squash lag on app launch.
param tsuser         tsuser                            # Name of the user that thinstation will run as. Needs userauto package.
param tsuserpasswd   pleasechangeme                     # Do Change! Console/telnet password for non-root

param rootpasswd     pleasechangeme                     # Do Change!  Console/telnet password for root
                                                        # If this is enabled, Telnetd will be enabled.
param tsadminpasswd  pleasechangeme                     # Admin password of web interface
param xorgvncpasswd  pleasechangeme                     # VNC Access Password
param storagepasswd  pleasechangeme                     # Password for storage server
param dialuppasswd   pleasechangeme                     # Password for dialin account
param sambapasswd    pleasechangeme                     # Password for samba shares when using user mode security 

Qo’shimcha sozlamalar

 param bootresolution 1920x1080-32

param desktop file:./backgrounds/Hive_Lite.jpg          # Custom image to load as desktop background
param defaultconfig  thinstation.conf.buildtime         # The file with default setup.  No other config file is found
                                                        #  during boot.
param basename       thinstation                        # тут нужно указать имя файла для получения дополнительных файлов настроек 
param basepath       conf                                 # тут нужно указать каталог для получения дополнительных файлов настроек 
param baseurl        'http://${SERVER_IP}'              # Used to determine url to wget/http files - if you wan't to use a web server on the same server as the TFTP server
param sametimestmp   true                               # When enabled, the timestamps for all files and folders will be set to 00:00 of todays date in your timezone
param initrdcmd      "gzip -9"                             # поправим gzip на более сильную компресию
param bootverbosity   3                                 # Increased vebosity when booting TS

param downloads         /downloads
param bootimages        "pxe"                    # сборка только PXE версии
param bootserver        "192.168.1.1"          # Указываем IP адрес сервера TFTPD64 

Barcha modullarni o’rnatadigan qatorlarni izohlang.

 #param allres            true            # Includes a lot of resolution splash images for live-cd s
#param allfirmware       true            # Includes a lot of firmwares for live-cd s
param earlymicrocode    false           # Builds microcode initramfs for early loading 

Mana bizning oxirgi konfiguratsiya faylimiz, unda oyna menejeridan foydalanish qulayligi uchun xfwm4 qo’shdik. Bu nosozliklarni tuzatish uchun foydali bo’lishi mumkin. Keyin, uni o’chirish uchun konfiguratsiya faylidan foydalanamiz.

 <pre class="wp-block-syntaxhighlighter-code">machine MyMachineName
package wpa_supplicant
module usb-storage
module isofs                    # ISO9960 file system support for CDRoms
module udf                      # CDRom UDF file system support
module vfat                     # Fat and VFat file system support
module ntfs                     # NTFS file system support
module ext4                     # Ext4 file system support
module nfs              # NFS file system support
module cifs                     # CIFS support (use either this or smbfs - not both)
package netfiles                        # Adds only this package instead of the whole ts-classic. netfiles lets you get thinstation.conf.xxx files
package udisks
package automount
package autonet
package ntp                     # Utility to obtain date & time from network
package alsa
package gnome-control-center
package volumeicon
package cpufreq
package xorg7-vesa              #A fallback driver that works with almost everything. Does allow resolution changes
package xorg7-vmware
package xorg7-intel             #Intel video driver for most modern chipsets except the GMA3500/3600
package locale-en_US  # English-US
package freerdp         # X RDP Client - fork of rdesktop
package open-vm-tools
package xfwm4
package xfce4-power-manager
package terminal                # Terminal emulator for xfwm4 -- Pulls in xfwm4
package thunar                  # File Manager for xfwm4 -- Pulls in xfwm4
package www                     # Web access to client.  From a browser: "http://<IP number>"
package cups
package samba-client            # Samba smbclient, gives a shell like environment to access an samba server
package gtk-2.0                 # Full gtk-2.0 plus clearlooks theme
package gtk-3.0
package gtk-theme-adwaita
package icons-cursor            # Anti Aliased Mouse Cursor Theme
package icons-hicolor           # Hi-Color icons for some applications and themes. Does not really contain any icons.
package icons-adwaita
package fonts-TTF-BH            # This one works nicely most of the time and is small.
package fonts-TTF-vera
package fonts-TTF-liberation
package fonts-TTF-noto
param fastboot       false                              # Mangles the filesystem a special way as to improve boot speed and reduce
param tsuser         tsuser                            # Name of the user that thinstation will run as. Needs userauto package.
param tsuserpasswd   pleasechangeme                     # Do Change! Console/telnet password for non-root
param rootpasswd     pleasechangeme                     # Do Change!  Console/telnet password for root
param tsadminpasswd  pleasechangeme                     # Admin password of web interface
param xorgvncpasswd  pleasechangeme                     # VNC Access Password
param storagepasswd  pleasechangeme                     # Password for storage server
param dialuppasswd   pleasechangeme                     # Password for dialin account
param sambapasswd    pleasechangeme                     # Password for samba shares when using user mode security
param bootlogo       true                               # Enable or Disable the use of the Boot splash.
param boottheme      default                            # Backgound picture during boot
param splash         silent
param fbmtrr         0                                  # MTRR value for uvesafb (default = 0, 4 is the best) grep your log to make sure you have not set it to high
param fbsm           ywrap                              # Window scrolling method (redraw, ypan, ywrap) ywrap is best, but may not work correctly for all people
param bootresolution 1920x1080-32
param desktop file:./backgrounds/Hive_Lite.jpg          # Custom image to load as desktop background
param defaultconfig  thinstation.conf.buildtime         # The file with default setup.  No other config file is found
param basename       thinstation                        # Used for all config/tftp/scp file names
param basepath       conf                               # Used to determine path to tftp/scp files
param baseurl        'http://${SERVER_IP}'              # Used to determine url to wget/http files - if you wan't to use a web server on the same server as the TFTP server
param haltonerror    false                              # Will halt on error, default is true
param hardlinkfs     true
param sametimestmp   true                               # When enabled, the timestamps for all files and folders will be set to 00:00 of todays date in your timezone
param initrdcmd      "gzip -9"                          # Compression mode and level of initrd file. none, gzip -9, lzma -9 ,bzip2 -9
param bootverbosity   3                                 # Increased vebosity when booting TS
param downloads         /downloads
param bootimages        "pxe"
param bootserver        "192.168.1.1"           # Used for the pxe image config files to specify where to download
param syslinuxtheme     "default"
param grubtheme         "default"
package alltimezone
param allres            false           # Includes a lot of resolution splash images for live-cd s
param allfirmware       false           # Includes a lot of firmwares for live-cd s
param earlymicrocode    false           # Builds microcode initramfs for early loading
param blacklist "snd-pcsp.ko pcspkr.ko"</pre> 

Agar siz hali yupqa mijozlarda qaysi apparat ishlatilishini bilmasangiz yoki u juda katta farq qilsa —
unda mashina konfiguratsiyalarini yaratmasdan va shunchaki barcha modullarni yoqib qo’ymasdan kompilyatsiya qilishga arziydi, bu bosqichni o’tkazib yuboring.

Agar sizda faqat bitta qurilma modeli bo’lsa va/yoki Linux haqidagi bilimingiz sizga qaysi modullar (drayverlar) kerakligini shunchaki belgilashga imkon bermasa, unda quyidagi parametr qo’shilgan holda standart tasvirni kompilyatsiya qilishingiz kerak:

 package extensions-x 

va kompilyatsiyani ishga tushiring

 ./build --allmodules 

Keyin, boot-images/iso katalogidan iso faylini olib, uni flesh-diskka ochishingiz va mijozga yuklashingiz kerak.
Telnet orqali ulanganingizdan so’ng, shaxsiy konfiguratsiya yaratish uchun zarur bo’lgan fayllarni yaratadigan hwlister.sh buyrug’ini ishga tushiring (tftp talab qilinadi).

Endi biz mashinani yaratishga o’tamiz.

 cd machine
mkdir MyMachineName
cd MyMachineName
cp /tftp_server/*.list . 

Keling, Thinstation ishga tushirilgandan so’ng, foydalanuvchi manzilini muhit nuqtai nazaridan sozlaylik. Ushbu sozlamalar thinstation.conf.buildtime faylida amalga oshiriladi.

 cd ../..
nano thinstation.build.conf 

Biz Timzone va TFTP serveridan qo’shimcha konfiguratsiyalarni yuklab olish imkoniyatini, shuningdek, istalgan IP-manzildan masofaviy kirishni o’rnatamiz.

 TIME_ZONE=Asia/Tashkent
NET_REMOTE_ACCESS_FROM=0.0.0.0
NET_FILE_ENABLED=On 

Kompilyatsiya

Endi barcha konfiguratsiyalarimiz tayyor bo’lgandan so’ng, qurishni boshlaylik.

 cd ../../
./build 


Biz hamma narsani ./boot-images/pxe/ katalogidan tftp katalogiga ko’chiramiz

 cp -rf ./boot-images/pxe/* /tftp_server/ 

iPxe

iPxe TFTP HTTP va iSCSI protokollari yordamida tarmoqni yuklash uchun ishlatiladi.
Bizning holatimizda, iPXE yuklash tasviri TFTP orqali uzatiladi, bu esa o’z navbatida initrd va vmlinuz fayllarini HTTP orqali yuklab olishni boshlaydi. Bu yuklab olishni tezlashtiradi, chunki TFTP nisbatan sekin protokol bo’lib, odatda katta fayllar uchun mo’ljallanmagan.

Manba kodini yuklab olish

 cd /opt
git clone git://git.ipxe.org/ipxe.git
cd ipxe 

Keling, iPXE ishga tushirilgandan so’ng darhol yuklanadigan faylni tayyorlaylik.

 nano embed.ipxe
 

Keling, DHCP orqali parametrlarni, jumladan, yuklash tasvirini qabul qilish uchun o’rnatilgan konfiguratsiya yarataylik. Mening holatimda, veb-server root va tftp bir xil katalogga ishora qilmoqda: /tftp_server/

 #!ipxe

dhcp
chain http://192.168.1.1:8080/boot/efi64/boot.ipxe 

Kompilyatsiya

Biz avval yaratilgan iPXE faylimizga yo’lni ko’rsatib kompilyatsiya qilamiz

 cd /opt/ipxe/src/
make bin-x86_64-efi/ipxe.efi EMBED=../embed.ipxe 

./bin-x86_64-efi/ipxe.efi faylini tftp katalogiga ko’chiring

 cp -rf ./bin-x86_64-efi/ipxe.efi /tftp_server/ 

Yugurish

Keling, kataloglarni ishga tushirishga tayyorlaylik

 cd tftp_server/boot 
rm -rf ./efi32
rm -rf ./lpxelinux
rm -rf ./pxelinux
rm -rf ./efi64/*
cp ../../ipxe.efi ./efi64/ 

Keling, rasmimizni IPXE orqali yuklash uchun konfiguratsiya faylini yarataylik.

 nano ./efi64/boot.ipxe 
 #!ipxe

kernel http://192.168.1.1:8080/boot/vmlinuz initrd=initrd
initrd http://192.168.1.1:8080/boot/initrd
boot 

TFTP

Men TFTP serverli routerdan foydalandim. TFTP serverini sozlash uchun bir nechta variantlar mavjud. Yangi boshlovchi administratorlar uchun tinyPXE ni tavsiya qilaman.

Keling, DHCP ga 66 va 67-variantlarni qo’shamiz, ular mijozga TFTP server manzilini va yuklash tasviriga yo’lni aytib beradi:

 option 66 = 192.168.1.1             # Адрес TFTP сервера
option 67 = boot/efi64/ipxe.efi     # путь к файлу загрузки 

Endi barcha asosiy sozlash va konfiguratsiya tugallangandan so’ng, yupqa mijozingizni ishga tushirish va barcha ilovalaringizni sinab ko’rish vaqti keldi.

thinstation.conf tarmoq

Agar yuklab olish muvaffaqiyatli bo’lsa, biz qo’shimcha variantlarga o’tishimiz mumkin. Xususan, RDP serveriga avtomatik ulanishni sozlash.
Buning uchun server ildizida conf katalogini yaratishingiz kerak

 cd /tftp_server/
mkdir conf
cd conf 

Keling, thinstation.conf.network nomli konfiguratsiya faylini yarataylik

 nano thinstation.conf.network 

Keling, faylga server ulanishi va avtomatik ishga tushirish ma’lumotlarini qo’shamiz. freerdp parametrlari haqida ko’proq ma’lumotni bu yerdan o’qishingiz mumkin: https://github.com/FreeRDP/FreeRDP/wiki/CommandLineInterface

 SESSION_0_AUTOSTART=ON
SESSION_0_TYPE=freerdp
SESSION_0_TITLE="RDP"
SESSION_0_FREERDP_SERVER="server-ip-addr"
SESSION_0_FREERDP_OPTIONS="/d:domain.org /bpp:32 /cert-ignore +fonts +aero"
RECONNECT_PROMPT=FORCE 

Faylni saqlang, yupqa mijozni qayta ishga tushiring va voila! Bajarildi.