Category Archives: Command Line Hacks

Auto Added by WPeMatico

Jasper Image v1.5 Released

Major Updates

NOTE:  Be sure to do a “git pull” in the “Jasper-RPI-Tools” directory to get the updated scripts.

  • Installed Home-Assistant.io
    • Script to enable Home-Assistant.io Daemon
      • It is located /home/pi/Jasper-RPI-Tools/enable-hass-service.sh
    • Config under /home/hass/.homeassistant
    • Installed in Virtual Environment
    • Installed under the “hass” user.
  • Removed clutter from rc.local
    • Was causing harmless error at boot.
  • Installed needed dependencies for the development branch
    • libmad0 * libmad0-dev
  • Created/Enabled Service for jasper “jasper-daemon”
  • Created/Disable Service for Home-Assistant.io (user needs to enable)
  • Created Script to download a specified version of Jasper/Jasper-dev
    • It is located /home/pi/Jasper-RPI-Tools/installers/jasper-repo-installer.sh
      • You can pick what branch you would like to use at clone-time
  • Ensure phonetisaurus pre-compiled/installed
  • Removed Erroneous cron entries
  • Updated the OS and all related pkgs

Pre-Built Jasper Kits, Ready to go out of the box!

These kits will arrive and be ready to use the moment you power them up. They will be customized to the user, and an image will be provided so they can restore any time they like.

They will include the following:

  • RPI3 B+
  • 32GB Class 10 SD Card
  • US Robotics 9610 [USB Speaker/Mic]
  • Customized/Installed/Setup of Jasper by me personally
    • Install of Jasper and all dependencies
    • STT Setup
    • TTS Setup
  • Testing
    • Running overnight
    • With your settings if you wish
  • Copy of your personalized image for backup
    • In case you wish to restore to a “Known Good” state
  • Updates
    • Such as customized integrations and modules provided by me.
    • Updated Installer / Setup script COMING SOON.


If you are interested in one of these kits, feel free to contact me or start the process by purchasing one below:




New Community TTS Server! – Thanks Mycroft.ai!

It has been a little while; but the guys and gals at Mycroft.ai helped us (The Jasper Project) with a donated TTS (Text to Speech) server.  This has helped many of our users to get their projects working virtually out of the box.  Keep in mind Mycroft.ai does almost the same thing. We would almost be a competitor.  However, I do not see it that way.  We are open source and here to help each other out.

 

Thank you again to the guys at Mycroft.ai!

To those not familiar with them; here is a link to their Indigogo campaign.

Jasper Client Links

These are several links I have compiled, and/or created in the last few months. They can help you get Jasper going. I am also working on a full how-to for both RPI2 and RPI3.

  • Jasper-Support-Forums
    • Support forums, I help run these if you have any questions. Contact Me.
  • SLACK SIGN UP
    • Chat room for helping with Jasper
  • Jasper-Client
    • Official Jasper-Client
  • Jasper-RPI-Tools:
    • Set of tools I created in helping setup Jasper/RPI. They are a work in progress, so be sure to do a ‘git pull’ often.
  • RPI-Jasper-Dependencies:
    • Set of pre-compiled dependencies, that would normally take hours to compile. Tested on RPI2/3. Usually used for a non-Jasper image; as the images I created have them all installed.
  • ALSA Setup Wiki
    • Help with ‘.asoundrc’, and setting your default audio device
    • Usually the most common road block.
  • Home-Assistant.io: Home automation for the RPI, works very well. Working on integration on the same RPI; however it has dependency conflicts. Testing in pyenv soon…
  • How TO: Burning SD Card

Time Machine Backup with Ubuntu 15.x and OSX 10.7+

In the Older versions of this how-to, you will see people use the method shown just below.  Obviously that no longer works.  I will walk you through setting up TimeMachine via AFP over your LAN.  This is using an Ubuntu 15.04 machine; but since all the packages are common and in the base repos; I don’t see there being a problem getting it to work on any distro.

 OLD METHOD:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
