Sunday, January 19, 2025

Remotely connect to Home Assistant hosted behind an ISP NAT

The home assistant instance I use is hosted on a Raspberry Pi 4 and it's connected to internet via an ISP who does not provide public IP addresses for home usage. Therefore it's not straightforward to allow access to the home assistance instance from internet.

Therefore I decided to use reverse SSH tunnel between the home assistant (raspberry pi) and my seedbox which already has an nginx instance running. 

you can gain SSH access to home assistant via Advanced SSH & Web Terminal add-on. 

Below command has been executed on home assistant to create the reverse SSH tunnel with the seedbox,

ssh  -fTNR  18123:localhost:8123 <user in seedbox>@<ip of the seedbox> -p <ssh port of the seedbox> -i <path to SSH private key to connect to seedbox>

-f for ssh background execution
-T to disable pseudo terminal allocation
-N to restrict remote command execution
-R [bind_address:]port:host:hostport. This specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side. Please refer man page of SSH for more details.

Once the SSH command is executed, you should be able to see a server is running in the remote machine, (in this case port 18123 in my seedbox),

netstat -anpt | grep 8123
tcp        0      0 127.0.0.1:18123         0.0.0.0:*               LISTEN      -                   
tcp6       0      0 ::1:18123               :::*                    LISTEN      -  

Please note that the bind address is 127.0.0.1 by default. if you want to change this, you will have to set clientspecified as the value for GatewayPorts configuration in /etc/ssh/sshd_config file of the remote server and then restart sshd service. Instead of configuring that (due to security risk), you can still expose the service running on localhost to internet via nginx.

below snippet added to the default file in /etc/nginx/sites-enabled directory,

location / {
     proxy_pass http://127.0.0.1:18123;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
 }

To avoid SSH tunnel connectivity issues, enable ssh keep alive for the SSH client. I added below 2 lines to ~/.ssh/config file in the home assistant. 

ServerAliveInterval 15
ServerAliveCountMax 3

Sunday, January 12, 2025

How to configure a Tuya compatible smart switch with Home Assistant

Prepare Raspberry Pi 4 with Home Assistant OS 

I used my Raspberry Pi 4 to install Home Assistant. The OS versions mentioned below may not be as yours. 

Use Raspberry Pi Imager to prepare the SD card. Select "Other specific-purpose OS" when you select the operation system and then select "Home assistants and home automation" and then "Home Assistant" and finally select "Home Assistant OS 14.1 (RPI 4/400)"






Log in to home assistant web portal when everything is ready.

Install HACS

Go to settings, click on Add-ons and then click on ADD-ON STORE button located in the right hand corner at the bottom. 



Then click on Repositories from the menu you get clicking on the three dots at top right hand corner.
Enter https://github.com/hacs/addons as the repository 


Then go back to settings, select Add-ons and click on 
ADD-ON STORE button. Then search for hacs. You will see the "Get HACS" repository. 


click on it and hit INSTALL button to get HACS installed. click on Start once the installation is done. 
Then restart Home Assistant. 

Once restarted, go to settings, click on Devices & Services.Click on ADD INTEGRATION button and search for HACS. select HACS and proceed with the instructions provided. once the github authorization is completed, HACS will be appeared in the Integrations list.



Open HACS by clicking on HACS in the left hand side menu. Since the default Local Tuya available with HACS was not working with protocol 3.5, I had to use a forked version of the original Local Tuya repository. Click on the 3 dots at top right hand side and select Custom Repositories.
 


Enter 
https://github.com/xZetsubou/localtuya as Repository and Integration as Type. Once that is added, the forked version of Local Tuya will be appeared in HACS. 


Install Tuya Local

Click on the three dots of the new Local Tuya appeared and hit Download.


Restart Home Assistant to complete the installation.

Configure Tuya Local

Go to Settings, select Devices & Services. Click on ADD INTEGRATION button and select Local Tuya. I didn't enter any details for Cloud API account configuration as I selected Disable Cloud API.
Now Local Tuya is appeared in the Integrations. 


 Click on Local Tuya and click Configure. Select Add new device. As it does not automatically detect the device, go ahead with Add Device Manually option. 

