Home Blog Page 656

Build Your Own Netflix and Pandora With Raspberry Pi 3

Do you have a huge collection of movies, TV shows, and music that you purchased over the years but it’s collecting digital dust on your hard drives? How about creating your very own Netflix- and Pandora-like setup using the free Plex Media Server software? No, you don’t have to buy an expensive, bulky PC. All you need is a Raspberry Pi 3, a hard drive, an SD card and a mobile charger. It should all cost less than $100.

What you need:

  • PC or laptop

  • Raspberry Pi 3

  • Micro SD card

  • A powered hard drive

  • 5v 2A power supply for Pi

  • Monitor, HDMI cable, keyboard and mouse (only for initial setup)

  • I also recommend a heat sink for Pi chips as multimedia consumption does make them hot

  • Ethernet cable (optional)

I will be using it in a headless manner, but we do need a monitor with an HDMI cable for initial setup.  On your PC/laptop, download the ‘NOOBS’ distribution installer from the official site. It’s a zip file, which you’ll extract using the unzip command.

Insert the Micro SD card and format it as FAT32 using Gnome Disk Utility.

gztF3kGsoByxxfjYXA_D-hfRAiwxGF1CqjNnb155

Then, change directory to the Micro SD card:

cd /path_of_USB

And unzip the NOOBS file into the Micro SD card:

unzip PATH_OF_NOOBS

In my case it was:

unzip /home/swapnil/Downloads/NOOBS_v1_9_2.zip

Just ensure that all the content of the NOOBS folder is in the root directory of the Micro SD card.

Now plug the monitor, keyboard and mouse into the Pi, insert the Micro SD card and connect the power supply. The system will boot up to NOOBS where you can choose the operating system you want to install. Choose Raspbian. Once the installation is finished, it will reboot into your brand new Raspbian OS. It will also automatically resize the file system to use all available space on the SD card.

If you can use an Ethernet cable, I would recommend that because it will give you faster speed compared to the WiFi on board. If not, then use the WiFi utility in Raspbian to connect to the wireless network. Once you are online, open the terminal and run the following command to find the IP address of your Pi:

if config

Once you have the IP address, open the terminal on your PC/laptop and ssh into your Pi:

ssh pi@IP_ADDRESS_OF_PI

The default password for the Pi is raspberry. If you want to change the password, run the following command and enter the new password after the prompt:

passwd pi

Now let’s update the system before we install Plex. This is a best practice for all fresh distro and software installations

sudo apt-get update

sudo apt-get dist-upgrade

Once updated, connect the external hard drive to your Pi using one of the USB ports. It’s best to use a hard drive that has been formatted in the ext4 file system for better compatibility with Linux. Mount it and create an entry in the ‘fstab’ so that it auto mounts between reboots.

Now it’s time to install Plex Media Server. We are using packages created by a third-party developer so let’s add their GPG key:

wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key  | sudo apt-key add - 

Now add repos to the source list file:

echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list

Now update the system:

sudo apt-get update

And then install Plex Media Server:

sudo apt-get install -t jessie plexmediaserver -y

Now run it:

service plexmediaserver star

That’s it. You have Plex Media Server running on your Raspberry Pi 3.

Set up your media server

Plex Makes it extremely easy to set up your Plex Media Center. Now you need to point your Plex Media Center towards the media files: movies, music, and TV shows. You can do it from any PC in your local network. Just type this address into a web browser, filling in your own Pi’s IP address:

IP_ADDRESS_OF_PI:32400/web/index.html#

In my case it was:

10.0.0.26:32400/web/index.html#

This will open the Plex Media Server interface. The greatest feature of Plex is metadata that it pulls from the internet and attaches to your media files. But it’s extremely important to categorize your media otherwise Plex won’t detect it. So create these folders on your hard drive and store appropriate media inside the folders: movies, tv_shows, music, home_videos, photos.

Now copy movies to the movies folder, TV shows to the tv_shows folder, any videos that you take from your phone or camera to home_video folder, and so on. If you copy TV shows or home videos to movies or vice versa, those files won’t show up on Plex and you won’t be able to play them.

