Raspberry pi2 model B, "Access Point, hostapd" setup issue - raspberry-pi2

Working with Raspberry Pi2, ModelB with below configurations:
$ uname -a
Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l GNU/Linux
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
I have a MediaTek usb-adapter as below:
$ lsusb | grep 76
Bus 001 Device 004: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
When trying to start "hostapd" for creating access-point, the below error is reported:
$ sudo /usr/local/bin/hostapd -ddd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
Line 2: invalid/unknown driver 'mt7601u'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'
However, the driver does exist,
$ ls /lib/modules/4.9.59+/kernel/drivers/net/wireless/mediatek/mt7601u
-rw-r--r-- 1 root root 126932 Oct 30 14:36 mt7601u.ko
Can someone please help point out what is going wrong here ? why is it not able to find the driver ?

Related

Arch Linux arm Xorg doesn't display anything on Raspberry Pi 3 when running startx

On my raspberry pi 3 i have Arch Linux Arm Installed. I installed xorg, i3, and all of the drivers for it. i have my xinitrc file set up like default to run i3:
#!/bin/sh
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
xrdb -merge "$userresources"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
exec i3
when I run sudo startx i get this output
X.Org X Server 1.21.1.4
X Protocol Version 11, Revision 0
Current Operating System: Linux archpi 5.15.68-2-rpi-ARCH #1 SMP Mon Sep 19 17:23:23 MDT 2022 armv7l
Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1920x1080M#60 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 root=/dev/mmcblk0p2 rw rootwait console=ttyS0,115200 console=tty1 fsck.repair=yes
Current version of pixman: 0.40.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Thu Sep 22 04:48:27 2022
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
Failed to connect to bus: No medium found
dbus-update-activation-environment: error: unable to connect to D-Bus: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead
[libi3] ../i3bar/src/main.c i3bar version 4.20.1 (2021-11-03)
[libi3] ../libi3/font.c Using Pango font monospace, size 8
[libi3] ../libi3/font.c Using Pango font monospace, size 8
i3status: trying to auto-detect output_format setting
i3status: auto-detected "i3bar"
[libi3] ../libi3/font.c Using Pango font monospace, size 8
the error is in Failed to connect to bus: No medium found dbus-update-activation-environment: error: unable to connect to D-Bus: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead
I have looked for hours and can not find a way to fix this. After running sudo startx My screen just goes dark and I have to reboot. I appreciate any help give, thanks.

Systemd service using screen: 'No screen session found'

I'm trying to setup a minecraft server for my kid and screen is giving me fits. I've been following this tutorial and I've already consulted this AskUbuntu answer. I'm running on Ubuntu 16.04.5 x64. I have created the following Service file and linked it to /etc/systemd/system/minecraft.service.
[Unit]
Description=Minecraft Server
Documentation=
Wants=network.target
After=network.target
[Service]
User=minecraft
Group=minecraft
Nice=5
EnvironmentFile=-/var/minecraft/unit.conf
KillMode=none
SuccessExitStatus=0 1
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessibleDirectories=/root /sys /srv -/opt /media -/lost+found
ReadWriteDirectories=/var/minecraft/server /usr/bin/screen
WorkingDirectory=/var/minecraft/server
#ExecStartPre= /usr/bin/screen -dmS Minecraft
ExecStart= /usr/bin/screen -dm -S Minecraft '/usr/bin/java -Xmx1500M -Xms1024M -jar /var/minecraft/server/craftbukkit-1.13.jar'
ExecStop=/usr/bin/screen -S minecraft -p 0 -X stuff "stop^M"
[Install]
WantedBy=multi-user.target
When I monitor the service startup, I get the following in the journalctl logs:
Aug 05 14:55:41 spigot-1 systemd[1]: Started Minecraft Server.
Aug 05 14:55:41 spigot-1 screen[9869]: No screen session found.
Per the SO post I referenced, I already changed the permissions in /var/run/screen. This is the current setup:
root#spigot-1:/var/minecraft/server# ls -alR /var/run/screen/
/var/run/screen/:
total 0
drwxrwxrwx 4 root root 80 Aug 5 14:12 .
drwxr-xr-x 23 root root 860 Aug 5 14:11 ..
drwx------ 2 minecraft minecraft 40 Aug 5 14:55 S-minecraft
drwx------ 2 root root 40 Aug 5 14:50 S-root
/var/run/screen/S-minecraft:
total 0
drwx------ 2 minecraft minecraft 40 Aug 5 14:55 .
drwxrwxrwx 4 root root 80 Aug 5 14:12 ..
/var/run/screen/S-root:
total 0
drwx------ 2 root root 40 Aug 5 14:50 .
drwxrwxrwx 4 root root 80 Aug 5 14:12 ..
** Debug Notes **
You'll see the commented ExecStartPre command in there... all that happens if I try to start the screen session with that command is I get a second 'No screen session found' error.
I can launch the server from the command line using 'screen -dmS Minecraft [..]' and reattach. I can do this both as root and as the 'minecraft' user.
Any help would be greatly appreciated
I don't have Ubuntu to hand, but I tried something similar on Fedora 24 and had a similar error. To investigate I added an strace to the screen command and removed PrivateTmp so that I could get the trace output.
ExecStart=/bin/strace -o /tmp/s -f screen -dm -S me bash -c 'sleep 999'
In the output I found that at the end, screen was trying to open a pseudo-tty and failed to do so:
open("/dev/ptmx", O_RDWR) = -1 EACCES (Permission denied)
...
write(1, "No more PTYs.\r\nSorry, could not "..., 52) = 52
I added some ls -l /dev commands to the Unit to see what the effect of the PrivateDevices=true option had been. There was indeed a /dev/ptmx file, but unlike my real /dev it was a symbolic link to /dev/pts/ptmx, instead of just being the special character device. For some reason on my system I have:
$ ls -l /dev/ptmx /dev/pts/ptmx
crw-rw-rw- 1 root tty 5, 2 Aug 6 14:29 /dev/ptmx
c--------- 1 root root 5, 2 Jun 27 08:29 /dev/pts/ptmx
(This is probably a bug depending on the version of systemd and udev.)
So when /dev/ptmx is replaced in the private namespace by a symbolic link to /dev/pts/ptmx, you can no longer open a new pty. A simple fix for testing was sudo chmod a+rw /dev/pts/ptmx which indeed made the Unit work and start the screen process.
This may not be the case for you, but you could undertake a similar debug method to try to find the problem.

