Creating a Custom Raspbian Image containing SUSI.AI Linux Libraries

Installing Raspbian and SUSI Linux on your Raspberry Pi can be a long process and if your raspberry Pi crashes due to some bug, you have to repeat the process again and again.

It wastes a lot of valuable time. So, we will discuss a method in which we will have to install the SUSI Linux repo only once and can use it again in case of any issues.

First, we’ll go through the requirements for f installing SUSI Linux on our hardware

Hardware Requirements

1> Raspberry Pi

2> Micro SD card (16GB or greater)

3> USB Mic

4> USB Mouse and USB Keyboard

5> HDMI Monitor

6> ReSpeaker Pi Hat 2 Mic Array(optional)

7> 3.5 mm Jack Headphones / Speaker

 

Step 1: Preparing SD for Installation

1> To format your SD card

  • You can use softwares like SDCardformater to do so.

2> To install Raspbian

  • Download raspbian official build from here
  • Now mount the Image using software like Etcher or win32diskimager

 

Step 2: Installing SUSI Linux on your Pi

1> Navigate to the folder `/home/pi` and make a folder called SUSI.AI

 

cd /home/pi
mkdir SUSI.AI
cd SUSI.AI

 

2> Clone the SUSI Linux repo from here and navigate in the repo

 

git clone http://github.com/fossasia/susi_linux

cd susi_linux/

 

3> Run the installation script by using the command `./install.sh`

 

./install.sh

 

4> Run the configuration script by using the following command

`python3 config_generator.py <stt> <tts> <hotword> <wake>`

 

5> Run SUSI linux with the following command

`python3 -m main`

‘log’

If it plays a bell after you say ‘SUSI’ , it means that your software has been successfully installed

Step 3: Creating the image

1> Now that you have successfully installed SUSI Linux on your raspberry Pi , we will make a backup of the current stage of the system and use it for future references

 

2>Turn off the raspberry Pi , and remove the SD card from the Pi and insert it in your system.

 

3> To create the custom Image , use something like win32 imager and follow the steps below

  • In the text box , create a custom where you want your image to exist
  • Click on read button
  • And voila

 

References

https://www.raspberrypi.org/downloads/raspbian/

Tags

Fossasia, gsoc’18, SUSI.AI , susi_linux , gsoc, SUSI HW, installation

Continue ReadingCreating a Custom Raspbian Image containing SUSI.AI Linux Libraries

Working of Meilix Build Script

Meilix build script is divided into several parts the initial part consist of getting the build environment ready for build which includes installation of packages to build the ISO.

Iike debootstrap genisoimage p7zip-full squashfs-tools ubuntu-dev-tools.

The we have a debuild script which is ran by the build script in initially to rebuild the metapackages so that if any change is created it can be included in the build.

To make the change in metapackage like meilix-default-settings.deb we include the changes in the meilix-default-settings/ to test the meta package locally we can use the following script to build it for testing.

#!/bin/bash
rm meilix-default-settings_*                                    #removes the older meilix-default-settings packages
cd meilix-default-settings                                      #cd into the metapackage directory
debuild -uc -us                                                 #debuild the meilix-default-settings metapackage

 

After creation of packages we prepare chroot with the help of debbootstrap using ubuntu mirror for application installation after that we copy the files we created using debuild script and the files we require in the chroot.
We have a different file for working in the chroot which executes once the chroot is ready.

Now we copy the kernel from chroot to the build server /image for creation of live cd

sudo cp chroot/boot/vmlinuz-**-generic image/casper/vmlinuz sudo cp chroot/boot/initrd.img-**-generic image/casper/initrd.lz

Next step is to extract initrd for updating the uuid information for the above changes.

7z e image/casper/initrd.lz && \
  mkdir initrd_FILES/ && \
  mv initrd initrd_FILES/ && \
  cd initrd_FILES/ && \
  cpio -id < initrd && \
  cd .. && \
  cp initrd_FILES/conf/uuid.conf image/.disk/casper-uuid-generic && \

Now we pack the ISO using mkisofs but the problem here is we don’t have a boot.cat file and without that we will have errors in packing the ISO so to handle that we first create a temporary ISO to be able to extract boot.cat from it.

