Getting VLC to work with Celestron Digital Microscope on Manjaro

I’ve run into problems getting VLC to work with miscellaneous devices on Manjaro and I believe I’ve finally figured out that some of the dependencies to the plugins weren’t getting installed. Here is how I figured this out.

Runningvlc v4l2:///dev/video0

Gives the error about “VLC is unable to open the MRL…”

Make sure your user is a member of the “video” group. If so, then run VLC in debug mode: vlc v4l2:///dev/video0 --extraintf=http:logger --verbose=2 --file-logging --logfile=vlc-log.txt

In my vlc-log.txt log file there is was a line that indicated that the libv4l2 was not loading due to a dependency issue (you will probably find lots of other dependencies that could also be fixed). The specific line was:

main warning: cannot load module `/usr/lib/vlc/plugins/access/libv4l2_plugin.so' (libzvbi.so.0: cannot open shared object file: No such file or directory)

I then searched for that specific file with:

pacman -F libzvbi.so.0
extra/zvbi 0.2.35-3
usr/lib/libzvbi.so.0

Then simply installed it with sudo pacman -S zvbi

Now opening vlc v4l2:///dev/video0 works and I can use my Celestron USB Microscope.

Automate Bacula Restore for Testing Backups

As per my standard operating procedure, I would rather spend a week scripting something than spend one extra minute doing anything twice. Testing restores from backup jobs is something that everyone hates to do, but hopefully recognizes the criticality of such tasks, else performing backups is nearly pointless. Bacula Enterprise is a great backup/restore product (and their support is AMAZING!). Given that it is Linux based, scripting many common tasks becomes a simple concept using common Linux tools.

bconsole (the administrative interface for Bacula) commands can be automated with simple expect scripts. Below is the expect script that I created which will automate the restore of a VM to a dev ESXi host. There is another shell script executed out of cron that randomly picks a VM from the list of VM’s that have been backed up and then executes the following with an argument.

#!/usr/bin/expect -f 

set ServerToRestore [lindex $argv 0]
set timeout -1
spawn /usr/bin/bconsole

expect "\\*"
send  "restore client=10-srv-fd01 fileset=$ServerToRestore where= current select all done\r"
expect "OK to run? (yes/mod/no):"
send  "mod\r"
expect "Select parameter to modify (1-13): "
send  "13\r"
expect "Use above plugin configuration? (yes/mod/no):"
send  "mod\r"
expect "Select parameter to modify (1-7): " 
send "1\r"
expect "Please enter a value for datastore: "
send "datastore2\r"
expect "Use above plugin configuration? (yes/mod/no):"
send  "mod\r"
expect "Select parameter to modify (1-7): "
send "2\r"
expect "Please enter a value for restore_host: "
send "10-dev-vm03.domain.com\r"
expect "Use above plugin configuration? (yes/mod/no):"
send  "mod\r"
expect "Select parameter to modify (1-7): "
send "4\r"
expect "Please enter a value for vsphere_server: "
send "10-dev-vm03\r"
expect "Use above plugin configuration? (yes/mod/no): "
send "yes\r"
expect "OK to run? (yes/mod/no):"
send  "mod\r"
expect "Select parameter to modify (1-13): "
send  "7\r"
expect "Enter new Priority: "
send  "15\r"
expect "OK to run? (yes/mod/no): "
send "yes\r"
expect "\\*"
send "quit\r"
exit

Each morning someone on my team validates the restore and documents the successes and failures and, if necessary, creates a ticket to determine the cause of any such failure.

Automate WPA2 passphrase change on Cisco AP

I recently needed to provide wireless Internet access to Spektrum transmitters so updates could be applied while the transmitters are in for repair. These devices were not working reliably with the existing UniFi Guest Wireless/Portal and the transmitters do not seem able to connect using WPA2-Enterprise authentication. Due to security concerns, I did not want to provide a permanent WPA2 passphrase for ongoing use so I decided to use bash, clogin and cron to create a function that would change the passphrase daily.

I grabbed the first bit of code from Mike Willis’ blog which randomly picks a predefined number of words from a specified wordlist file. I found an acceptable wordlist without special characters from EFF’s site (although it would bee been a better password to use all characters, I didn’t want users to have to enter special characters on the transmitter touch screen). I proceeded to make a few changes to Mike’s script so that the script would only select words that were less than 4 characters and added random digits to the end of the randomly chosen word. After picking a random word and adding 4 digits the script writes the requisite Cisco commands for changing the passphrase to an external file. clogin finishes the process by simply running the IOS commands against the Cisco AP after automatically logging in via SSH (the credentials are stored in the .cloginrc file). If all goes well an email is sent out notifying the users of the new password (if a failure occurs the script sends me an email). Adding the script to crontab makes the process happen every night without any IT intervention.

#!/bin/bash

WORDFILE="/opt/ResetServiceCenterAPPassword.wordfile"
NUMWORDS=1
EMAILLIST="[email protected] [email protected]"

tL=`awk 'NF!=0 {++c} END {print c}' $WORDFILE`
poorchoice=1

while read -r line; do
  while [[ $poorchoice = 1 ]]; do
    rnum=$((RANDOM%$tL+1))
    pword=$(sed -n "$rnum p" $WORDFILE)
    if [[ ${#pword}  > 5 ]]; then
      poorchoice=1
    else
      poorchoice=0
    fi
    pword=$pword$(shuf -i 2000-9999 -n 1)
  done
done < <(echo $WORDFILE)

echo "conf t
dot11 ssid Spektrum
wpa-psk ascii 0 $pword
exit
exit" > /opt/ResetServiceCenterAPPassword.cmds

/opt/clogin -x /opt/ResetServiceCenterAPPassword.cmds <Access Point IP>
status=$?

if [ $status = 0 ]; then
  echo "Spektrum transmitter WiFi password changed to $pword" | mail --append="FROM:IT <[email protected]>" [email protected] -s
"Spektrum transmitter WiFi password changed to $pword EOM" $EMAILLIST
else
  echo "Error with /opt/ResetServiceCenterAPPassword.sh script" | mail --append="FROM:IT <[email protected]>" [email protected] -s "Error with /opt/ResetServiceCenterAPPassword.cmds" [email protected]
fi