Tag Archives: CLI

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.

Nginx proxy_pass

From synchtube.itunix.eu:1337 to synchtube.itunix.eu

  1. server {
  2. #  listen      66.225.195.83;
  3.    server_name synchtube.itunix.eu;
  4.    access_log  /var/log/nginx/access.log;
  5.    error_log   /var/log/nginx/error.log;
  6.  
  7.    location / {
  8.         proxy_pass  http://synchtube.itunix.eu:1337;
  9.         proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
  10.         proxy_redirect off;
  11.         proxy_buffering off;
  12.         proxy_set_header        Host            static.example.com;
  13.         proxy_set_header        X-Real-IP       $remote_addr;
  14.         proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  15.     }
  16. }

Screenshot with date and Countdown

Install: save code to /usr/bin/screenshot
Usage: $ screenshot 5
five us for 5sec countdown

#!/bin/sh
if [ $1 ]
then
	scrot -cd $1 "%Y-%m-%d_`echo $(date +%H-%m-%S)`.png" -e 'mv $f /home/modinfo/shots/'
        echo "Screenshot save in: /home/modinfo/shots/`echo $(date +%Y-%m-%d_%H-%m-%S)`.png"
else
	scrot "%Y-%m-%d_`echo $(date +%H-%m-%S)`.png" -e 'mv $f /home/modinfo/shots/'
        echo "Screenshot save in: /home/modinfo/shots/`echo $(date +%Y-%m-%d_%H-%m-%S)`.png"
fi

Create md5 from string im Linux

How to install?
Create new file

nano /usr/bin/md5

copy&paste code to /usr/bin/md5

chmod:

chmod +x /usr/bin/md5

Code:

#!/bin/sh
if [ $1 ]
then
        hash="$(echo -n "$1" | md5sum )"
        echo "$hash"
else
        echo "Example usage: md5 <you-string>"
fi

Usage and Output:
root@host:~# md5 sebastian
c2d628ba98ed491776c9335e988e2e3b  –

Own IRC Server on Debian

  1. aptitude install ircd-irc2
  2. nano /etc/ircd/ircd.conf

M:irc.<HOSTNAME>::<COUNTRY>::000A
A:<NAME>:<EMAIL>::<COMPANYNAME>:
Y:1:90::100:512000:5.5:100.100
Y:2:90::300:512000:5.5:250.250
I:*:::0:1
I:127.0.0.1/32:::0:1
I:192.168.0.0/24::::0:2
P::::6667:

3. nano /etc/ircd/ircd.motd
Your welcome text

4. /etc/init.d/ircd restart