Once you have taken care of your media files, open the movie tab on the Plex Media Center interface and browse to add the movies folder from your hard drive. Repeat the step for each media type. Once done, give Plex some time to scan and process those files.

eEAS8rVfeHCjfwrG6m4StFGLCsBYG9MYfUp2s4k3

Another interesting thing that you can do with your Plex is add online video channels such as CNN, PBS, and History.… Just go to the ‘Channels’ option and install channels that you like. Now all of these channels, in addition to your movies, tv shows, music and photos are accessible through your Plex server running on the Pi.

w5N1FC1GJEqk2PlUcc2VyXBX9VakE3SZ4Yal7wjR

Access your Plex Media Server

There are many ways to access your Plex Media Center:

1. If you are on the local network open this URL in the web browser:

IP_ADDRESS_OF_PI:32400/web/index.html#

In my case it was:

10.0.0.26:32400/web/index.html#

It will open the Plex Media Player interface, just log into your media server and start playing content. You can also manage your Plex Media Server from this interface.

2. You can access your Plex Media Server from mobile devices using the official Plex app that’s available for both Android and iOS.

3. Or you can set up a Plex Media Player device (such as RasPlex) and turn any HDMI-enabled TV into your very own entertainment system. (See the next tutorial on how to do this!)

If you want to be able to access Plex outside of your home network then you can purchase PlexPass which allows you to stream your content across devices over the Internet. Because Plex also remembers playback history and where you are in any content, you can also add family members, just like Netflix, so that you can maintain your own viewing history.

All of this for just under $100, and you got to build it yourself. Isn’t it fun?

Read the other articles in the series:

5 Fun Raspberry Pi Projects: Getting Started

How to Build a Minecraft Server with Raspberry Pi 3

Turn Raspberry Pi 3 Into a Powerful Media Player With RasPlex

For 5 more fun projects for the Raspberry Pi 3, including a holiday light display and Minecraft Server, download the free E-book today!

Time Is Running Out for NTP

Everyone benefits from Network Time Protocol, but the project struggles to pay its sole maintainer or fund its various initiatives. 

“NTF’s NTP project remains severely underfunded,” the project team wrote in a recent security advisory. “Google was unable to sponsor us this year, and currently, the Linux Foundation’s Core Internet Initiative only supports Harlan for about 25 percent of his hours per week and is restricted to NTP development only.”

Read more at InfoWorld

 

Writing Docker Microservices in COBOL

There is one thing that COBOL does very well and that has kept it around longer than one would expect. The one thing that COBOL does well is volume processing. A lot of very big companies and firms use it to process a lot of data. The Social Security Administration currently has about 60 million lines of COBOL in production, and the US Navy and the Internal Revenue Service still use COBOL.

What happens when we need to access COBOL programs in a more modern architecture? What happens we we have to move a function that has been performed by a COBOL program in house for years?

Read more at Microservices Practitioner Articles

Uncommon but Useful GCC Command-Line Options

Software tools usually offer multiple features, but – as most of you will agree – not all their features are used by everyone. Generally speaking, there’s nothing wrong in that, as each user has their own requirement and they use the tools within that sphere only. However, it’s always good to keep exploring the tools you use as you never know when one of their features might come in handy, saving you some of your precious time in the process. So, in this article, we will cover a couple of such options, offering all the required details, and explaining them through easy to understand examples wherever necessary.

Case in point: compilers. A good programming language compiler always offers plethora of options, but users generally know and use a limited set only. Specifically, if you are C language developer and use Linux as your development platform, it’s highly likely that you’d using the gcc compiler, which offers an endless list of command line options.

Read the full article here

Health Checking Your Docker Containers

One of the new features in Docker 1.12 is how health check for a container can be baked into the image definition. And this can be overridden at the command line.

Just like the CMD instruction, there can be multiple HEALTHCHECK instructions in Dockerfile but only the last one is effective.

This is a great addition because a container reporting status as Up 1 hour may return errors. The container may be up but there is no way for the application inside the container to provide a status. This instruction fixes that.