Notes: You need several information to proceed from here. However make sure you have configured your devices in your mobile app, either Smart Life or Tuya Smart.

1. Device ID

You can find out the Device ID from the application installed in your mobile (Smart Life or Tuya Smart).  Open the App, Select the device, click on the pencil icon at the top right hand corner and click on Device Information to find out the device ID. 


2. Local Key. 

You can find out the Local Key from https://auth.tuya.com/. Create an account there if you don't have a login already. 
Log in to Tuya account.  Click on Cloud and click on Create Cloud Project.



Make sure you select the correct Data Center. Otherwise it won't work. This document has the data center mapping. Select the data center based on the country you selected when you configured the mobile App. 
https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb

In my case, it's Central Europe data center.


Then proceed with the default options provided.
Once the project is set up, go to Cloud again and Open the project. Select Devices and then Link App Account. Then click on Add App Account. A QR code will appear. 


Open your mobile App and scan it and confirm Login. Now the device(s) will be added to the project.



Open API Explorer from Cloud.

Expand Device Management and select Query Device Details. Enter the Device you found out in the step 1 and hit Submit Request button. 



It will provide a JSON response. You should be able to find the value for local_key in the JSON.

Now you have the Device ID and Local Key to proceed. Make sure to add a scan interval, otherwise the information will not get updated in Home Assistant portal. 



Once Submit, another window will appear. Select Configure device entities manually. Choose entity as Switch and proceed. To proceed further you need to know about DP IDs. You can find out the DP IDs from https://auth.tuya.com portal. 

Make sure you select Smart Home Basic Service and expand Smart Home Device Control section. Select Get Device Specification Attribute. Then enter your device ID and hit Submit Request button. 
A JSON response will appear with the DP ID mapping. This will be useful when the device is added to Home Assistant. 


I configured below values for the smart plug,



The device will be appeared in Local Tuya now,





Prepare a Dashboard

To plot the current, power utilization and voltage, I have added those attributes as entities. 
Go to Local Tuya, select Configure and select Reconfigure existing device.


Select Add new entity(s)


Select Sensor for the entity. Repeat the same for Power and Voltage. 









Saturday, February 15, 2020

High CPU utilization just after display sleep in Hackintosh

I noticed that after a few seconds the monitors went sleep, the CPU utilization and iGPU utilization of my hackintosh went significantly high. This was clearly noticed in the Intel Power Gadget as well,




I kept a terminal session open redirecting the output of top command in terminal (top -o cpu > bla.txt). From the output I was able to find out that mediaanalysisd process was utilizing the CPU and iGPU.

After unloading mediaanalysisd, the issue went away.

Uload command I used,
launchctl unload -w /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist

Monday, February 10, 2020

Restore Google Chrome and Firefox Bookmarks from a backup

I had an issue with my Hackintosh, so that it wouldn't boot anymore. However I was able to mount the disk of the machine to another newly built Hackintosh which helped me to access the files of the troubled Hackintosh.

First I plugged the disk to the new Hackintosh

For Google Chrome,


1. Navigate to below location of the disk,

/Volumes/<volume name> - Data/Users/<username>/Library/Application Support/Google/Chrome/Default

2. There should be two Bookmark files in the directory:'Bookmarks' and 'Bookmarks.bak'

3. Check the latest by executing diff command

4. Copy the latest to below location of your new machine

/Users/<username>/Library/Application Support/Google/Chrome/Default


For Firefox,


1. Navigate to below location of the disk,

/Volumes/<volume name> - Data/Users/<username>/Library/Application Support/Firefox/Profiles/wzghbr3j.default/bookmarkbackups


2. There should be multiple files in the directory.
e.g.:

bookmarks-2020-02-08_744_<some-encoded-values>.jsonlz4
bookmarks-2020-02-09_744_<some-encoded-values>.jsonlz4


3. Pick the latest file and copy it to the desktop


4. Open Firefox, Select Bookmark and then Show All BookMarks


5. Click on Restore and then select choose file


6. Select the file from the Desktop

How to disable parsec-fbf which prevents Catalina Sleep functionality

1. Execute below command to find out which processes block sleep,

pmset -g assertions

2. Execute below command to disable parsec-fbf

launchctl unload -w /System/Library/LaunchAgents/com.apple.parsec-fbf.plist

