The officially official Devuan Forum!

You are not logged in.

#101 DIY » ditch your bloated network manager » 2019-10-07 13:59:45

GNUser
Replies: 12

I have a laptop and my networking needs are quite simple. This is all I need:

a. handful of wireless hotspots (SSID and password) should be remembered
b. at boot, laptop should connect to highest-priority hotspot among those available
c. an icon should appear while I am connected to internet, showing hotspot's SSID

Given such simple needs, for many years I thought having a "network manager" installed was overkill. Finally, for the past few months I've been enjoying a completely network-manager-free computing experience thanks to these two simple shell scripts I wrote:

https://github.com/bdantas/autowifi (currently 63 lines including comments and blank lines)
https://github.com/bdantas/wifi-monitor (currently 51 lines including comments and blank lines)

I'd like to share the scripts with my Devuan friends. If you'd like to use them, all you need to do is:

1. Install some basic packages (you likely have most of them installed already):

sudo apt install procps net-tools wireless-tools wpasupplicant udhcpc curl yad

2. Download the two scripts, put them somewhere in your PATH, adjust the "user variables" at the top as appropriate, change the ssid/password strings at the top of autowifi as appropriate, make the scripts executable

3. Add sudo autowifi & and wifi-monitor &  to your startup jobs (note that wifi-monitor should run without sudo)

4. Disable your current network manager (e.g., sudo update-rc.d network-manager disable)

5. Reboot

If you decide to try it, please let me know how it goes.

Cheers,
Bruno "GNUser"

P.S. If you change your mind and want to go back to using the network manager, just remove the two startup jobs and re-enable the network manager (e.g., sudo update-rc.d network-manager enable)

#102 Re: Off-topic » 'xinput test' produces no output when typing in xfwrite [SOLVED] » 2019-09-29 04:08:28

I found that xinput --test-xi2 --root and xinput --test-xi2 --root <keyboard_id> work.

#103 Off-topic » 'xinput test' produces no output when typing in xfwrite [SOLVED] » 2019-09-29 01:10:39

GNUser
Replies: 1

I created a little shell script that uses a crude keylogger (xinput test <keyboard_id>) and xdotool to replace certain character combinations when they are typed. The script is here but the particulars are not important.

The problem is that my script works well with all the GUI applications I've tested except for (ironically) my preferred text editor, xfwrite. It seems that xfwrite is somehow immune to the keylogger.

To reproduce the issue, open up a terminal emulator then:

$ sudo apt install xinput xfe
$ xinput test <your_keyboard_id> # mine is 9

Leave the terminal emulator open then launch a different application (e.g., web browser) and type something; you'll notice that xinput test detects your keystrokes. Now launch xfwrite and type something; you'll notice that xinput test does not seem to detect any keystrokes and produces no ouput.

I tried recompiling libfox and libfox-dev with the --with-xinput flag to configure then recompiling xfe, but it made no difference. UNIX wizards who frequent this forum: Any idea what needs to be done so that xinput test can detect keystrokes while typing in xfwrite?

#104 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-15 00:46:57

I tinkered with ralph.ronnquist's solution in post #13 and figured out that this is what's actually going on when you decompress the logic:

$ master_id=$(LANG=C xinput list | grep -i 'master keyboard' | egrep -o 'id=[0-9]+' | egrep -o '[0-9]+')
$ keyboard_id=$(LANG=C xinput list $master_id | grep 'XIKeyClass' | egrep -o '[0-9]+')

This version is easier for my pea brain to grasp.

#105 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-14 17:45:01

Why would you need the xinput id if you don't have xinput installed?

#106 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-14 16:16:30

Yes, that works even on my wife's wonky hardware where multiple "slave keyboards" are listed. big_smile

eileen@vaio:~$ xinput list --id-only | xargs -n 1 -I+ sh -c "xinput list + | grep -wv + | grep XIKeyClass" | egrep -o '[0-9]+'
12

Wow, ralph.ronnquist. Very impressive. Thank you!

I understand the logic of the command, but don't understand how you figured out that it was the necessary logic. Will chew on it.

BTW, I had also found that nugget on stackexchange, but do not want to give users anything in addition to the shell script I've created. The script is here if you are curious:
https://github.com/bdantas/iksilo

#107 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-14 11:59:35

Doesn't work on my wife's Sony Vaio:

