Strona główna / Społeczność / Blog

Once, after server crash, I've noticed I've BackupPC shows no backups for some clients. Fortunately /BackupPC/pc/*/ still contains those backups.

To fix a corrupted backups file you should:

  • Stop BackupPC
/etc/init.d/backuppc stop
  • Run BackupPC_fixupBackupSummary script as backuppc user
sudo -u backuppc /usr/share/backuppc/bin/BackupPC_fixupBackupSummary
  • Start BackupPC
/etc/init.d/backuppc start

Now I can see all backups on Host Summary page.

How to detect if there someone is home or if the house is empty.

Prerequisite

  • OpenWRT router
  • MQTT server
  • Something to interpret and display data (Node-RED, Home Assistant, Domoticz, OpenHAB, etc.)

On your OpenWRT router:

Install mosquitto-client. If you don't use encrypted communication use -nossl version.

opkg install mosquitto-client-ssl

Download presence_sensor script:

wget -O /usr/bin/presence_report https://github.com/dersimn/owrtwifi2mqtt/raw/master/presence_report

make it executable:

chmod u+x /usr/bin/presence_report

Now you can check if it works. Run command:

root@OpenWrt:~# /usr/bin/presence_report event 192.168.1.8
presence_report, mode: event, MQTT server: 192.168.1.8

Change 192.168.1.8 to address of your MQTT server. Turn WiFi on one of your devices (my was e6:6a:ca:c8:38:e6).

root@OpenWrt:~# /usr/bin/presence_report event 192.168.1.8
presence_report, mode: event, MQTT server: 192.168.1.8
Mac: e6:6a:ca:c8:38:e6 did del
Mac: e6:6a:ca:c8:38:e6 did new

as you can see there my device "left" (del) and connect (new) to Wi-Fi.

Press Ctrl-C to stop test.

To start this every time router boots I've added this line:

(/usr/bin/presence_report event 192.168.1.8 >/dev/null 2>&1 )&

to /etc/rc.local file. Of course before "exit 0".

Using data

You can subscribe to "owrtwifi/status/#" topics to receive messages in topic like this:

owrtwifi/status/mac-e6-6a-ca-c8-38-e6/event

and payload del or new.

They are also messages in topic

owrtwifi/status/mac-e6-6a-ca-c8-38-e6/dhcp-name

and name of your device in payload.

I'm using Node-RED and check every device like this:

context.devicescount=0;

if (!context.hasOwnProperty("devices")) {
    context.devices={};
}

if (msg.topic === "owrtwifi/status/mac-e6-6a-ca-c8-38-e6/event") {


    if (msg.payload === "new") {
        context.devices.PhoneNo1 = 1;
    }
    if (msg.payload === "del") {
        context.devices.PhoneNo1 = 0;
    }
}
// repeat above to all of your mobile devices
if (msg.topic === "owrtwifi/status/mac-00-11-22-33-44-55/event") {


    if (msg.payload === "new") {
        context.devices.PhoneNo2 = 1;
    }
    if (msg.payload === "del") {
        context.devices.PhoneNo2 = 0;
    }
}


let values = Object.values(context.devices);

values.forEach(function (value,index) {
    if (value == 1) {
        context.devicescount+=1;
    }
    return null;
});

if (context.devicescount>0) {
    node.send({payload:{"devices":context.devicescount},topic:"mydevices"});
}
else {
    node.send({payload:{"devices":context.devicescount,"house is empty":1},topic:"mydevices"});
}

Maybe it's not the best way, but it works for me.

The most important value is devicescount - the house is empty if equal to zero.

Of course this method cannot distinguish if you are in home or you just forgot your phone. It's obvious, but I want to be sure you know this too ;-)

When you will try to use VirtualBox on Windows 11 you can notice that VM performance is very low.

One of the reason can be Windows Hypervisor-enforced Code Integrity (HVCI).

The easiest way to check if it active is via Settings > Update & Security > Windows Security > Device security > Core isolation details > Memory integrity.

To turn it off run cmd as privileged user:

bcdedit /set hypervisorlaunchtype off

and restart the system.

Be aware, that HVCI is turned on to improve system security - so turn if off only when you really need it.

Download current binary from site memtest.org. Now current version is 5.31b.

Extract file (in my case memtest86+-5.31b.bin).

Rename it and place somewhere in TFTP server:

mv /tmp/memtest86+-5.31b.bin /data/tftpboot/networkboot/memtest86+-5.31b

as in previous posts my TFTP root is /data/tftpboot and I place all files in networkboot directory.

Add menu entry in pxelinux.cfg/default or as in my examples in pxelinux.cfg/4c4c4544-0042-4410-8053-b2c04f43334a (these magic numbers are my test PC UUID):

LABEL Memtest86-5.31
MENU LABEL Memtest86+ 5.31b
KERNEL /networkboot/memtest86+-5.31b

On fresh install ESXi 7.0 U2 you just need two commands:

esxcli system syslog config set --loghost='udp://192.168.1.28:514'
esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true

First line configures address of remote syslog server - of course you have to change 192.168.1.28 to yours server IP.

Second one opens required ports on firewall.

My router configuration was:

root@gargoyle:~# uci show dhcp.lan.dhcp_option
dhcp.lan.dhcp_option='252,http://wpad/wpad.dat' '6,192.168.1.28,192.168.1.4'

I would like to change WPAD address (option 252) to wpad.lan so I've to remove (del_list) old entry and add (add_list) new one:

root@gargoyle:~# uci del_list dhcp.lan.dhcp_option='252,http://wpad/wpad.dat'
root@gargoyle:~# uci add_list dhcp.lan.dhcp_option='252,http://wpad.lan/wpad.dat'

check, if everything is correct:

root@gargoyle:~# uci show dhcp.lan.dhcp_option
dhcp.lan.dhcp_option='6,192.168.1.28,192.168.1.4' '252,http://wpad.lan/wpad.dat'

now, You can commit changes (write to /etc/config/dhcp file) and restart dnsmasq daemon:

root@gargoyle:~# uci commit dhcp
root@gargoyle:~# /etc/init.d/dnsmasq restart

On client you can check again using nmap command:

[root@Optiplex745 ~]# nmap --script broadcast-dhcp-discover -e enp3s0
Starting Nmap 7.70 ( https://nmap.org ) at 2021-03-17 22:42 CET
Pre-scan script results:
| broadcast-dhcp-discover:
|   Response 1 of 1:
|     IP Offered: 192.168.1.249
|     DHCP Message Type: DHCPOFFER
|     Server Identifier: 192.168.1.4
|     IP Address Lease Time: 2m00s
|     Bootfile Name: undionly.kpxe\x00
|     Renewal Time Value: 1m00s
|     Rebinding Time Value: 1m45s
|     Subnet Mask: 255.255.255.0
|     Broadcast Address: 192.168.1.255
|     Router: 192.168.1.4
|     Domain Name: lan
|     WPAD: http://wpad.lan/wpad.dat
|_    Domain Name Server: 192.168.1.28, 192.168.1.4
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 3.85 seconds

Last two attempts (one and two) to power off using just short press of power button didn't work or work only when when you are logged in.

Now I've just installed ACPI daemon:

dnf install acpid
systemctl enable acpid

This finally works for my home server.

My last resolution about power button works only when monitor is connected.

If you have headless server you can use systemd-logind service. By default (in CentOS 8) it do nothing. I've only found:

systemd-logind[1373]: Power key pressed

in /var/log/messages.

To change this behaviour you can modify

/etc/systemd/logind.conf

I've uncommented line

#HandlePowerKey=poweroff

After thins restart service:

systemctl restart systemd-logind

Now power key works on headless Linux server.

Booting to PXE (or iPXE) using dnsmasq is rather well documented also by Me ;-).

If You would like to use MikroTik it's not so easy (at least v6.43.2). I couldn't manage to boot iPXE using chainloading because of the infinite loop with the DHCP server.

Booting from PXE is also not so obvious. You cannot set option 66 (next-server/Server-Name) nor 67 (boot-file/Bootfile-Name) in "ip dhcp-server option". Instead set "Next Server" and "Boot File Name" in "ip dhcp-server network", so it should look like this:

[admin@MikroTik] > /ip dhcp-server network print detail
Flags: D - dynamic
 0   ;;; defconf
     address=192.168.1.0/24 gateway=192.168.1.15 netmask=24
     dns-server=192.168.1.28,192.168.1.15 wins-server="" ntp-server=""
     caps-manager="" domain="lan" next-server=192.168.1.28
     boot-file-name="pxelinux.0" dhcp-option="" dhcp-option-set=""

I would like to upgrade kernel on diskless machine.

First upgrade system as regular one:

yum upgrade

Copy new installed initramfs and vmlinuz files somewhere, I've copied them directly to TFTP server

scp /boot/vmlinuz-3.10.0-1127.19.1.el7.x86_64 /boot/initramfs-3.10.0-1127.19.1.el7.x86_64.img 192.168.1.28:

as you can see my TFTP (and also PXE/iSCSI) server is 192.168.1.28.

Then you have to expose new files via TFTP server and modify PXE config files.

My TFTP server files are in /data/tftpboot, and I've decided to store boot files in /networkboot/CentOS7-2003 directory so:

mkdir /data/tftpboot/networkboot/CentOS7-2003
mv ~/initramfs-3.10.0-1127.19.1.el7.x86_64.img ~/vmlinuz-3.10.0-1127.19.1.el7.x86_64 /data/tftpboot/networkboot/CentOS7-2003

You can edit /data/tftpboot/pxelinux.cfg/default. I've per-machine PXE config files that's why I added to /data/tftpboot/pxelinux.cfg/4c4c4544-0042-4410-8053-b2c04f43334a instead of default:

LABEL Centos7-Optiplex745-3.10.0-1127.19.1
MENU LABEL CentOS 7 DELL Optiplex 745 (3.10.0-1127.19.1)
kernel /networkboot/CentOS7-2003/vmlinuz-3.10.0-1127.19.1.el7.x86_64 root=/dev/mapper/centos00-root ro netroot=iscsi:@192.168.1.28::::iqn.1994-11.com.netgear:nas:08303042:centos-pxe rd.iscsi.initiator=iqn.1994-05.com.redhat:2f3474eec735 vconsole.keymap=pl LANG=en_GB.UTF-8  console=tty0 ip=enp3s0:dhcp  rhgb quiet
append initrd=/networkboot/CentOS7-2003/initramfs-3.10.0-1127.19.1.el7.x86_64.img

as you can see kernel and initrd are updated to point at new files.

When You test that system boots from this new config you can change set it as default.

Ten kto umie pisze kod, ten kto nie umie pisze książki..., albo blog.

Pon Wt Śr Czw Pt So N
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30