Read more at DZone

 

Managing Devices in Linux

There are many interesting features of the Linux directory structure. This month I cover some fascinating aspects of the /dev directory. Before you proceed any further with this article, I suggest that, if you have not already done so, you read my earlier articles, Everything is a file, and An introduction to Linux filesystems, both of which introduce some interesting Linux filesystem concepts. Go ahead—I will wait.

Great! Welcome back. Now we can proceed with a more detailed exploration of the /dev directory.

Read more at OpenSource.com

Why the Fuss about Serverless?

To explain this, I’m going to have to recap on some old work with a particular focus on co-evolution.

Co-evolution

Let us take a hike back through time to the 80s/90s. Back in those days, computers were very much a product and the applications we built used architectural practices that were based upon the characteristics of a product, in particular mean time to recovery (MTTR)

When a computer failed, we had to replace or fix it and this would take time. The MTTR was high and architectural practices had emerged to cope with this. 

Read more at HackerNoon

How To Enable Shell Script Debugging Mode in Linux

A script is simply a list of commands stored in a file. Instead of running a sequence of commands by typing them one by one all the time on the terminal, a system user can store all of them (commands) in a file and repeatedly invokes the file to re-execute the commands several times.

While learning scripting or during the early stages of writing scripts, we normally start by writing small or short scripts with a few lines of commands. And we usually debug such scripts by doing nothing more than looking at their output and ensuring that they work as we intended.

Read complete article at Tecmint

How to Install an SSL Certificate on Linux Server

With Security being the top most priority in the e-commerce world, the importance of SSL Certificates has skyrocketed. Installing an SSL Certificate on an online portal has become the basic foundation of a company’s business structure.

But the question is ‘How to install an SSL Certificate on a server?’

It is not necessary that everyone who is into e-commerce has a technical background. E-commerce is all about business and the owners are mostly businessmen. So also the core team of an e-commerce industry is not fully technical. In such a situation it becomes very difficult for people with minimal technical knowledge to grasp concepts even as basic like SSL Certificates or its installation for that matter.

This article aims at giving a sneak peek into the process of installing an SSL Certificate on Linux server in lay man’s words. This would help the non-technical people also to get a grasp of what it is all about. Of course, every e-commerce company has a core technical team, so they can easily take over from here. But it is always good to have a know-how of the process.

The installation of SSL Certificates on a Linux server is very easy. It can be done using a Plesk control panel and also without it.

What is Plesk?

It is a web hosting platform that has a very simple configuration. This simple configuration helps all web hosting providers to manage a lot of virtual hosts easily and on a single server. Ever since its conception, Plesk has been coming up as a preferred choice for all the web hosting companies.

How to install an SSL certificate on a Linux Server that has Plesk?

1. First Log into the control panel of Plesk.

2. Then, Select Domain;

3. The third step implies choosing the domain to be updated.

4. In the next step click on the ‘Add New Certificate’ icon.

5. Save the certificate name in the ‘Certificate Name’ box.

One would have the certificate and key files saved on the local computer. These certificate and key files are provided by the certificate authority and are important for the installation.

6. The next step is to find these files. Open these in a Notepad or in other similar text formats from where one can copy the text.

7. Copy the entire text of the files.

8. Paste them in the correct boxes. Reading through the content and the box name in Plesk will give one an idea where to paste it.

9. Next, click on the ‘Send Text’ button.

10. Go to the ‘Hosting Section’. It is on the domain screen.

11. Click ‘Set-up’ from this section. A drop down list will follow.

12. The next step is to click on the ‘new certificate’ from the drop down list.

13. Click ‘Ok’ to finish.

How to install SSL Certificate on Linux servers that do not have Plesk.

1. The first and foremost step is to upload the certificate and important key files. One can upload the files to the server using –  S/FTP.

2. Login to Server. It is important to log in via SSH. Logging in via SSH will help the user to become the root user.

3. Give Root Password.

4. One can see /etc/httpd/conf/ssl.crt in the following step. Move the certificate file here