$ LANG=C xinput --list | grep -i keyboard | egrep -iv 'virtual|video|button|bus'
    ↳ Sony Vaio Keys                          	id=7	[slave  keyboard (3)]
    ↳ USB 2.0 Camera: USB 2.0 Camera          	id=10	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=12	[slave  keyboard (3)]
    ↳ Sony Vaio Jogdial                       	id=14	[slave  keyboard (3)]

This is tough.

#108 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-14 11:16:51

Thank you both. I think we're getting warmer. Does this work on all your test systems?

LANG=C xinput --list | grep -i keyboard | egrep -iv 'virtual|video|button|bus' | egrep -o 'id=[0-9]+' | egrep -o '[0-9]+'

#109 Re: Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-14 02:04:07

Wow, thanks guys!

ralph.ronnquist's suggestion works in Devuan, in Tiny Core Linux (which uses BusyBox instead of coreutils), and even in OpenBSD. I modified it slightly to something that does same thing but makes more sense to me:

xinput --list --long | grep XIKeyClass | head -n 1 | egrep -o '[0-9]+'

There's no way I would have figured this out on my own. Thanks again, ralph. You're a wizard!

The only thing I don't understand is why the entry of interest always happens to be the first match.

#110 Off-topic » how to automatically get xinput id of keyboard? [SOLVED] » 2019-09-13 17:46:24

GNUser
Replies: 17

I've written a shell script that needs to know the xinput id of the keyboard being used. In the case of my Devuan box the id happens to be 9. However, in my OpenBSD box the id is 6.

I want to make the script portable and don't want to bother myself or other users with having to run xinput --list and then manually editing the keyboard id in the script. Is there a way to determine the id automatically? If the script has to wait for user to press a key so that script can find the id, that would be fine.

I've checked what xdotooland xev but neither one seems able to help. grepping output of xinput --list for "keyboard" won't work because there's more than one line with that word in it. Also, I don't want to assume that the system language is English.

Any ideas?

#111 Re: Off-topic » What other distro are you using (besides devuan)? » 2019-07-18 19:38:46

OpenBSD and Tiny Core Linux

I dual boot Devuan and OpenBSD on my Libreboot laptop, which one I use on a given day depends on my mood.
Tiny Core Linux on my netbook-turned-router/fileserver/webserver

#112 Re: Installation » The most secure hardened kernel » 2019-06-20 19:05:43

For what it's worth, I find FSF/GNU and OpenBSD folks equally trustworthy. They bicker a lot over licensing, style, and other fine points, but the fact that both camps insist on source code being available tells me they have nothing to hide.

Unless a person decides he will become an island to himself and use only his own products, we have no choice but to trust others. So the question is not whether to trust, but who to trust. When it comes to software, I completely trust the FSF/GNU and OpenBSD folks (unless they are talking about each other smile).

#113 Re: Hardware & System Configuration » Listing Services On System » 2019-06-18 18:37:40

Welcome, nullr00t!

To see the init scripts that run at boot (which presumably are your "services"), do ls /etc/rcS.d and ls /etc/rc2.d

Another way is sudo service --status-all. The output of this command also shows which services are running vs. not running vs. status unknown. For the services that report status unknown, you can try pgrep -fa foo

#114 Re: Installation » The most secure hardened kernel » 2019-06-14 11:31:40

alupoj, if you care this much about your hardware not having backdoors (as I do and as we all should), then you need to use a computer that does not have proprietary BIOS or, even worse, Intel Management Engine or (AMD's) Platform Security Processor. See https://www.fsf.org/blogs/sysadmin/the- … rs-freedom

If you don't already, you should be using a computer with Libreboot (i.e., no proprietary BIOS and Intel Management Engine completely disabled). You can get a laptop with Libreboot on Minifree, Technoethical, or Vikings. They may be more vendors, but these are the ones I know of. I have been happily using a T400 with Libreboot (on which I dual-boot Devuan and OpenBSD) for several years. Everything works perfectly except for virtualization, which I have had to sacrifice. The choice between security and convenience affects everybody.

I second HoaS's plug for OpenBSD. Devuan is one of the the best GNU/Linuxen around, but GNU/Linux in general is not about being "most secure". If most secure is what you're looking for, that's what OpenBSD does by default--no need to swap key software components or tweak configuration settings.

#115 Re: Hardware & System Configuration » Create new service from systemd x11vnc.service » 2019-05-24 13:53:36

Hi, ea4170. I did some copy and pasting and came up with this. It is untested, but something to get you started:

#!/bin/sh
### BEGIN INIT INFO
# Provides:		x11vnc
# Required-Start:
# Required-Stop:
# Should-Start:	     
# Should-Stop:       
# X-Start-After:	lightdm
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6		
# Short-Description:	VNC Server for X11
# Description:		VNC Server for X11 
### END INIT INFO

case "$1" in
  start)
	while true; do
		/usr/bin/x11vnc -xkb -repeat -allow 127.0.0.1 -display :0 -auth guess -rfbauth /etc/X11/x11vnc.passwd -rfbport 5900 -forever -loop -o /var/log/x11vnc.log
	done
	;;
  stop)
	pkill x11vnc
	sleep 1
	pkill -KILL x11vnc
	;;
