Sal Aguilar's Bilingual Adventures in IT

computers are easier to deal with than people

miniDLNA issues on MacOS Mojave (part 1) — November 13, 2018

miniDLNA issues on MacOS Mojave (part 1)


Last week I finally had some courage to update my Macbook to Mojave. The latest version of the MacOS family. The only thing I was really looking forward was the security updates and Dark Mode. Aside from that, it was unappealing to me.

Today, I downloaded some videos and wanted to fire up my minidlna local install only to find out that service was not working. None of my devices was able to see the DLNA service so I couldn’t stream to any TV.

I started investigating.  I did the basics, tried to restart, and services were launching fine.

➜ ~ brew services restart minidlna
Stopping `minidlna`... (might take a while)
==> Successfully stopped `minidlna` (label: homebrew.mxcl.minidlna)
==> Successfully started `minidlna` (label: homebrew.mxcl.minidlna)

Since everything seem fine, and still I couldn’t see the DLNA media. I went to the logs.

➜ ~ tail -100 /usr/local/var/log/minidlnad.log

I saw some errors which caught my attention. So I decided to remove it completely.

➜ ~ brew remove minidlna
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Uninstalling /usr/local/Cellar/minidlna/1.2.1_1... (11 files, 307.6KB)

And I saw the xcrun error, invalid active developer path? After quickly reviewing in Google this was due to the X Code Command Line tools that needed to be installed. It seems when Mojave was installed, the old X Code Command line tools were removed. Ok now we are getting somewhere. Now I would install that package. Again I went to my terminal and:

➜ ~ xcode-select --install

The package started downloading. It was about 130MB. Once it was installed I went and installed minidlna again.

➜ ~ brew install minidlna
==> Installing dependencies for minidlna: ffmpeg
==> Installing minidlna dependency: ffmpeg
==> Downloading https://homebrew.bintray.com/bottles/ffmpeg-4.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ffmpeg-4.1.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/ffmpeg/4.1: 282 files, 55.4MB
==> Installing minidlna
==> Downloading https://homebrew.bintray.com/bottles/minidlna-1.2.1_1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring minidlna-1.2.1_1.mojave.bottle.tar.gz
==> Caveats
Simple single-user configuration:

mkdir -p ~/.config/minidlna
cp /usr/local/opt/minidlna/share/minidlna/minidlna.conf ~/.config/minidlna/minidlna.conf
ln -s YOUR_MEDIA_DIR ~/.config/minidlna/media
minidlnad -f ~/.config/minidlna/minidlna.conf -P ~/.config/minidlna/minidlna.pid

To have launchd start minidlna now and restart at login:
brew services start minidlna
Or, if you don't want/need a background service you can just run:
minidlna
==> Summary
🍺 /usr/local/Cellar/minidlna/1.2.1_1: 11 files, 307.9KB
==> Caveats
==> minidlna
Simple single-user configuration:

mkdir -p ~/.config/minidlna
cp /usr/local/opt/minidlna/share/minidlna/minidlna.conf ~/.config/minidlna/minidlna.conf
ln -s YOUR_MEDIA_DIR ~/.config/minidlna/media
minidlnad -f ~/.config/minidlna/minidlna.conf -P ~/.config/minidlna/minidlna.pid

To have launchd start minidlna now and restart at login:
brew services start minidlna
Or, if you don't want/need a background service you can just run:
minidlna

Once it was re-installed. I tried to launch it once more.

➜ minidlna brew services start minidlna
==> Successfully started `minidlna` (label: homebrew.mxcl.minidlna)

It launched, again, with no error but still it wouldn’t work. Sighs. We have to keep digging. So I went to the logs again, on a bug hunting mission and found this:

[2018/11/13 20:04:46] minidlna.c:1048: warn: Starting MiniDLNA version 1.2.1.
[2018/11/13 20:04:46] minissdp.c:131: error: bind(udp): Address already in use
[2018/11/13 20:04:46] minidlna.c:1080: info: Failed to open socket for receiving SSDP. Trying to use MiniSSDPd
[2018/11/13 20:04:46] minissdp.c:84: error: setsockopt(udp, IP_ADD_MEMBERSHIP): Bad file descriptor
[2018/11/13 20:04:46] minissdp.c:189: warn: Failed to add multicast membership for address 192.168.1.137
[2018/11/13 20:04:46] getifaddr.c:338: info: Enabling interface 192.168.1.137/255.255.255.0
[2018/11/13 20:04:46] minissdp.c:830: error: connect("/var/run/minissdpd.sock"): No such file or directory[2018/11/13 20:04:46] minidlna.c:1083: fatal: Failed to connect to MiniSSDPd. EXITING%

Reviewing online on the minidlna site, they do suggest to try to install such software.
https://sourceforge.net/p/minidlna/support-requests/55/

Funny enough I found a link to my article on that link.