IMAGE_NAME=${IMAGE_NAME:-"Meilix ${release} $(date -u +%Y%m%d) - ${arch}"}
ISOFILE=meilix-${release}-$(date -u +%Y%m%d)-${arch}.iso
sudo mkisofs -r -V "$IMAGE_NAME" -cache-inodes -J -l \
  -b isolinux/isolinux.bin -c isolinux/boot.cat \
  -no-emul-boot -boot-load-size 4 -boot-info-table \
  --publisher "Meilix Packaging Team" \
  --volset "Ubuntu Linux http://www.ubuntu.com" \
  -p "${DEBFULLNAME:-$USER} <${DEBEMAIL:-on host $(hostname --fqdn)}>" \
  -A "$IMAGE_NAME" \
  -m filesystem.squashfs \
  -o ../$ISOFILE.tmp .

After getting a updated boot.cat file by mounting the temporary ISO and extracting boot.cat from it, we repeat the similar steps to create the ISO.

Chroot Script

Inside the chroot script we are going to install all the packages we require in the ISO and the metapackages we created for ISO. we can also add the custom changes we require like turning off screen dimming or setting plymouth after installing the package.

echo -ne "\033[9;0]" >> /etc/issue
setterm -blank 0 >> /etc/issue

At the end of chroot script we do the cleanup.