esac

exit 0

To test it:
1. Replace lightdm if appropriate (run # service --status-all or $ ls /etc/init.d to find the name of your display manager service)
2. Name the above script x11vnc, put it in /etc/init.d/, and make it executable
3. # update-rc.d x11vnc defaults

Good luck. Let me know how it goes.

P.S. I haven't used any vnc applications in a long time. If -forever -loop already gives you automatic restarting, delete the while true; do and done lines from my script.

#116 Re: Hardware & System Configuration » unreliable wireless network printer after power off/on cycle [SOLVED] » 2019-05-24 13:11:47

TL;DR version:
    This HP printer's dhcp client is flaky. If the printer's dhcp lease expires while printer is off, the printer cannot reliably get back on the network after being powered on--despite what its friendly beeps and lights might lead one to believe. Configuring router's dhcp server (dnsmasq) to give the printer a non-expiring ("infinite") lease solved the problem.

-----

Detailed version:
    I was able to consistently reproduce the problem by turning printer off, revoking printer's dhcp lease (in router: # pkill dnsmasq,  delete the line in /var/lib/misc/dnsmasq.leases that shows printer's lease, # dnsmasq), then turning printer back on. After printer fully powers on, its blue network light blinks for a little while then printer makes a friendly beep and blue light goes steady to indicate it has a network connection--which I found to be a big lie. In my experiments I found one of three things to always be true:

1. Printer takes a long time to negotiate a new dhcp lease--no new lease shows up in router's dnsmasq.leases (and printer is not reachable by ping or traceroute) until several minutes after printer's blue light is steady
2. Printer does not negotiate a new dhcp lease at all until I push some buttons on its little screen asking it to display its network settings
or
3. Printer never actually negotiates a new dhcp lease and reports that it has an ip address that is not even on my network (169.254.227.111)

Explaining the problems I was experiencing:
    Sometimes the kids turn off the printer and it is off for a few days until we find ourselves having to print again, by which time the printer's 24-hour dhcp lease has certainly expired. Those times it seemed that I needed to reboot my laptop before I could print again were probably due to situation #1 above--me rebooting was simply giving the printer enough time to finish negotiating a new lease with my router.

The solution:
    Configure printer to do as little as possible network-wise (in its settings, choose "get address automatically", provide the wireless network password, and that's it) and let the router not only assign the desired static IP but also make the lease non-expiring. This line in dnsmasq.conf takes care of both things: dhcp-host=aa:bb:cc:11:22:33,192.168.10.7,infinite (where aa:bb:cc:11:22:33 is the printer's MAC address, of course).
    Now when I turn the printer off and back on, it quickly gets on the network (can be reached by ping and traceroute) and can print reliably.

I hope this helps someone. I've been scratching my head on and off because of this for well over a year at this point.

#117 Re: Off-topic » dhclient - how to never ask for prior address? [SOLVED] » 2019-05-19 19:14:13

I have a good-enough solution. It involves A) some changes in router (dhcp server side) and B) some changes in laptop (dhcp client side).

A. In router (assuming you, like me, are using dnsmasq as the dhcp server):

# pkill dnsmasq
# rm /var/lib/misc/dnsmasq.leases
# echo "dhcp-sequential-ip" >> /etc/dnsmasq.conf
# dnsmasq

B. In my Devuan ASCII laptop (which unfortunately uses network-manager, which runs dhclient when appropriate):

# vi /etc/init.d/network-manager
add this line under the 'start)' line: rm /var/lib/NetworkManager/dhclient*
# service network-manager restart