Right now I will keep reviewing and will come back later with an answer.

MacOS Improvements: Homebrew — November 13, 2017

MacOS Improvements: Homebrew


For those who have used any Linux distro like Debian or CentOS, you are pretty familiar with packet managers. But this is also for all those Mac newbies out there, basically a packet manager is:

… a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer‘s operating system in a consistent manner.

On Debian has APT and CentOS comes with YUM. Every IT Pro, SysAdmin or Dev knows how lovely packet managers are, and well since Apple never made one for MacOS, some one did and its amazing.

It’s called HOMEBREW and it brings the sweetness and ease of installing packages just like APT or YUM does on Linux.

How do you install HOMEBREW?

Open your favorite terminal app, either the one that comes with MacOS or my favorite iTerm2 and execute this command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 And that’s it. YES, IT’S THAT SIMPLE!

Now What?

Now you should update Homebrew and you do it with this command:

brew update

And you can install any program/software. On this example I’m going to install Apache, PHP 7, MySQL:

brew install apache2 php70 mysql

This will proceed to install all the required dependencies for each of the software we are installing and that are NOT currently installed on the server.

After it is installed all software is saved the following directory:

/usr/local/Cellar

Below is a snapshot of how my HomeBrew directory is currently:

1. salvador@RipeR81-MBP: :usr:local:Cellar (zsh) 2017-11-09 21-27-20

So start experimenting with HomeBrew today, and let me know if you need a hand!

Tweet at me @RipeR81

Oh-My-ZSH on MacOS Sierra — June 22, 2017

Oh-My-ZSH on MacOS Sierra


If you are a developer, coder, sysadmin or IT Pro I assume that you have used the terminal either on your Unix, Linux, Mac o Windows. And the shell that usually comes as default is the good old faithful BASH shell, which is nice but not cool.

What is Oh-My-Zsh?

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a other cool things.

Below are some facts about it:

  • More than 200 plugins. Enhance your productivity with plugins that integrate into git, google, youtube, sublime and much more.
  • More than 1000 contributors.  Since its Open Source, the code is available for free on GitHub and you can add your modifications, plugins and themes. Just submit your pull request!
  • More than 140. Don’t be a dull bird using the old BASH simple theme. Add colors and other functionalities by using any of the themes.

Still not convinced?

Check this screen captures:

And these are just some of the ways your terminal or console can look like. Pretty awesome right?

Now, how do I install Oh My ZSH on my Mac?

Dude, its a piece of cake. Just go to your Terminal or iTerm2

mac-terminal-1

And type:

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

This will do the entire process of installing all the required pieces to make it work. Once it finishes you can go ahead and customize the themes & plugins.

Picking a different theme

As default, Oh-My-ZSH comes with the theme default which is robbyrussell. But if you want to choose a different please go to the Themes page in GitHub. Choose the one you like the most and then use your favorite text editor (nano, vim, emacs, sublimetext or even textedit) to edit the file .zshrc located on your home folder. Below are the commands to open such file on nano & vim:

nano ~/.zshrc
vim ~/.zshrc

Then you will have to locate the string:

ZSH_THEME=robbyrussell

And change it to the theme that you selected, on this case I chose the theme called Blinks, so I went ahead and edited the .zshrc file and put this string instead of the one above:

ZSH_THEME=blinks

Then save the file and exit the editor. Please note that you will NOT see an immediate change on your current session. You would have to start a new terminal session to see the new theme applied there.

Now if you are a free soul like me, then you might want to set the value to random, that way each time you open the terminal you will experience a new theme until you find the one that you love the most. To enable this awesomeness simply use this string instead of the two previous ones:

ZSH_THEME="random"

Cool? Dude you know it is cool!

So, what about plugins?

Just like Themes, enabling and disabling plugins is done thru a text editor and your file .zshrc. You will need to look for the string:

plugins=(xxxx)

Where xxxx can be anything.

Since you are on Mac, I suggest all these plugins to be enabled:

plugins=(brew rails git ruby terminalapp sublime screen rvm perms osx history github encode64)

But there are several more, just go to the Plugins page on GitHub to learn about them all.

Please note that the same rule of the themes applies here, you will need to save the file and open a new session to see the plugins enabled.

So that is all folks. Start experimenting with Oh-My-ZSH and help the creator of this awesome shell by buying some swag for you and your friends!

Comment below if I missed anything! Thanks!

DLNA on Mac: The Ultimate Guide — February 24, 2016

DLNA on Mac: The Ultimate Guide


Well folks, many of you have read my article from Streaming from Mac OS X to a Roku Streaming Device and Stream Media from Debian to XBOX One, now it comes this guide, which is basically a different way of using DLNA on your Mac OS X (El Capitan).

