So, after I met problems with iwlwifi driver and my attempts to aggregate both em0 and wlan0 interfaces to the one lagg0 interface (https://mastodon.bsd.cafe/@evgandr/115985853500057386) — looks like I found a much (MUCH!) simpler solution 

I wanted to automatically switch between wired and wireless networks when I plug-in (or disconnect) my Ethernet cable. First, because I was a newbie in the FreeBSD world, I tried to search for some kind of NetworkManager. Thankfully, I didn't find any NetworkManager clone ported to the FreeBSD. I found some tries to port NetworkManager from Linux to FreeBSD but all of them are failed (not surprised, lol).

Then, I finally started to read documentation  . In the section about advanced networking I read about aggregation interfaces. And somehow I managed to aggregate both of em0 and wlan0 to the one lagg0 interface and it works well.

But, looks like (see https://mstdn.social/@erikarn/115986265106931691) it is not the way how the lagg interfaces should work. It is not intended to use wireless interfaces in the aggregate interfaces — so my tricky setup stopped working in the FreeBSD 15.0.

BUT, since we have a beautiful devd daemon, which listens for various system events and able to execute actions when event is happened — I just wrote 23 lines of shell script to learn my laptop how to switch between interfaces when the Ethernet cable (dis)connects, lol. Solution is very simple:

First, we already have /etc/devd/dhclient.conf, which starts dhclient when some interface appeared in the system. I modified it, so it calls the sPeCiAL script, each time when em0, or wlan0, or ue0 interface appeared in the system, or when em0 is disappeared:

notify 0 {
match "system" "IFNET";
match "type" "LINK_UP";
media-type "ethernet";
action "/root/bin/unfuck_network.tcsh $subsystem ifup";
};

notify 0 {
match "system" "IFNET";
match "type" "LINK_DOWN";
media-type "ethernet";
action "/root/bin/unfuck_network.tcsh $subsystem ifdown";
};

notify 0 {
match "system" "IFNET";
match "type" "LINK_UP";
media-type "802.11";
action "/root/bin/unfuck_network.tcsh $subsystem";
};

notify 0 {
match "system" "ETHERNET";
match "type" "IFATTACH";
match "subsystem" "ue0";
action "/root/bin/unfuck_network.tcsh ue0";
};

Then, the main magic happens in the /root/bin/unfuck_network.tcsh:
— When Ethernet cable is connected — it destroys the wlan0 interface and starts dhclient for em0 to talk with DHCP server.
— When Ethernet cable is disconnected — it makes all to remove route using em0 from routing table (removes em0 interface completely, flush routing table, etc — somehow em0 still stays in the routing table if interface is not destroyed; btw system will create it anyway later, in some point) and recreates the wlan0 interface.
— When wlan0 device is created — it starts dhclient for it.

Script contents (for tcsh):
#!/bin/tcsh

switch ( $1 )
case "em0":
if ( $2 == "ifup" ) then
service netif quietstop wlan0
service dhclient quietstart em0
else if ( $2 == "ifdown" ) then
service dhclient quietstop em0
ifconfig em0 delete
route flush
service routing restart
service netif quietstart wlan0
endif
breaksw;
case "wlan0":
service dhclient quietstart wlan0
breaksw;
case "ue0":
service dhclient quietstart ue0
breaksw;
endsw

#FreeBSD #FreeBSD150RELEASE #wifi #tcsh #devd #iwm

Eugene :freebsd: :emacslogo: (@evgandr@bsd.cafe)

Attached: 1 image Huh, looks like I hurried to sign praises for iwlwifi in the FreeBSD 15.0 :drgn_sigh: With wlan0 (Intel Dual Band Wireless-AC 8260) added to the aggregate interface lagg0, I receive "general protection fault while in kernel mode" if laptop booted with connected Ethernet cable, or if I connect the cable after the system boot. #FreeBSD #FreeBSD150RELEASE #iwlwifi

BSD.cafe Mastodon Portal

@lea 🤢 🤮 #Windows!

  • I'd rather use #tcsh or OG Unix #shell than ever touching cmd.exe again in my life!

#sarcasm #commentary

Preparing an engineering-focused presentation entitled "The Zen of Shell Scripting" for an internal talk at work. Question for seasoned Shell programmers: What would you have liked to know when you first started out? Interested in both big ideas and sharp edges that come with Shell scripting.

#shell #unix #linux #posix #bash #zsh #tcsh #ksh #fish

#Lesson of the day: I waste time searching for a solution #online, then ask #AI, which gives me “wonderful” but completely wrong results. In the end, I read the official #documentation and solve it in a few seconds:

1. https://man.freebsd.org/tcsh/1 > 2. Ctrl-f > 3. type "redirect" > 4. "The shell cannot presently redirect diagnostic output without also redirecting standard output, but `(command > output-file) >& error-file' is often an acceptable workaround. ..."

#Documentation #UNIX #FreeBSD #Shell #scripting #terminal #tcsh #fixing

tcsh(1)

Serious question for CLI users.

Do you think it’s insane to use an interactive shell and to code your scripts for a totally different shell?

#shell #unix #linux #bash #sh #fish #tcsh #csh #cli

yes of course, that’s insanity
15.8%
no and there is a good reason to do so
84.2%
Poll ended at .

If I've never seen the codebase, which #Linux shell has the easiest code to read and understand? Specifically I want to isolate the code for *parsing* the command line syntax.

All #POSIX-compliant (or close enough) shells welcome! I probably don't know them all but off the top of my head:

#bash
#dash
#fish (sorry for the spam, marine life enthusiasts)
#zsh
#ksh
#tcsh & #csh I think?

#shell #shells #foss #code #commandline

#Poll: Curious about people's attitudes towards shell scripting.

Two part question:

  • Are you a DEVeloper (or working in a development-heavy role), OTHER-IT worker (such as a sysadmin, architect, anything in a non-development-heavy role), or NON-IT (accountant, doctor, whatever)
  • Do you HATE shell scripting, are you INDIFferent towards (or ignorant of) shell scripting, or do you LOVE it?
  • #Unix #UnixShell #ShellScript #ShellScripting #POSIX #PosixShell #sh #bash #zsh #csh #tcsh #ksh #pdksh #oksh #mksh

    dev - hate
    10.4%
    dev - indif
    15.6%
    dev - love
    22.9%
    other-it - hate
    2.1%
    other-it - indif
    9.4%
    other-it - love
    24%
    non-it - hate
    1%
    non-it - indif
    7.3%
    non-it - love
    7.3%
    Poll ended at .
    I just upgraded #OpenBSD from 7.1 all the way up to 7.7 one release at a time in a #KVM VM running on my laptop #Debian. At first #tcsh and #vim were giving coredumps. I realized I did not even run #pkg_add even once so I did a doas pkg_add -u. After that all is fine and everything was like before. #OpenBSD is truely awesome!

    #BSD #UseBSD #RunBSD #unix #FOSS

    @wolf480pl @cas it's easy...

    The reasons one can despise something and the reason one appreciates it can be different.

    I.e. I can appreciate #macOS for it's #accessibility right from the #installer but I can #despise it for #Apple not selling it as a commercial #Unix distro for a #subscription

    Same with #bash: I can appreciate it for being better than #sh (unix-#shell) , #tcsh or #csh but I despise it for not having modernized like #fish.

    It's called having "mixed feelings" or rather #NuancedOpinion.

    fish shell

    A smart and user-friendly command line shell

    I'll add a screenshot or two at the later point in time since I'm letting that machine do something very nice in a set of important processes

    .🖋️ #bash #sh #zsh #ksh #csh #tksh #fish #tcsh  #lolcat  #currentComputing #Colours #POSIX  #fresh #programming