Now, even with the default dhclient settings in my Devuan laptop, DHCP is working in a way that seems intuitive. Namely:
1. router leases out the first available IP
2. router keeps track of leases and repeatedly gives a particular IP to a particular machine only during life of the lease
3. when network-manager starts or restarts on a client machine, dhclient cannot ask for an old IP because there is no record

Problem solved smile

P.S. Since I know Head_on_a_Stick likes both Devuan and OpenBSD (I'm brudan on daemonforums.org, by the way), for an OpenBSD laptop/desktop, part B is simply adding !rm /var/db/dhclient.leases.\$if to the top of your /etc/hostname.if file.

#118 Re: Off-topic » dhclient - how to never ask for prior address? [SOLVED] » 2019-05-19 12:12:54

Thank you, Head_on_a_Stick. It seems NetworkManager parses /etc/dhcp/dhclient.conf then appends a few lines, to produce /var/lib/NetworkManager/dhclient-wlan0.conf. The latter file already contains request;. This is what the complete /var/lib/NetworkManager/dhclient-wlan0.conf looks like:

# Created by NetworkManager
# Merged from /etc/dhcp/dhclient.conf

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#    man page for more information about the syntax of this file
#    and a more comprehensive list of the parameters understood by
#    dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#    not leave anything out (like the domain name, for example), then
#    few changes must be made to this file, if any.
#
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}
#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}
send host-name "thinkpad"; # added by NetworkManager

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;

request; # override dhclient defaults
also request subnet-mask;
also request broadcast-address;
also request time-offset;
also request routers;
also request domain-name;
also request domain-name-servers;
also request domain-search;
also request host-name;
also request dhcp6.name-servers;
also request dhcp6.domain-search;
also request dhcp6.fqdn;
also request dhcp6.sntp-servers;
also request netbios-name-servers;
also request netbios-scope;
also request interface-mtu;
also request rfc3442-classless-static-routes;
also request ntp-servers;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;

Any idea what needs to be changed in order to achieve the desired behavior?

#119 Re: Off-topic » dhclient - how to never ask for prior address? [SOLVED] » 2019-05-19 04:08:45

Alas, things are never as simple as they seem. Not only do we need 1) dhcp server sequential ip flag and 2) delete server's lease file, but there are also considerations on the client side.

It seems that dhclient is hardwired to ask for the last IP address it got. This from dhclient.conf's man page:

When the client is restarted, it first tries to reacquire the last address it had. This is called the INIT-REBOOT state. If it is still attached to the same network it was attached to when it last ran, this is the quickest way to get started. The reboot statement sets the time that must elapse after the client first tries to reacquire its old address before it gives up and tries to discover a new address. By default, the reboot timeout is ten seconds.

I tried putting reboot 0; in my computer's /etc/dhcp/dhclient.conf, but it has no effect. So I had to do this:
3) # rm /var/lib/NetworkManager/dhclient*

With 1-3 above I finally got the expected behavior of my computer getting the lowest-available IP address from the router.

But I'm not satisfied because step 3 is a hack. What I really want is a way of telling dhclient not to try to reacquire the last address it had. Any idea how to accomplish this?

#120 Re: Off-topic » dhclient - how to never ask for prior address? [SOLVED] » 2019-05-18 22:45:28

The dnsmasq man page solved the mystery of dhcp always giving particular computers particular IP addresses:

Dnsmasq  is  designed  to  choose  IP addresses for DHCP clients
using a hash of the client's MAC address. This normally allows a
client's  address to remain stable long-term, even if the client
sometimes allows its DHCP lease to expire.

The --dhcp-sequential-ip flag causes dnsmasq's behavior to be what I expected. Hope this helps anyone who finds themselves doing some head-scratching as I was smile

#121 Off-topic » dhclient - how to never ask for prior address? [SOLVED] » 2019-05-18 17:17:14

GNUser
Replies: 7

I'm doing some network troubleshooting and am surprised that the machines on my wireless network always get the same "random" IP address from my router, even after I delete all the leases in /var/lib/misc/dnsmasq.leases.

The router has a startup job that creates /tmp/dnsmasq.conf and then launches dnsmasq with this command: dnsmasq -C /tmp/dnsmasq.conf. This is what /tmp/dnsmasq.conf looks like:

listen-address=192.168.10.1
bind-dynamic
dhcp-range=192.168.10.100,192.168.10.200,255.255.255.0,24h
dhcp-option-force=option:router,192.168.10.1
dhcp-option-force=option:dns-server,192.168.10.1
dhcp-option-force=option:mtu,1500