Tuesday, December 25, 2018

ext4 ext4lazyinit

Today I formatted a 3TB hard disk and mounted it with default options. However after mounting it I noticed that it periodically writes about 2 MB data. Initially I thought it was some journal information writing for the files I copied to the disk, but this 2MB data writing was not stopped when I mounted the disk after removing the journal.

Therefore I installed iotop to see what's going on. Aha, I was able to find the culprit immediately.
It was a process called ext4lazyinit.

Apparently when a partition is formatted with ext4, it does not initialize all inode tables in the file system during the file system creation time in order to speed up the process.  When the new file system is mounted, it starts ext4lazyinit process to initialize the inode tables leisurely.
Needless to say, it's really annoying to hear the sound of the disk is being accessed in every second indefinitely.

After searching about this ext4lazyinit process, I found out that all the inode tables can be initialized  passing lazy_itable_init=0 with the -E option when the  filesystem is created. Since I have already copied some files to the disk, I didn't want to reformat it. Therefore I followed another mechanism described in the articles I read. That is mount the partition with init_itable=0 mount option. This will speed up the inode table initialization. (https://www.kernel.org/doc/Documentation/filesystems/ext4.txt)


Saturday, December 1, 2018

How to install youtube-dl on Mac OS

  • Install youtube-dl,

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl


  • Install ffmpeg which is useful to merge media streams,

    • Download the static snapshot from https://evermeet.cx/ffmpeg/
    • copy ffmpeg binary to /usr/local/bin,
      • sudo cp ffmpeg /usr/local/bin/

Sunday, November 25, 2018

How to configure wireless network interface using CLI in Fedora Server

I wanted to use my wireless network adapter on Fedora Server (version 29). Even though there are ways configure it graphically on Fedora Server, I wanted to configure it using only CLI with minimum steps.

When I plugged the adapter to my server, it was shown as wlp0s21f0u4,

ip a command output,

wlp0s21f0u4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000

Therefore I chose wlp0s21f0u4 as my connection name.

Here are the steps I followed,

1. Create a network configuration file in /etc/sysconfig/network-scripts directory. File name: ifcfg-wlp0s21f0u4 (i.e. ifcfg-<connection name>)


Content of the file is,

[root@localhost network-scripts]# cat ifcfg-wlp0s21f0u4
TYPE=Wireless
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
NAME=wlp0s21f0u4
ONBOOT=yes
DEVICE=wlp0s21f0u4
ESSID=bla
KEY_MGMT=WPA-PSK
MODE=Managed

The highlighted configuration parameters are important to establish a wireless connection. As you can see the SSID of my wifi network is bla and it uses WPA-PSK security.

2. Create another file to store the wireless key in the same directory. File name: keys-wlp0s21f0u4 (i.e. keys-<connection name>)


Content of the key file is,

[root@localhost network-scripts]# cat keys-wlp0s21f0u4
WPA_PSK=abc123

 As you can see the password is abc123 and it's stored as plain text.

3. Restart NetworkManager,


systemctl restart NetworkManager

4. After a couple of seconds, the network interface should be up,


ip a command output,

wlp0s21f0u4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

If you encounter issues, you can use journatctl for troubleshooting,

journalctl -xe -u NetworkManager

Create a keyboard shortcut for Menu action in Mac OS X

While I was using my Hackintosh, I noticed that some menu items do not have keyboard shortcuts defined. Some menu items have keyboard shortcuts, but need special keys.
As an example, If you want to select Sleep menu item, there is a special key combination where one of the required keys "Eject" is not available in typical keyboards. However if you have Mac OS compatible keyboard, this will not be an issue.

There are multiple ways to overcome this. The easiest way I found was adding a new keyboard shortcut using system preferences. No additional software or scripting required.

These are the steps I followed to create a shortcut to Sleep menu action,


1. System Preferences -> Keyboard ->  Shortcuts
2. Select "App Shortcuts" from the left pane
3. Click on + (plus) sign
4. Select "All Applications" for "Application" option
5. Type "Sleep" for "Menu Title" Option
6.  Use your preferred key combination for "Keyboard Shortcut" option. I used Command + F12
7. Click on Add button

Adding a custom keyboard shortcut for Sleep menu action


That's it. Command + F12 will be shown as the keyboard shortcut for Sleep in the menu now,

Command + F12 keyboard shortcut assigned for Sleep menu action

Tuesday, November 20, 2018

Firewalld rules required to open nfs services

Fedora server edition comes with nfs server installed. However we need to add several rules for firewalld to access nfs service.

firewall-cmd --add-service=rpc-bind
firewall-cmd --add-service=mountd
firewall-cmd --add-port=2049/tcp
firewall-cmd --add-port=2049/udp


Use --permanent option and then --reload option to make the rules persistent and effective. 

Change a network interface to remove it from being the default gateway in Fedora

Sometimes it's required to change a network interface to avoid it from being the default gateway. This can be easily achieved by changing the network interface configuration file.

The only change required is to change the value of DEFROUTE of the configuration file to no

e.g.:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp3s0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp3s0
UUID=e73d611-501-33ac-9fd-4946bcfdf8
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
DEVICE=enp3s0

Permanently disable ipv6 on Fedora

There are several ways to disable ipv6 on Fedora. e.g.: changing sysctl, changing the network configuration file.

However if it's required to disable ipv6 system wide in a reliable way, I prefer to disable it using the kernel parameter method.

I'm using Fedora 29 server edition on an UEFI system.

1.  Add ipv6.disable=1 to GRUB_CMDLINE_LINUX parameter listed in /etc/default/grub file,

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=UUID=aee6d21-c4a6-437-a7c6-d80c98ab9 rhgb quiet ipv6.disable=1"
GRUB_DISABLE_RECOVERY="true"


2. Take a backup of the grub configuration file.

cp /boot/efi/EFI/fedora/grub.cfg /boot/efi/EFI/fedora/grub.cf.bk

3. Generate the grub configuration file,

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg 

4. Reboot

Update 1: It looks like this method breaks firewalld on fedora 29, Therefore I had to revert the changes.

[root@localhost ~]# systemctl status firewalld -l
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-20 11:11:07 +0530; 5min ago
     Docs: man:firewalld(1)
 Main PID: 1874 (firewalld)
    Tasks: 2 (limit: 4915)
   Memory: 22.8M
   CGroup: /system.slice/firewalld.service
           └─1874 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid

Nov 20 11:11:06 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 20 11:11:07 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 20 11:11:07 localhost.localdomain firewalld[1874]: WARNING: ip6tables not usable, disabling IPv6 firewall.
Nov 20 11:11:07 localhost.localdomain firewalld[1874]: ERROR: UNKNOWN_ERROR: 'ip6tables' backend does not exist
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: COMMAND_FAILED: UNKNOWN_ERROR: 'ip6tables' backend does not exist
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.0 (legacy): goto 'PRE_FedoraServer' is not a chain
                                                      
                                                       Error occurred at line: 2
                                                       Try `iptables-restore -h' or 'iptables-restore --help' for more information.
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: COMMAND_FAILED: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.0 (legacy): goto 'PRE_FedoraServer' is not a chain
                                                      
                                                       Error occurred at line: 2
                                                       Try `iptables-restore -h' or 'iptables-restore --help' for more information.




Install and Configure hd-idle on Fedora

hd-idle is a useful program if you want to spin down hard disks after a defined time period.
It is available in fedora repositories. Therefore you can install it using dnf command,

dnf install hd-idle

systemd unit file is available in below path,

/usr/lib/systemd/system/hd-idle.service

The configuration file is available in below path,

/etc/sysconfig/hd-idle

man page of hd-idle (man hd-idle) describes the usage of hd-idle program. It has capability to define a default idle time for all the disks and define idle time for disks individually.

The default log file path is,

/var/log/hd-idle/hd-idle.log

All the informatiion about this utility can be found here,

http://hd-idle.sourceforge.net/

How to add and remove default gateway on Mac OS

Command to delete the default route,

sudo route delete default

Command to add a default route,

sudo route add default <default gateway IP>

How to turn off IPV6 of an interface on MacOS

Command to list the network services,

networksetup -listallnetworkservices

output of the command,

anons-iMac:~ anon$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet
iPhone USB


Command to turn IPV6 off for a particular network service (in this case Ethernet and iPhone USB are the network services I want to modify),

networksetup -setv6off Ethernet
networksetup -setv6off 'iPhone USB'

Sunday, November 4, 2018

Configure Google Chrome to stop opening 5353 port for listening

Today I have noticed that Google Chrome opens a UDP listening port 5353 whenever I open the browser.
After searching about it, I found this solution shuts down the port,

Create a file under /etc/opt/chrome/policies/managed directory

e.g.:  blockport.json

Add this line to the file,
{ "EnableMediaRouter": false }

Finally it will look like this,
[root@localhost ~]# cat /etc/opt/chrome/policies/managed/blockport.json
{ "EnableMediaRouter": false }



Restart the browser. It will not open the port anymore.

Source: https://unix.stackexchange.com/questions/187294/chromium-browser-pepperflashplugin-opening-listening-ports-on-0-0-0-05353


Update,
For latest Google Chrome instances, Above method didn't work and I have found out that disabling "Show notifications when new printers are detected on the network" shutdown port 5353. Please note that I'm using Version 81.0.4044.129 (Official Build) (64-bit) on MacOS

Tuesday, August 14, 2018

Avoid WebRTC leak if you use browser + VPN or SSH Tunnel

I have been using a SSH tunnel (Please see this post for the instructions, http://swapoff.blogspot.com/2018/03/how-to-create-ssh-tunnel-and-use-it-for.html) for web browsing via Firefox.

I used it to forward DNS queries well. So I thought I'm pretty much safe until I read about WebRTC feature in web browsers.

WebRTC allows P2P communication for real time communication in web browsers.  WebRTC can be used to get your true IP address via STUN requests with browsers, even when you are using a VPN or SSH tunnel.

You can check whether WebRTC is enabled using several methods, but checking it via a web application is easier than any other methods. e.g.: https://browserleaks.com/webrtc

To disable WebRTC in firefox, set media.peerconnection.enabled to false via about:config

Saturday, July 14, 2018

Fix some errors appeared in rtorrent

After a fresh installation and configuration of rtorrent and rutorrent, below errors were appeared.

  • unpack plugin: rtorrent user can't access 'unrar' program.
  • rTorrent user can't access external program (sox)

To fix those, I had to install the missing programs,

In Ubuntu,

apt-get install unrar-free
apt-get install sox


Tuesday, July 10, 2018

Create your own OVH Server availability checker

Recently I came to know that OVH has a line of storage specific "So You Start"  (SyS) ARM based servers. I have been using a Kimsufi server, but some of these SyS servers are cheaper than the Kimsufi server I have been using. Also the storage available in SyS servers is larger than what I get from the Kimsufi Server for a slightly higher price. Therefore I decided to try a SyS ARM server (ARM-2T/1801armada01)

Unfortunately SyS ARM servers are not always available to order, specially the cheapest servers. I was refreshing their page regularly to order a server, but soon I understood that's not practical. I didn't see they become available in the web page even though I tried many times for several days.

Then I decided to automate the check so that I can order a server whenever they are available.

Fortunately OVH offers a REST API to communicate with their servers and services. It's easier to check the availability of a server sending a http request to their API. Using a bunch of commands, the availability can be checked using a one line Linux command.

Just checking the availability is not enough. There should be a way to notify the availability. I could setup a script to send the availability to an email easily, but I don't read emails often. The best way of doing that is to push a message to my mobile. I found a free service called pushme (pushme.jagcesar.se) which can be used to push a message to my mobile. It also use a REST API, so I can send a message as a http POST request to pushme servers. Then pushme forwards the message to the app installed in the mobile via iCloud.

I created a simple shell script to read the server code as an argument and used it to check the availability of that server type using the OVH REST API. If a server is available, it sends a message to pushme using pushme REST API.

Then the script was scheduled to run for every 5 minutes using a cron job so that I'll get a notification whenever a server is available.

I also created another script to send a test message in every day morning to verify that the availability checker mechanism works.

After a day of implementing this, I was able to purchase the server I wanted. :)
Hope this might help you to find a server as well.
 
Avaiability Checker. It worked!

Screenshot of the notifications I received about 1801armada01 availability