Homebrew: how to remove redis/4.0.2 and use redis#3.2 as my default redis

I started this quest with redis/3.0.3 installed, and looking to upgrade my local dev redis to version 3.2.3, which is what we're running in production. I ultimately ran brew upgrade redis, which installed redis 4.0.2, ahead of my desired version. Then I found that you can install 3.2.x with brew install redis#3.2. Also, while trying to cleanup 4.0.2, instead it cleaned up only 3.0.3.
Now I'm stuck in a situation where Homebrew won't allow me to uninstall redis/4.0.2, and views redis#3.2 as a separate Homebrew Formula.
$ brew switch redis 3.2
Error: redis does not have a version "3.2" in the Cellar.
Versions available: 4.0.2
See how in the Cellar, they're showing as separate Formulae here:
$ ls /usr/local/Cellar/ | grep redis
redis
redis#3.2
What is the correct "Homebrew" way to remove redis/4.0.2 and use redis#3.2 as my default redis, so that commands to redis-server and redis-cli reference 3.2 instead? I'm running Mac OS X Yosemite 10.10.5 and Homebrew 1.3.4.
$ ls -l /usr/local/bin/ | grep redis
lrwxr-xr-x 1 jsoro wheel 41 Oct 5 12:51 redis-benchmark -> ../Cellar/redis/4.0.2/bin/redis-benchmark
lrwxr-xr-x 1 jsoro wheel 41 Oct 5 12:51 redis-check-aof -> ../Cellar/redis/4.0.2/bin/redis-check-aof
lrwxr-xr-x 1 jsoro wheel 41 Oct 5 12:51 redis-check-rdb -> ../Cellar/redis/4.0.2/bin/redis-check-rdb
lrwxr-xr-x 1 jsoro wheel 35 Oct 5 12:51 redis-cli -> ../Cellar/redis/4.0.2/bin/redis-cli
lrwxr-xr-x 1 jsoro wheel 40 Oct 5 12:51 redis-sentinel -> ../Cellar/redis/4.0.2/bin/redis-sentinel
lrwxr-xr-x 1 jsoro wheel 38 Oct 5 12:51 redis-server -> ../Cellar/redis/4.0.2/bin/redis-server
The issue was trivial and could have been easier if the Brew Docs/FAQs were more clear. The Brew FAQs say that uninstalls are handled by brew cleanup <formula>, which is what caused my redis/3.0.3 to be removed. However, brew cleanup would not remove redis/4.0.2. To remove it I used brew uninstall, which I could not find in the Docs...
$ brew uninstall redis
Uninstalling /usr/local/Cellar/redis/4.0.2... (11 files, 2.7MB)
Then, to fix the remaining issue of redis#3.2 not being symlinked under /usr/local/bin/, I first tried an uninstall/re-install of redis#3.2 to see if Homebrew would take care of it...
$ ls -l /usr/local/bin/ | grep redis
$ brew uninstall redis#3.2
Uninstalling /usr/local/Cellar/redis#3.2/3.2.11... (11 files, 1.7MB)
$ brew install redis#3.2
==> Downloading http://download.redis.io/releases/redis-3.2.11.tar.gz
## TRIMMED ##
==> Summary
🍺 /usr/local/Cellar/redis#3.2/3.2.11: 11 files, 1.7MB, built in 10 seconds
Of course, this did not create the symlinks--actually the Caveats section which I trimmed away from the output says this explicitly with suggestions. Instead of using their suggestion, I opted to create symlinks manually:
$ cd /usr/local/bin/
$ ls -l | grep redis
$
$ ln -s /usr/local/Cellar/redis\#3.2/3.2.11/bin/redis-check-aof redis-check-aof
$ ln -s /usr/local/Cellar/redis\#3.2/3.2.11/bin/redis-check-rdb redis-check-rdb
$ ln -s /usr/local/Cellar/redis\#3.2/3.2.11/bin/redis-cli redis-cli
$ ln -s /usr/local/Cellar/redis\#3.2/3.2.11/bin/redis-sentinel redis-sentinel
$ ln -s /usr/local/Cellar/redis\#3.2/3.2.11/bin/redis-server redis-server
$ ls -l | grep redis
lrwxr-xr-x 1 jsoro wheel 54 Oct 5 14:27 redis-check-aof -> /usr/local/Cellar/redis#3.2/3.2.11/bin/redis-check-aof
lrwxr-xr-x 1 jsoro wheel 54 Oct 5 14:27 redis-check-rdb -> /usr/local/Cellar/redis#3.2/3.2.11/bin/redis-check-rdb
lrwxr-xr-x 1 jsoro wheel 48 Oct 5 14:27 redis-cli -> /usr/local/Cellar/redis#3.2/3.2.11/bin/redis-cli
lrwxr-xr-x 1 jsoro wheel 53 Oct 5 14:27 redis-sentinel -> /usr/local/Cellar/redis#3.2/3.2.11/bin/redis-sentinel
lrwxr-xr-x 1 jsoro wheel 51 Oct 5 14:26 redis-server -> /usr/local/Cellar/redis#3.2/3.2.11/bin/redis-server
The last thing to note is that since I had run the redis-server while under the redis/4.0.2 version, the dump.rdb file was no longer compatible. Running redis-server using redis 3.2.x on a 4.x dump.rdb causes the server to exit immediately.
$ redis-server
## TRIMMED ##
38504:M 05 Oct 14:29:07.234 # Server started, Redis version 3.2.11
38504:M 05 Oct 14:29:07.259 # Can't handle RDB format version 8
38504:M 05 Oct 14:29:07.260 # Fatal error loading the DB: Invalid argument. Exiting.
Unfortunately you need to rm dump.rdb, or remove/rename the dump.rdb file, in order to get redis-server to start up again.