Requirements

  • Mac OS X El Capitan
  • Internet access
  • Brew
  • Any DLNA capable device (Android device, Roku, Windows based computer, Playstation 4, XBOX or any SmartTV. The device needs to be on the same network as your Mac OS X computer.
  • Time, and willing to geek out!!

Step 1: Install Brew

Brew is the missing package manager for Mac OS X, it’s what aptitude is for Debian, yum for Red Hat based Linux distributions (RHEL, Fedora, CentOS, etc).It makes your life really easy if you are a developer or sysadmin. Install packages just like you would do on linux. Forget about downloading sources and compiling. This is the way to roll.

  1. Open your Terminal on your Mac OS X computer.
  2. Type the following command:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Wait for Brew to be installed. If it fails for any reason, please visit this link for further information.

Step 2: Install minidlna

On linux, we have minidlna which is a daemon used to share media contents in your network using DLNA. The daemon is now called ReadyMedia. The full description is:

ReadyMedia (formerly MiniDLNA) is server software with the aim of being fully compliant with DLNA/UPnP-AV clients.

  1. Once Brew is installed, go back to your terminal and get ready.
  2. Type the following command on your terminal to install minidlna:
    brew install minidlna
  3. This will download & install minidlna on your device. If you get any errors, then please run this command and then go back to step 2:
    brew update
  4. If minidlna installed without problems, move to the next step.

Some clarifications:

  • The software is installed on the folder /usr/local/Cellar/minidlna/x.x.x (x.x.x would be the version of minidlna installed.

Step 3: Setup minidlna sharing folders

This step is about to setup all the following: device name, folder where your media is stored and that you want to share across your network.

  1. Go back to your terminal.
  2. Open a text editor to modify the configuration file. So type the following command:
    nano /usr/local/Cellar/minidlna/x.x.x/share/minidlna/minidlna.conf
  3. Now customize your settings, please make sure that you customize the media_dir with the actual path where your media is stored, below is an example that you can use :
    friendly_name=Mac DLNA Server
    media_dir=/Users/salvador_aguilar/movies/

    Please note that you can name it what ever you’d like and the media_dir NEEDS to be an existing directory/folder on your computer so be sure to put the right path.

  4. Brew does not creates the symbolic links for minidlna to work well, so we are going to have to do this:
    ln -s /usr/local/Cellar/minidlna/x.x.x/sbin/minidlnad /usr/local/bin/minidlnad

    What you are doing here is basically creating a shortcut from our recently installed minidlna on the brew directory to our /usr/local/bin directly which is where most used commands are stored. In a few words to make your life easier. Less is more, enjoy!

  5. Launch minidlna with the following command:
    minidlna

    If you have OS X firewall turned on, then you will get a prompt that you will need to approve to give permission to minidlna to serve files on your network.

  6. Voilá! Now you can turn on your TV, XBOX, Android Device or any DLNA capable device that is connected to the same network as your Mac, and you should be able to see your Mac serving media files via DLNA.

    No need for Apple TV or any other Apple branded media devices. This will make your Mac talk to EVERYONE using a STANDARD that they have refused to use or implement! Bad Apple!

Let me know if you need a guide for a specific device, XBOX, Playstation, Roku, etc. I’m always eager for new challenges!


					
Avoid SSH Timeouts on the Mac Terminal — February 18, 2016

Avoid SSH Timeouts on the Mac Terminal


I admit it, I’m always with a lot of applications opened, Chrome with at least 6 tabs, Skype, Slack, PHPStorm or SublimeText, Airmail or Outlook for Mac, Photoshop and terminal.

I regularly login via SSH to VPS in Digital Ocean and AWS EC2 and then run some commands like:

wp plugin install wordfence

Then I go to the wordpress site and start adjusting the settings, but by the time I get back to the terminal (5 – 10 minutes), the SSH session is frozen, so I’m forced to open a new one. I honestly became tired of this, and I remembered that SSH was built on TCP and as such it should have some “Keep Alive” settings like on SIP (sorry I come from the call center world). And after some search online, I found that you can make this change both from the server side (SSHD: Secure SHell Daemon) or from your CLI (*nix, Linux & Mac).

Reduce SSH Timeouts from the server

Reduce SSH Timeouts from your computer

All you need to do is to setup your ssh client to send a “Keep Alive” signal to the server every certain amount of seconds. So you can add the following text to your ~/.ssh/config file:

Host remote-host
HostName remote-host.com
ServerAliveInterval 120

This basically tells your computer to send “keep alive” signals to remote-host.com every 120 seconds (2 minutes). That way the session will not get frozen for that server.

If you want to enable this for all of the hosts that you connect to, then simply add the following strings instead:

Host *
  ServerAliveInterval 120

This will setup the “keep alive” signal interval to 2 minutes for any host that you connect to via SSH.

After you finish editing the file, please make sure to change the permissions on the file using the following command:

chmod 600 ~/.ssh/config

And there you go, as simple as that! No more timeouts on my terminal app on my Mac OS El capitan MBP!

%d bloggers like this: