Category Archives: Linux

ffmpeg on Raspbian – Raspberry Pi

First for all we need to build and install x264

# git clone --depth 1 git://git.videolan.org/x264
# cd x264
# ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
# make -j 4
# sudo make install

For mp3 support

wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz
tar xzvf lame-3.99.tar.gz
cd lame-3.99
./configure
make
make install

For Hardware Encoding
1. add "--enable-omx --enable-omx-rpi" to ./configure options
2. compile
3. use encoder option "-c:v h264_omx"

Then build and make ffmpeg

# git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
# cd ffmpeg
# ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-libmp3lame --enable-nonfree --enable-omx --enable-omx-rpi
# make -j4
# sudo make install
# ldconfig

It takes just 25 minutes on a Raspberry Pi 3.
In case you are wondering v4l2 should work with this.

I provide a repository for this kind of stuff some day.
git clone http://git.itunix.eu/git/x264/
git clone http://git.itunix.eu/git/ffmpeg/

What can I say, a simple way to backup remote server on the local machine

rsync -aHxv root@remote.example.com:/* /local/backup/server/ \ 
		--exclude=/dev \
		--exclude=/proc \
		--exclude=/sys \
		--exclude=/tmp

Setting up Nagios Server to Remotely Server on Debian

Step 1. Installing packages

We have one server for monitoring (eg. myoneserver). [client]

# aptitude install nagios-nrpe-server nagios-plugins

And one server to view statistics. [server]

# aptitude install nagios-nrpe-plugin nagios-plugins nagios3

Step 2. Configuring the server for monitoring [client]
Edit /etc/nagios/nrpe.conf.

# nano /etc/nagios/nrpe.conf

Set the server_address to the IP address you want NRPE to bind to on the Untangle server.  If you want it to bind to all addresses, leave this command commented out.

server_address=10.0.0.1

Change allowed_hosts to the IP address of the Nagios server:

allowed_hosts=10.0.0.20

Add a command to check the swap utilization:

command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1

Save and quit /etc/nagios/nrpe.conf.

Restart the NRPE service:

/etc/init.d/nagios-nrpe-server restart

Step 3. Configure the Nagios Server
Create a file named /etc/nagios3/conf.d/myoneserver.cfg with the following contents:

#Host Definition
define host{
use                     generic-host
host_name               myoneserver
alias                   MyOneServer Server
address                 10.0.0.1
}

# Service Definitions
define service{
use                     generic-service
host_name               myoneserver
service_description     CPU Load
check_command           check_nrpe_1arg!check_load
}

define service{
use                     generic-service
host_name               myoneserver
service_description     Swap Drive Usage
check_command           check_nrpe_1arg!check_swap
}

define service{
use                     generic-service
host_name               myoneserver
service_description     Free Disk Space
check_command           check_nrpe_1arg!check_sda1
}

define service{
use                     generic-service
host_name               myoneserver
service_description     Number of Users
check_command           check_nrpe_1arg!check_users
}

define service{
use                     generic-service
host_name               myoneserver
service_description     Number of Zombie Processes
check_command           check_nrpe_1arg!check_zombie_procs
}

define service{
use                     generic-service
host_name               myoneserver
service_description     Total Processes
check_command           check_nrpe_1arg!check_total_procs
}

Save and quit  /etc/nagios3/conf.d/myoneserver.cfg.

Edit /etc/nagios3/conf.d/hostgroups_nagios2.cfg and add the following section to define an

Server group. (optional)
define hostgroup {
hostgroup_name  myoneserver
alias           MyOneServer Servers
members         MyOneServer1, MyOneServer2 MyOneServer3
}

Restart the Nagios service to apply the changes:

/etc/init.d/nagios3 restart

Find and replace text in multiple files using geany

To open all files, in which a specific string is found, from inside of a directory (and subdirectories) open Geany, select Terminal tab from Message Window and run next command inside:

grep -rHIF --exclude='/home/modinfo/bitcoin/*~' -- 'text_to_find' /bin/bash /home/modinfo/bitcoin/* | geany `awk 'BEGIN {FS="[:]"} {print $1}'`

source

Quick server backup

mount /dev/xxxx -o remount-ro /mnt
tar -cvjpf serverbackup.tar.bz2 /mnt

then unpack the behavior of permissions

tar -xvjpf serverbackup.tar.bz2

here my script with mysql backup. backup.sh

  1. # create backup catalog
  2. mkdir /backup
  3. # clean
  4. aptitude clean
  5. rm /var/log/*.gz
  6. rm /var/log/apache2/*.gz
  7. rm /var/log/apt/*.gz
  8. rm /var/log/clamav/*.gz
  9. rm /var/backups/*.gz
  10. # start archive
  11. tar -cvjpf /backup/backup_bin.tar.bz2 /bin
  12. tar -cvjpf /backup/backup_home.tar.bz2 /home
  13. tar -cvjpf /backup/backup_lib.tar.bz2 /lib
  14. tar -cvjpf /backup/backup_root.tar.bz2 /root
  15. tar -cvjpf /backup/backup_usr.tar.bz2 /usr
  16. tar -cvjpf /backup/backup_etc.tar.bz2 /etc
  17. tar -cvjpf /backup/backup_lib64.tar.bz2 /lib64
  18. tar -cvjpf /backup/backup_sbin.tar.bz2 /sbin
  19. tar -cvjpf /backup/backup_var.tar.bz2 /var
  20. # backup mysql
  21. mysqldump -u root -p<PASSWORD> --all-databases > /backup/all_databases.sql
  22. # archiving of all backups to a single file
  23. tar -cvjpf /backup_`date +"%F"`.tar.bz2 /backup
  24. # send backup to another server
  25. scp /backup_`date +"%F"`.tar.bz2 user@server:/home/backup
  26. # remove local backup
  27. rm -R /backup /backup_`date +"%F"`.tar.bz2

update
backup from remote server 192.168.0.100 to local /mnt

mount /dev/sda1 /mnt/
rsync -aHxv root@192.168.0.100:/* /mnt --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp

Liquidsoap: AutoDJ for icecast

Wonder it’s called “Liquidsoap”. Is a piece of firmware that can really do a lot of things. What does it do? Starting play playlists, depending on the time or any logic, he can listen to Icecast or Shoutcast instead, is able to download the streams from other servers, mix them, detect or work, etc…

Configuration looks like this:

#!/usr/bin/liquidsoap
set("log.file.path","/tmp/basic-radio.log")
 
# required speech synthesizer, aptitude install festival
message = "That's it! you listening the radio dubstep is our life, listen to us at school, at home or at a party with friends"
messagesorry = "Sorry for the inconvenience, continuation of the program soon!"
 
welcome = single("say:"^message)
sorryvoice = single("say:"^messagesorry)
 
# find /home/music/ -type f -name "*.mp3" > /etc/liquidsoap/music.m3u
radio   = playlist("music.m3u")
dubstep = playlist("dubstep.m3u")
 
#play a random playlist with random music
radio   = random(weights = [1, 3, 1],[welcome, radio, dubstep])
 
#if the music not available
radio = fallback(track_sensitive=false, [radio, sorryvoice])
 
#if the live broadcast available
full = fallback(track_sensitive=false, [input.http("http://nsa310:8000/live"), radio])
 
# Stream it out (ogg)
#output.icecast(%vorbis, host = "localhost", port = 8000, password = "<PASSWORD>", mount = "/radio.ogg", full)
 
# Stream in mp3 ~Low Quality
output.icecast(%mp3(bitrate=32, samplerate=22050, stereo=false), mount="/radio-32.mp3", host="localhost", port=8000, password="<PASSWORD>", mean(full))
 
# Stream in mp3 ~High Quality
output.icecast(%mp3(bitrate=128), mount="/radio-128.mp3", host="localhost", port=8000, password="<PASSWORD>", full)

There is a lot of options to configure according to your needs, here are more examples: documentation.