Can't access ttyACM device in mode 0660

I want to be able to read and write ttyACM device, particularly Arduino Leonardo board under Fedora.
I made a following rule:
SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", SYMLINK+="arduino", MODE="0660", GROUP="plugdev"
Symlink is created but I do not have permission to read the device:
[nexy#shire ~]$ cat /dev/arduino
cat: /dev/arduino: Permission denied
Showing ls gives the following:
[nexy#shire ~]$ ls -l /dev/arduino /dev/ttyACM0
lrwxrwxrwx. 1 root root 7 Dec 18 15:25 /dev/arduino -> ttyACM0
crw-rw----. 1 root dialout 166, 0 Dec 18 15:25 /dev/ttyACM0
When I change mode to 0666 then it works. I belong to the group plugdev:
[nexy#shire ~]$ sudo groups nexy
nexy : nexy wheel plugdev
You might have to log out and log back in or restart your computer if you just added yourself to the group recently.

expect with cron not as manually

backup.sh has :
#!/bin/bash
expect backup.exp
tr -d '\15\32' < backup.templog > backup.log
backup.exp has next content:
#!/usr/bin/expect -f
puts "----------------- [exec date +%Y.%m.%d\ %H:%M:%S] ------ exp start -----\n"
spawn ssh root#someIP2
expect "# "
send "su - postgres\r"
expect "\$ "
send "ls -lh db.dump.gz\r"
send exit\r
send exit\r
interact
when I run manually like next:
bash backup.sh >> backup.templog 2>&1
I get next, which I like:
spawn ssh root#someIP
Linux db01 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Sep 2 11:06:02 2015 from someIP2
root#db01:~# su - postgres
postgres#db01:~$ ls -lh /var/lib/postgresql/db.dump.gz
-rw-r--r-- 1 postgres postgres 218M Sep 2 10:39 /var/lib/postgresql/db.dump.gz
postgres#db01:~$ exit
logout
root#db01:~# exit
logout
Connection to someIP2 closed.
but with cron (has a line):
* * * * * bash backup.sh >> backup.templog 2>&1
I get only next:
spawn ssh root#someIP2
Linux db01 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Sep 2 11:04:13 2015 from someIP1
root#db01:~# su - postgres
postgres#db01:~$
Can I get the same with cron and manually?