5. Next move key file also to /etc/httpd/conf/ssl.crt

It is important to ensure the security of the files that has been moved. One can keep the files secure by restricting permission. Using ‘chmod 0400’ will help users to securely restrict permission to the key.

6. Next Go to etc/httpd/conf.d/ssl.conf. Here the user will find Virtual Host Configuration set up for the domain.

7. Edit Virtual Host Configuration.

8. Restart Apache.

The technicality of installing an SSL certificate may baffle many non-technical people, but once one gets a hang of it, it becomes easy.

Helm: The Kubernetes Package Manager

Back on October 15th 2016, Helm celebrated its one year birthday. It was first demonstrated ahead of the inaugural KubeCon conference in San Francisco in 2015. What is Helm? Helm aims to be the default package manager for Kubernetes.

In Kubernetes, distributed applications are made of various resources: Deployments, Services, Ingress, Volumes, and so on (as discussed in parts one and two of this series). You can create all those resources in your Kubernetes cluster using the kubectl client, but there is a need for a way to package them as a single entity. Creating a Package allows for simple sharing between users, tuning using a templating scheme, as well as provenance tracking, among other things. All in all, Helm tries to simplify complex application deployment on Kubernetes coupled with sharing of applications’ manifests.

Helm has been created by the folks at Deis and was donated to the Cloud Native Computing Foundation. Recently, Helm released version 2.0.0.

Helm is made of two components: A server called Tiller, which runs inside your Kubernetes cluster and a client called helm that runs on your local machine. A package is called a chart to keep with the maritime theme. Read the birthday retrospective from Matt Butcher to get the historical context of the naming.

With the Helm client, you can browse package repositories (containing published Charts) and deploy those Charts on your Kubernetes cluster. Helm will pull the Chart and talking to Tiller will create a release (an instance of a Chart). The release will be made of various resources running in the Kubernetes cluster.

Structure of a Chart

A Chart is easy to demystify; it is an archive of a set of Kubernetes resource manifests that make up a distributed application. Check the GitHub repository, where the Kubernetes community is curating Charts. As an example, let’s have a closer look at the MariaDB chart. The structure is as follows:

```

.

├── Chart.yaml

├── README.md

├── templates

│   ├── NOTES.txt

│   ├── _helpers.tpl

│   ├── configmap.yaml

│   ├── deployment.yaml

│   ├── pvc.yaml

│   ├── secrets.yaml

│   └── svc.yaml

└── values.yaml

```

The Chart.yaml contains some metadata about the Chart, such as its name, version, keywords, and so on. The values.yaml file contains keys and values that are used to generate the release in your Cluster. These values are replaced in the resource manifests using Go templating syntax. And, finally, the templates directory contains the resource manifests that make up this MariaDB application.

If we dig a bit deeper into the manifests, we can see how the Go templating syntax is used. For example, the database passwords are stored in a Kubernetes secret, and the database configuration is stored in a Kubernetes configMap.

We see that a set of labels are defined in the Secret metadata using the Chart name, release name etc. The actual values of the passwords are read from the values.yaml file.

```

apiVersion: v1

kind: Secret

metadata:

 name: {{ template "fullname" . }}

 labels:

   app: {{ template "fullname" . }}

   chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"

   release: "{{ .Release.Name }}"

   heritage: "{{ .Release.Service }}"

type: Opaque

data:

 mariadb-root-password: {{ default "" .Values.mariadbRootPassword | b64enc | quote }}

 mariadb-password: {{ default "" .Values.mariadbPassword | b64enc | quote }}

```

Similarly, the configMap manifest contain metadata that is computed on the fly when tiller expands the templates and creates the release. In addition, you can see below that the database configuration can be set in the values.yaml file, and if present is placed inside the configMap.

```

apiVersion: v1

kind: ConfigMap

metadata:

 name: {{ template "fullname" . }}

 labels:

   app: {{ template "fullname" . }}

   chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"

   release: "{{ .Release.Name }}"

   heritage: "{{ .Release.Service }}"

data:

 my.cnf: |-

{{- if .Values.config }}

{{ .Values.config | indent 4 }}

{{- end -}}

```