NOTE: Any OSX after 10.6 Lion, will have to use the method demonstrated here.

 

Step 1: Install Netatalk

Install the following packages:

sudo apt-get install netatalk libc6-dev avahi-daemon libnss-mdns

Step 2: Configure /etc/nsswitch.conf

Once those packages are installed, we have to adjust 4 configuration files:

sudo nano /etc/nsswitch.conf

Locate the following:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

Add mdns  as below:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Step 3: /etc/avahi/services/afpd.service

sudo nano /etc/avahi/services/afpd.service

Paste the following:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_afpovertcp._tcp</type>
        <port>548</port>
    </service>
    <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=TimeCapsule</txt-record>
    </service>
</service-group>

Step 4: /etc/netatalk/AppleVolumes.default

Now we setup the share:

sudo nano /etc/netatalk/AppleVolumes.default

At the bottom the section that reads:

# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots

# By default all users have access to their home directories.
~/                      "Home Directory"

# End of File

Change the path “~/”  to your share directory.

IMPORTANT:  Don’t forget to add ‘tm’ to options:upriv,usedots
As seen below:

# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: cnidscheme:dbd options:upriv,usedots,tm

# By default all users have access to their home directories.
/path/to/share                       "Time Capsule"

# End of File

Step 5: /etc/default/netatalk

Now, we need to adjust netatalk settings.

sudo nano /etc/default/netatalk

Locate the following section:

#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
TIMELORD_RUN=no
A2BOOT_RUN=no

Update it to reflect the following:

#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

Once all is completed, and all the services have been restarted on the Ubuntu server.  The drive should show up under “Select Disk” under “Time Machine Preferences”.  If you have an old one, you may have to remove it.  Once selected you can use it as if it were physically plugged in.

 

*TIP – Use a wired connection only, and a gigE network will help immensely.  I do not recommend WiFi .

TCPDUMP with Date for Wireshark

Just another handy snippet:

It will date the output, and also put it in a handy pcap for Wireshark.

tcpdump -i eth1 -s0 -v -w /tmp/capture_`date +%d_%m_%Y__%H_%I_%S`.pcap

*Note: Should work on all Linux distros (make sure to have the right network interface selected, Ex: eth1); it might have to be slightly modified for Mac. Windows can go DIAF.

 

Search entire server for Q4 2015 obfuscated PHP malware of unknown origin.

This is just a snippet I have used before to identify some malicious code on web servers.  This will not work on everything; but it will give you a way to find suspect files.  It is easy to cron in a script with others to make a nice daily report if you have those concerns.

#!/bin/bash
# Malware Search Script
# 11/1/15 – Matthew D. Curry
# Matt@MattCurry.com

echo “Search entire server for Q4 2015 obfuscated PHP malware of unknown origin.”

find / -name *.php -exec grep -Hn .1.=…….0.=…….3.=…….2.=…….5.= {} ;

 

Hope this helps, enjoy.

Remove Spaces (or any character) from File Names in Linux

This is actually a pretty common thing to run into in a Linux file system.  It is especially prevalent in the files that are moved from another operating system (Usually Windows).  So if you get files that need to have a space or a character removed, the below snipped is a very simple, and handy way to fix this issue.

└─(11:26:40)-(~/Example)->ls
file 1.txt
file – 2.txt

So, from here we want to rename the file “file 1.txt” to “file_1.txt”.  This would be done as follows:

rename ‘s/ /_/g’ file 1.txt

This will remove any spaces in the file-name listed.  If you want to do all the files in a directory:

rename ‘s/ /_/g’ *

Here is an example output if we run it on all the files in the directory (as seen above):

└─(11:33:59)-(~/Example)->ls
file_1.txt
file_-_2.txt

 

Note:  If you are new to Linux; and you haven’t heard of the “sed” command, that is the syntax used in the command.  If you get comfortable with this, then you can easily learn sed, which is a great tool to have on the command line.