But note that pushme works only with Apple. you will need another message sender if you use Android. Also this is a very simple and lazy way of doing this. No errors are checked in the script and only happy path is considered.

Here are the shell scripts and crons I used,

server_checker.sh

#!/bin/bash

server_code=$1
pushmeapi_token='replace_this_with_your_pushmeapi_token'

availability_count=`curl -s "https://www.ovh.com/engine/api/dedicated/server/availabilities?country=eu&hardware=$server_code" | json_pp | grep availability | grep -v unavailable | wc -l`

if [ $availability_count -gt 0 ]; then
 curl -d "title=found a $server_code&token=$pushmeapi_token" -X POST  https://pushmeapi.jagcesar.se
fi



ping_sender.sh

#!/bin/bash

pushmeapi_token='replace_this_with_your_pushmeapi_token'

curl -d "title=test message&token=$pushmeapi_token" -X POST  https://pushmeapi.jagcesar.se



Cron Jobs

*/5 * * * * /home/seedbox/server_checker.sh 1801sk13
*/5 * * * * /home/seedbox/server_checker.sh 1801armada01
30 5 * * * /home/seedbox/ping_sender.sh


You can find out the server code from either their web page (look at the source of the web page) or using their API.

Examples:

In https://www.soyoustart.com/us/server-storage/ page, when you click ARM-2T, the server code is there at the end of the URL as 1801armada01

below command will provide the list of ARM server types,

curl -s "https://www.ovh.com/engine/api/dedicated/server/availabilities?country=eu" | json_pp | grep hardware | grep -v , | sort | uniq | grep armada

below command will provide the list of kimsufi server types,

curl -s "https://www.ovh.com/engine/api/dedicated/server/availabilities?country=eu" | json_pp | grep hardware | grep -v , | sort | uniq | grep sk



Anyway, here is a list of machine types of kimsufi servers and SyS ARM servers,

Kimsufi Servers

France
KS-1    1801sk12
KS-2    1801sk13
KS-3    1801sk14
KS-4    1801sk15
KS-5    1801sk16
KS-6    1801sk17
KS-7    1801sk18
KS-8    1801sk19
KS-9    1801sk20
KS-10    1801sk21
KS-11    1801sk22
KS-12    1801sk23

Canada
KS-1    1804sk12
KS-2    1804sk13
KS-3    1804sk14
KS-4    1804sk15
KS-5    1804sk16
KS-6    1804sk17
KS-7    1804sk18
KS-8    1804sk19
KS-9    1804sk20
KS-10    1804sk21
KS-11    1804sk22
KS-12    1804sk23

Sys ARM servers

France
ARM-2T    1801armada01
ARM-4T    1801armada02
ARM-6T    1801armada03

Canada
ARM-2T    1804armada01
ARM-4T    1804armada02
ARM-6T    1804armada03

Tuesday, July 3, 2018

Document viewer Evince in Fedora does not print page borders? Here is a solution!

Well, this is not a workaround or a solution available in Evince, but this is a general solution which can be used when the usual GUI applications does not have some features. 

Today I was trying to print some lecture slides using "Document Viewer" also known as "Evince" running on my Fedora laptop. I was trying to print several pages in one output page. (4 lecture slides should be printed on a single page)

Once I got the output, I realized that it does not add a border to source pages printed on a single output page. I couldn't find an option in Evince to get that done.

Fortunately I came across about the Unix/Linux lp command which uses CUPS. (Common UNIX Printing System)
Using that I was able to get what I wanted printed precisely.

Here are the steps,

1. Find out the status of the printers you have configured in the system,

lpstat -a

This will list down all the printers you have configured in your machine. Use the preferred printer as the destination of the lp command using -d option. (see the next step)

2. Use lp command to get the job done

lp -d HP-LaserJet-400 -o sides=two-sided-short-edge -o number-up=4 -o pagesize=A4 -o landscape -o page-border=single -o fit-to-page -o number-up-layout=lrtb my_document.pdf

As you can see, we can pass multiple options to lp command including the page-border which I couldn't find in Evince. You can find the explanations of each option in lp man page.

Another great option of lp is that you can send multiple files to printer.
e.g.: if you want to print all the files which have file names starting from "bla_" then you can pass bla_* to lp command so that all of them will be printed one by one.