perl -i -nle 'print unless /^Package: language-(pack|support)/ .. /^$/;' /var/lib/apt/extended_states 
apt-get -qq clean
 rm -rf /tmp/* #rm /etc/resolv.conf 
rm meilix-default-settings_1.0_all.deb 
rm meilix-metapackage_1.0-1_all.deb 
rm systemlock_0.1-1_all.deb plymouth-meilix-logo_1.0-1_all.deb plymouth-meilix-text_1.0-1_all.deb skype-ubuntu_4.1.0.20-1_i386.deb rm meilix-imclient_*_all.deb
rm /sbin/initctl dpkg-divert --rename --remove /sbin/initctl

Resources

Continue ReadingWorking of Meilix Build Script

Working with Apache Web Server

In this article, I will examine what apache is how to setup apache for ubuntu or debian and how to view error logs for apache and how to understand what the logs contain which will be useful for web development.

What is Apache?

Apache is the most popular web server on the internet. It is used to serve more than half of all active websites.

It is fast, reliable, and secure. It can be highly customized to meet the needs of many different environments by using extensions and modules.

Installing Apache on Ubuntu and Debian

If you do not already have Apache installed, you can do so now by issuing the following commands:

sudo apt-get update
sudo apt-get install apache2

If you visit your VPS’s IP address in a web browser, you will get the default Apache index page. We get the following output.

your_domain_name_or_ip_address
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.

Looking into apache error.log files

In order to effectively manage a web server, it is necessary to get feedback about the activity and performance of the server as well as any problems that may be occuring. The Apache HTTP Server provides very comprehensive and flexible logging capabilities.

Error.log file

The server error log, whose name and location is set by the ErrorLog directive, is the most important log file. This is the place where Apache httpd will send diagnostic information and record any errors that it encounters in processing requests.

It is the first place to look when a problem occurs with starting the server or with the operation of the server, since it will often contain details of what went wrong and how to fix it.

Explanation of log message

There is certain information that is contained in most error log entries. For example, here is a typical message.

[Sat Aug 20 08:09:38.958885 2016] [:error] [pid 1489] [client 127.0.0.1:40810] PHP Notice:  Constant MIN_PASSWORD_LENGTH already defined in /var/www/html/test/engelsystem/config/config.php on line 30, referer: http://localhost/

[Sat Aug 20 08:09:38.958885 2016] The first item in the log entry is the date and time of the message.

[:error] The second entry lists the severity of the error being reported.

[pid 1489] Indicates process Id

[client 127.0.0.1:40810] The fourth entry gives the IP address of the client that generated the error.

Fifth one is error message explaining the error.

Constant MIN_PASSWORD_LENGTH already defined.

File and line number

 /var/www/html/test/engelsystem/config/config.php on line 30

Error logs are easy to understand. Using error logs we can easily figure out the problem in your server or your code and fix it.

For more information about the log files and configuration please visit Apache website Apache provides excellent documentation.

Apache log files were useful for me during web development project Engelsystem. We are developing new features. Interested developers can work with us.

Development: https://github.com/fossasia/engelsystem

Issues/Bugs:https://github.com/fossasia/engelsystem/issues

Continue ReadingWorking with Apache Web Server

Installing Engelsystem in Five Minutes

Here are the instructions to install engelsystem on your local server in just five minutes.

Prerequisites

1.1 PHP 5.4.x (cgi-fcgi)

1.2 MySQL-Server 5.5+ or MariaDB

1.3 Webserver ( Apache/Nginx/lighttpd)

Step 1: Download or Clone the repository

git clone --recursive https://github.com/fossasia/engelsystem.git

Download and unzip the engelsystem from here

Step 2: Create a Database and a User

Using the MySQL Client

You can create MySQL/MariaDB user and database quickly and easily by running mysql from the shell. The syntax is shown below and the dollar sign is the command prompt:

$ mysql -u adminusername -p
Enter password:
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)

Step 3: Set up config.php

Renname config/config-sample.php to config/config.php, and add your database information.

// MySQL-Connection Settings
$DB_HOST = "localhost";
$DB_USER = "username_here";
$DB_PASSWORD = "password_here";
$DB_NAME = "database_name_here";

Step 4: Upload the files and configure Document Root

Now you will need to decide where on your domain you’d like your engelsystem to appear:

Upload the engelsystem files to the desired location on your web server. For Apache server we need to upload to /var/www/html/

Now we need to configure document root. Change the document root in /etc/apache2/sites-available/000-default.conf from /var/www to /var/www/html/engelsystem/public. Now we can view engelsystem at localhost or http://[i.p.address].

Following command will change the document root from /var/www/ to /var/www/html/engelsystem/public.

$ sudo sed -i -e ‘s/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/html\/engelsystem\/public/g’ /etc/apache2/sites-available/000-default.conf

Step 5: Run the Install Script

Point a web browser to start the installation script.

We will be redirected to install page where we need to fill in the information for installation. Once we fill the information and press install engelsystem. All the tables will be imported and we are redirected to login page.

In this way we can install engelsystem using installation script in just five minutes. For more information visit here

Development: https://github.com/fossasia/engelsystem

Issues/Bugs:https://github.com/fossasia/engelsystem/issues

 

 

 

 

Continue ReadingInstalling Engelsystem in Five Minutes

Writing Installation Script for Github Projects

I would like to discuss how to write a bash script to setup any github project and in particular PHP and mysql project. I would like take the example of engelsystem for this post.

First, we need to make a list of all environments and dependencies for our github project. For PHP and mysql project we need to install LAMP server.

The script to install all the dependencies for engelsystem are

echo "Update your package manager"
apt-get update

echo "Installing LAMP"
echo "Install Apache"
apt-get install apache2

echo "Install MySQL"
apt-get install mysql-server php5-mysql

echo "Install PHP"
apt-get install php5 libapache2-mod-php5 php5-mcrypt

echo "Install php cgi"
apt-cache search php5-cgi

We can even add echo statements with instructions.

Once we have installed LAMP. We need to clone the project from github. We need to install git and clone the repository. Script for installing git and cloning github repository are

echo "Install git"
apt-get install git
cd /var/www/html
echo "Cloning the github repository"
git clone --recursive https://github.com/fossasia/engelsystem.git
cd engelsystem

Now we are in the project directory. Now we need to set up the database and migrate the tables. We are creating a database engelsystem and migrating the tables in install.sql and update.sql.

echo "enter mysql root password"
# creating new database engelsystem
echo "create database engelsystem" | mysql -u root -p
echo "migrate the table to engelsystem database"
mysql -u root -p engelsystem < db/install.sql
mysql -u root -p engelsystem < db/update.sql

Once we are done with it. We need to copy config-sample.default.php to config.php and add the database and password for mysql.

echo "enter the database name username and password"
cp config/config-sample.default.php config/config.php

Now edit the config.php file. Once we have done this we need to restart apache then we can view the login page at localhost/engelsystem/public

echo "Restarting Apache"
service apache2 restart
echo "Engelsystem is successfully installed and can be viewed on local server localhost/engelsystem/public"

We need to add all these instructions in install.sh file.

Now steps to execute a bash file.

Change the permissions of install.sh file

$ chmod +x install.sh

Now run the file from your terminal by executing the following command

$ ./install.sh

Developers who are interested in contributing can work with us.

Development: https://github.com/fossasia/engelsystem

Issues/Bugs:https://github.com/fossasia/engelsystem/issues

Continue ReadingWriting Installation Script for Github Projects