Bottom line: a Chart is an archive of a set of resource manifests that make an application. The manifests can be templatized using the Go templating syntax. A instantiated Chart is called a release, it reads values in the values.yaml file and replaces those values in the template manifests.

Using Helm

As always you can build Helm from source, or grab a release from the GitHub page. I expect to see Linux packages for the stable release. OSX users will also be able to get it quickly using Brew.

```

$ brew cask install helm

```

With helm installed, you can deploy the server-side tiller in your cluster. Note that this will create a deployment in the kube-system namespace.

```

$ brew init

$ helm init

…

Now, Tiller (the helm server-side component) has been installed into your Kubernetes cluster.

$ kubectl get deployments --namespace=kube-system

NAMESPACE     NAME            DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE

kube-system   tiller-deploy   1         1         1            1           1m

```

The client will be able to communicate with the tiller Pod using port forwarding. Hence you will not see any service exposing tiller.

To deploy a Chart, you can add a repository and search for a keyword. Once Helm is officially released, the format of the repository indexed will be fixed and the default repository will be fully tested and usable.

```

$ helm repo add testing http://storage.googleapis.com/kubernetes-charts-testing

$ helm repo list

NAME       URL                                               

stable     http://storage.googleapis.com/kubernetes-charts   

local      http://localhost:8879/charts                      

testing    http://storage.googleapis.com/kubernetes-charts...


$ helm search redis

WARNING: Deprecated index file format. Try 'helm repo update'

NAME                        VERSION    DESCRIPTION                                       

testing/redis-cluster       0.0.5      Highly available Redis cluster with multiple se...

testing/redis-standalone    0.0.1      Standalone Redis Master                           

testing/example-todo        0.0.6      Example Todo application backed by Redis   

```

To deploy a Chart, just use the install command:

```

$ helm install testing/redis-standalone

Fetched testing/redis-standalone to redis-standalone-0.0.1.tgz

amber-eel

Last Deployed: Fri Oct 21 12:24:01 2016

Namespace: default

Status: DEPLOYED


Resources:

==> v1/ReplicationController

NAME               DESIRED   CURRENT   READY     AGE

redis-standalone   1         1         0         1s


==> v1/Service

NAME      CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE

redis     10.0.81.67   <none>        6379/TCP   0s

```

You will be able to list the release, delete it, and even upgrade it and rollback.

```

$ helm list

NAME         REVISION    UPDATED                     STATUS      CHART                 

amber-eel    1           Fri Oct 21 12:24:01 2016    DEPLOYED    redis-standalone-0.0.1

```

Underneath, of course, Kubernetes will have created its regular resources. In this particular case, a replication controller, svc, and a pod were created:

```

$ kubectl get pods,rc,svc

NAME                               READY     STATUS    RESTARTS   AGE

po/redis-standalone-41eoj          1/1       Running   0          6m

NAME                  DESIRED   CURRENT   READY     AGE

rc/redis-standalone   1         1         1         6m

NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE

svc/redis        10.0.81.67   <none>        6379/TCP   6m

```

And that’s it for a quick walkthrough of Helm. Expect stable, curated Charts to be available once Helm is released. This will give you quick access to packaged distributed applications with simple deployment, upgrade, and rollback capability.

Read the other articles in this series:

Getting Started With Kubernetes Is Easy With Minikube

Rolling Updates and Rollbacks using Kubernetes Deployments

Federating Your Kubernetes Clusters — The New Road to Hybrid Clouds

Enjoy Kubernetes with Python

Want to learn more about Kubernetes? Check out the new, online, self-paced Kubernetes Fundamentals course from The Linux Foundation. Sign Up Now!

Sebastien Goasguen (@sebgoa) is a long time open source contributor. Member of the Apache Software Foundation, member of the Kubernetes organization, he is also the author of the O’Reilly Docker cookbook. He recently founded skippbox, which offers solutions, services and training for Kubernetes.