Category Archives: Linux

Everything related to linux

add systray to elemtary os

Elementary OS 5 comes with a very limited systray functionality that needs to be fixed. For this you need to install wingpanel-indicator-ayatana that can be installed via a PPA and change autostart config of the indicator app.

Install wingpanel-indicator-ayatana

sudo add-apt-repository ppa:yunnxx/elementary
sudo apt update
sudo apt install indicator-application wingpanel-indicator-ayatana

Change autostart config

Open the config file with

sudo vim /etc/xdg/autostart/indicator-application.desktop

and change the line

OnlyShowIn=Unity;GNOME;

to

OnlyShowIn=Unity;GNOME;Pantheon;

Then reboot your machine and you should have a systray that displays your application icons too.

remove qemu libvirt user form lightdm login screen

After installing kvm on my enlightenment 5 system I had a login for qemu libvirt to choose in the login screen. To remove it I ran:

printf "[User]\nSystemAccount=true\n" | sudo tee /var/lib/AccountsService/users/libvirt-qemu
sudo systemctl restart accounts-daemon.service

On the next login the entry was gone.

How to use Epson POS printer TM-T20II under linux

Getting an epson pos printer up and running under linux is very easy:

# add current user to lp group (requires relogin to work properly)
sudo usermod -a -G lp $USER

# for TM-T20II add udev rule (optional in my case):
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0e15", MODE="0664", GROUP="lp"' > sudo tee -a /etc/udev/rules.d/99-escpos.rules
sudo service udev restart

# install pip and pipenv
sudo apt install python-pip
pip install --user pipenv

# install download python-escpos and submodules
git clone https://github.com/python-escpos/python-escpos.git
cd python-escpo
git submodule update --init --recursive

# install including deps
pipenv install -e .

Now you should be ready to use the installation. From your installation repository run a pipenv shell by using “pipenv shell” or simply run “pipenv run python _your-script_.py” to run a script directly.

Here is an example script:

from escpos.printer import Usb

# see https://github.com/python-escpos/python-escpos/blob/development/src/escpos/escpos.py

""" Seiko Epson Corp. Receipt Printer (EPSON TM-T20II) """
p = Usb(0x04b8, 0x0e15, 0, profile="TM-T88II")

p.set(bold=True, underline=1, align='center', custom_size=True, width=2, height=2)
p.textln("Hello world")
p.ln(count=1)
p.set()
p.textln("this is a test")

p.set(align='center')
p.image("examples/graphics/climacons/rain.png")
p.qr("Dies ist ein Test", size=8)
p.set()

p.barcode('1324354657687', 'EAN13', width=3)
p.barcode('123456', 'CODE39', width=3)

p.block_text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", font='a', columns=None)

p.cut()

redis-server on ubuntu 18.04

After installing redis on my machine I received the following error message:

redis-server.service: Can’t open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory

This message comes because redis refuses to start with disabled ipv6. To get it running you have to remove “::1” from “bind 127.0.0.1 ::1” in /etc/redis/redis.conf. Then redis starts as expected.

Access Ubuntu 18.04 via VNC from Mac

Ubuntu

First prepare the ubuntu machine by installing vino:

sudo apt install vino

Then hit windows button and look for sharing. Configure the system to allow remote connections with given password.

You also need to disable encryption with:

gsettings set org.gnome.Vino require-encryption false

MAC

Then you can access the machine from your Mac with Screen Sharing app with the url

vnc://<IP>:5900

 

Add network bridge with ubuntu 18.04

To create a network bridge with netplan you have to create a file

network:
  version: 2
  ethernets:
     enp6s0:
        dhcp4: true
  bridges:
     br0:
       interfaces: [enp6s0]
       dhcp4: true
       optional: false
       macaddress: <some mac>

Make sure to place a mac address in and replace the interface name enp6s0 with yours.

Then run sudo netplan apply.

The machine gets a new IP from dhcp so make sure you have it configured in your dhcp before or have a local console 😉

Openssl certificates for apache

In my former post i described a way how to create self signed SSL certificates with an own certificate authority. These certificates didn’t work in latest chrome versions so I updated my scripts to create valid certificates for chrome. This time I only create wildcard certificates because creating one for every subdomain was annoying.

#!/bin/bash
if [ -e ca.key ]; then
	echo "ca.key already exists"
	exit 1
fi

openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt \
  -subj "/C=AT/ST=Vienna/L=Vienna/O=Coffeebeans/CN=Coffeebeans Domain Validation Secure Server CA/emailAddress=office@coffeebeans.at"
