Skip to content

Malaczynski.eu Posts

Migration to a new server

Ok, I migrated.

Services that I have transferred:

  1. Gmail forward
  2. Mysql base
  3. WordPress
  1. It was simple, deleted on one host and added on another. I didn’t have to change anything with my domain registrar. When I configured it, I added the appropriate DNS entries.
  2. I thought I didn’t need to do anything because it’s a shared database, but it turns out I need to copy all the data and restore it to the new account. I did this using Adminer. It has easy import and export options.
  3. WordPress eh, scared me at first. I went to my first post about installing WordPress and noticed that the linked page had changed xD Well, this post is already worthless anyway, but a lesson for the future to make screenshots of pages.

New site: https://websiteforstudents.com/how-to-install-wordpress-on-ubuntu-linux-with-nginx/

I did everything without a database (I already have one) and Let’s Encrypt (Cloudflare provides me with an SSL certificate). Speaking about Cloudflare, I changed the IPv6 address in their configuration for the new server.

The last thing I did was copy the entire WordPress directory and overlay the old one on the new installation. That was the hardest part, because I didn’t know how to copy data from one VPS to another.

rsync -avzhe 'ssh -p 10XXX' --progress /var/www [email protected]:/var/www

Performed on the old server fixed the issue.
I used the instructions from this webpage: https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/

Edit. It wasn’t.

The last thing was to change wp-config.php file to change database name, username, password and host.

New server

Few days ago I received an email from my VPS provider with happy news of the new server being released to me. They migrate to the new architecture and remove the old one. My upgrades are: Faster connection (1Gbps), SWAP replaced by more RAM, faster drive (SSD NVMe), updated kernel (5….). I recommend this lifestyle. And my provider Mikr.us.

ps. I also bought a 256MB RAM and 5GB HDD upgrade for 30PLN for a one-time fee, so my wordpress server should now be much faster.

Hidden administrative shares

Believe me or not, but in Windows there is a hidden administrative shares that you can see when you enter in the cmd terminal command:

net share

Most important share is c$.

Lets say you have to connect remote computer and upload some files, you have an administrator right, you know destination IP address, but you don’t know how to do it. So you go to PC and must locally use pendrive or email, or other remote share. And then I come all in white and say: backslash backslash one hundred ninety-two dot one hundred sixty-eight dot oł dot one hundred and one backslash c dollar

\\192.168.0.101\c$

Autostart clean up

Video about finding hidden startup programs and deleting unnecessary ones.

WireGuard – best VPN ever

As in the title. I’m not even going to elaborate on the superiority of WireGuard over other VPNs like OpenVPN. You have to accept this fact and get along with it. However, sometimes there is a problem with the WireGueard client on Windows 10, because due to restrictions on non-admin user profiles, the GUI will not display. I have not been able to fix this, but I have found a solution which is TunSafe.

The only problem with TunSafe is that it requires you to log on to an administrator account while starting, but Windows security issues are a topic for a separate article.

Edit. An all-in-one WireGuard VPN solution with a web ui for connecting devices.

0x0000011b printer error

If you are having problem in windows 10 to connect remote printer and error number 0x0000011b appears then to fix it you need to uninstall latest system update KB5005565.

Restart MM form HA

From time to time the photo module in MagicMirror hangs. I used to restart it manually by logging into the Raspberry and using the command “pm2 restart mm”. Now I want to make it so that it automatically restarts when I scan the NFC tag stuck to the back of the monitor.

So I divided big problem to smaller ones:
1. Restart MM,
2. Connection HA to MM machine,
3. Automation when HA apk scan tag,
4. Stick the NFC tag to the monitor xD

  1. Restart MM – Easy
pm2 restart mm

2. Connection HA to MM mashine

HA needs to let MM know to shut down for a while, so I guess the easiest way to do this is with mqtt broker.
I have used before Mosquitto, so I will use it.

MM site:
I created 2 files in my home directory: restartmm.sh and restartmm.py

restartmm.sh:

#!/usr/bin/env python

sleep 20
python /home/pi/restartmm.py &
restartmm.py basen on mqtt-screen-power project:

mqtt_host = "192.168.xxx.xxx"
mqtt_port = 1883
mqtt_topic = "/screen/restart"
mqtt_username = "xxxxxxxx"
mqtt_password = "xxxxxxxx"
power_on_command = "pm2 restart mm"
power_off_command = " "


import paho.mqtt.client as mqtt
import subprocess


def on_connect(client, userdata, flags, rc):
    # The callback for when the client receives a CONNACK response from the server.
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe(mqtt_topic)


def on_message(client, userdata, msg):
    # The callback for when a PUBLISH message is received from the server.
    print(msg.topic+" "+str(msg.payload))
    if str(msg.payload) == "ON":
        subprocess.Popen(power_on_command,
                         shell=True, stdout=subprocess.PIPE)
    else:
        subprocess.Popen(power_off_command,
                         shell=True, stdout=subprocess.PIPE)


client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.username_pw_set(mqtt_username, mqtt_password)
client.connect(mqtt_host, mqtt_port, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()

Both files chown is 755. Autostart with command “crontab -e” – “@reboot sh /home/XXXXX/restartmm.sh”

HA site:

HA configuration.yaml

switch:
  - platform: mqtt
    name: "MM restart"
    command_topic: "/screen/restart"

automations.yaml:

- alias: turn_off_restart_mm
  trigger:
    platform: state
    entity_id: switch.mm_restart
    to: 'on'
    for:
      seconds: 1
  action:
    service: switch.turn_off
    entity_id: switch.mm_restart

3. Automation when HA apk scan tag,

HA automations.yaml:

- alias: mm_tag
  initial_state: true
  trigger:
  - platform: tag
    tag_id: 7275ecff-27a1-4c4d-a7fd-69647998dbf8
  action:
  - service: switch.turn_on
    entity_id: switch.mm_restart

4. Stick the NFC tag to the monitor. Formality.

Changing the hours of light in HA automations

I wanted the lights above my kitchen counter to light up faster in the evening and later in the morning, I did it this way:

- alias: Kitchen_leds_on
  initial_state: true
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d00031c90e3
    from: 'off'
    to: 'on'
  condition:
    condition: or
    conditions:
      - condition: numeric_state
        entity_id: 'sensor.illumination_34ce00fb6930'
        below: 100
      - condition: time
        after: '19:00:00'
      - condition: sun
        after: sunset
        after_offset: '-01:00:00'
      - condition: sun
        before: sunrise
        before_offset: '01:00:00'
  action:
    service: light.turn_on
    entity_id: light.kitchen_leds