How come machines get the same IP addresses even after I manually delete /var/lib/misc/dnsmasq.leases and reboot the router? All the machines are configured to use DHCP, not a static local ip. There must be a record of prior IP addresses somewhere. Does dnsmasq have some kind of IP address cache? Maybe the Devuan ASCII computers somehow remember their prior IP address and ask for the same address again during DHCP negotiation?

Bottomline: How do I purge all memory of prior IP addresses so that all machines in my wireless network get new addresses the next time they talk to the router?

#122 Re: Hardware & System Configuration » unreliable wireless network printer after power off/on cycle [SOLVED] » 2019-05-18 13:50:11

Hmm, I was curious about the ?zc= suffix in the printer's URI. An internet search tells me the zc stands for zeroconf and is related to avahi-daemon.

https://bugs.launchpad.net/hplip/+bug/521909

The strange thing is that avahi-daemon is not running on my machines because I disabled it (it is privacy-unfriendly). (Maybe I disabled avahi-daemon after installing the printer? I installed ASCII and setup the printer a long time ago and can't remember.) Maybe the ?zc= suffix has something to do with the flaky connection to the printer. I'll try re-creating the printer with the ?ip= suffix in its URL followed by its local ip address.

UPDATE:
I reconfigured the printer:

eileen@vaio:~$ lpstat -s
system default destination: HPWireless
device for HPWireless: hp:/net/Photosmart_7520_series?ip=192.168.10.7

Not sure if the new URI will cause the printer to be reachable more consistently, but it sure looks better!

#123 Re: Hardware & System Configuration » unreliable wireless network printer after power off/on cycle [SOLVED] » 2019-05-18 13:28:53

Thank you, ralph.ronnquist. That's an interesting theory. Next time I can't print, I'll try just disconnecting/reconnecting the computer from the wireless network instead of rebooting the computer. I'll report the results.

#124 Re: Hardware & System Configuration » unreliable wireless network printer after power off/on cycle [SOLVED] » 2019-05-18 02:35:27

Here is some basic printer information:

eileen@vaio:~$ lpstat -s
system default destination: HPWireless
device for HPWireless: hp:/net/Photosmart_7520_series?zc=HPA0D3C1E1E36F

Ping and traceroute can't reach the printer when the problem occurs. Strangely, I cannot reproduce the problem at will--it seems to happen randomly.

Here are results when I can print:

eileen@vaio:~$ ping -c 1 -W 2 192.168.10.7
PING 192.168.10.7 (192.168.10.7) 56(84) bytes of data.
64 bytes from 192.168.10.7: icmp_seq=1 ttl=255 time=1.86 ms

--- 192.168.10.7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.861/1.861/1.861/0.000 ms

eileen@vaio:~$ traceroute 192.168.10.7
traceroute to 192.168.10.7 (192.168.10.7), 30 hops max, 60 byte packets
 1  HPE1E36F (192.168.10.7)  4.685 ms  4.918 ms  4.886 ms

Here are results when I cannot print:

eileen@vaio:~$ ping -c 1 -W 2 192.168.10.7
PING 192.168.10.7 (192.168.10.7) 56(84) bytes of data.

--- 192.168.10.7 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

eileen@vaio:~$ traceroute 192.168.10.7
traceroute to 192.168.10.7 (192.168.10.7), 30 hops max, 60 byte packets
 1  192.168.10.187 (192.168.10.187)  1069.930 ms !H  1069.884 ms !H  1069.869 ms !H

Why is it that I need to reboot the computer (not the printer) in order to be able to print again?

#125 Hardware & System Configuration » unreliable wireless network printer after power off/on cycle [SOLVED] » 2019-05-17 13:37:03

GNUser
Replies: 5

All my Devuan ASCII computers at home print to an HP printer on my wireless network. The printer is always at the same local IP address.

I have noticed that if the printer reconnects to the network for any reason (e.g., one of my kids turns it off and I have to turn it back on), sometimes none of the Devuan computers can print unless I first reboot them. It's difficult to reproduce.

I have tried restarting cups on the computers after the printer reconnects to the network, but it makes no difference. Some other service or daemon probably needs to be restarted, but I have no idea which one.

So here is my question, fellow VUAs: Short of rebooting the computer, what can I do in order for a Devuan machine to able to print to a wireless printer (via CUPS) after the printer has gone through a network disconnect-reconnect?

Board footer

Forum Software