#!/bin/bash
NAME=star.$1
if [ "star." == $NAME ]; then
	echo "usage: $0 <domain.name>"
	exit 1
fi
if [ -e $NAME.key ]; then
	echo "$NAME.key already exists"
	exit 1
fi
if [ ! -e ca.crt ]; then
	echo "no ca certificate created"
	exit 1
fi

CONFIG=$(cat <<-EOF
[ca]
default_ca=CA_default

[CA_default]
dir=./ca
database=\$dir/index.txt
new_certs_dir=\$dir/newcerts
serial=\$dir/serial
private_key=./ca.key
certificate=./ca.crt
default_days=3650
default_md=sha256
policy=policy_anything
copy_extensions=copyall

[policy_anything]
countryName=optional
stateOrProvinceName=optional
localityName=optional
organizationName=optional
organizationalUnitName=optional
commonName=supplied
emailAddress=optional

[req]
default_bits=4096
prompt=no
default_md=sha256
req_extensions=req_ext
distinguished_name=dn
 
[ dn ]
C=AT
ST=Vienna
L=Vienna
OU=Domain Control Validated
emailAddress=office@coffeebeans.at
CN=*.$1
 
[ req_ext ]
subjectAltName=@alt_names
 
[ alt_names ]
DNS.1=$1
DNS.2=*.$1
EOF
)

# PREPARE
echo "$CONFIG" > config.txt
if [ ! -d ./ca ]; then
	mkdir -p ./ca/newcerts
	touch ./ca/index.txt
fi

openssl genrsa -out $NAME.key 4096
openssl req -new -key $NAME.key -out $NAME.csr -config config.txt
openssl ca -create_serial -batch -in $NAME.csr -out $NAME.crt -config config.txt

# CLEANUP
rm -f *.csr config.txt
chmod 644 *.key *.crt

I also tried to use these certificates in postfix which did NOT work. To create files for postfix see my former post.

 

Robo 3T MongoDB client fails to start on ubuntu 16.04

I tried to rim robo3t-1.1.1-linux-x86_64 downloaded from https://robomongo.org/ and got the following error when trying to run it:

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: xcb.

Reinstalling the application may fix this problem.
Aborted

Trying to install xcb via apt install xcb doesn’t change the behavior. Then I found a solution by removing all libstdc++* files from the lib directory in the extracted directory:

rm lib/libstdc++*

failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: “systemd” is different from docker cgroup driver: “cgroupfs”

Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

Docker version 17.06.0-ce, build 02c1d87

openshift-origin-server-v3.6.0-c4dd4cf-linux-64bit

I followed the steps under https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary and got the error in the title. To fix this you have to add “–exec-opt native.cgroupdriver=systemd” to ExecStart of docker. The best way to do this is to add a addin file /etc/systemd/system/docker.service.d/override.conf with following content:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --exec-opt native.cgroupdriver=systemd

Then reload systemd and restart docker:

sudo systemctl daemon-reload
sudo systemctl restart docker

 

SSL certificates for apache

Simple way to create self-signed SSL certificates.

#!/bin/bash
# usage: ./create-ca.sh
if [ -e ca.key ]; then
	echo "ca.key already exists"
	exit 1
fi

openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt \
  -subj "/C=AT/ST=Vienna/L=Vienna/O=coffeebeans.at/OU=IT/CN=coffeebeans.at/emailAddress=office@coffeebeans.at"
#!/bin/bash
# usage: ./create-key.sh CN
NAME=$1
SERIAL=`ls -l *.key | wc -l`

if [ $SERIAL -lt 10 ]; then
	SERIAL="0$SERIAL"
fi

if [ -e $NAME.key ]; then
	echo "$NAME.key already exists"
	exit 1
fi

if [ ! -e ca.crt ]; then
	echo "no ca certificate created"
	exit 1
fi

echo "creating key for $NAME with serial $SERIAL"
openssl genrsa -out $NAME.key 4096
openssl req -new -key $NAME.key -out $NAME.csr \
  -subj "/C=AT/ST=Vienna/L=Vienna/O=coffeebeans.at/OU=IT/CN=$NAME/emailAddress=office@coffeebeans.at"
openssl x509 -req -days 3650 -CA ca.crt -CAkey ca.key \
  -set_serial $SERIAL -in $NAME.csr -out $NAME.crt

rm *.csr