Commit b71f0ff9 authored by Andrey Shatokhin's avatar Andrey Shatokhin

Initial commit

parents
PORT=6702
#!/bin/bash
# Запуск скрипта:
# ./radio <mountpoint>
# - cоздается конфиг файл (название - <mountpoint>.mpd.conf).
# - папка с конфиг-файлами (папка называется так же , как и <mountpoint>).
# - порт автоматически указывается в конфиге.
# - процесс автоматически добавляется в systemd
# - управление потоком ./radio.sh <название>
# Со стороны пользователя остается лишь добавить пути к плейлистам и изменить конфиг по усмотрению(название трансляции,описание и т.д)
ICECAST_DIR=/home/icecastradio
source ./.port
if [[ $# -lt 1 ]]; then
echo "Формат ./radio.sh <поток>"
exit 1
fi
if [[ ! -f $ICECAST_DIR'/'$1.mpd.conf ]];then
cp -p $ICECAST_DIR'/'template.mpd.conf $ICECAST_DIR'/'$1.mpd.conf
mkdir $ICECAST_DIR'/'$1
touch $ICECAST_DIR'/'$1'/'mpd.log
touch $ICECAST_DIR'/'$1'/'mpdstate
touch $ICECAST_DIR'/'$1'/'mpd.db
touch $ICECAST_DIR'/'$1'/'mpd.pid
mkdir $ICECAST_DIR'/'$1'/'playlists
sed -i "s/#1/$1/g" $ICECAST_DIR'/'$1.mpd.conf
sed -i "s/#2/$PORT/g" $ICECAST_DIR'/'$1.mpd.conf
chown -R icecastradio $ICECAST_DIR'/'$1
chgrp -R icecastradio $ICECAST_DIR'/'$1
chmod -R 777 $ICECAST_DIR'/'$1
chmod +x $ICECAST_DIR'/'$1/playlists
echo "Файлы конфигураций cозданы успешно !"
cp template.service /etc/systemd/system'/'$1.service
sed -i "s/#1/$1/g" /etc/systemd/system'/'$1.service
echo PORT=$((PORT+1)) > ./.port
systemctl daemon-reload
systemctl start $1.service
systemctl enable /etc/systemd/system'/'$1.service
echo "Запущен mpd-поток под названием : $1 по адресу : radio.azbyka.ru:8000/$PORT"
echo "Для начала работы требуется обновить базу данных mpd"
echo "Для работа с потоком : ./radio <название потока>"
else
ncmpc -p `cat $ICECAST_DIR'/'$1.mpd.conf | grep port | awk '{ print $2 ; exit; }' | tr -d \"`
fi
\ No newline at end of file
######################## REQUIRED PATHS ###############################
music_directory "/home/icecastradio/Music"
playlist_directory "/home/icecastradio/#1/playlists"
log_file "/home/icecastradio/#1/mpd.log"
db_file "/home/icecastradio/#1/mpd.db"
#######################################################################
######################## OPTIONAL PATHS ###############################
pid_file "/home/icecastradio/#1/mpd.pid"
state_file "/home/icecastradio/#1/mpdstate"
#######################################################################
######################## DAEMON OPTIONS ###############################
user "icecastradio"
bind_to_address "127.0.0.1"
#bind_to_address "any"
port "#2"
# "default", "secure", or "verbose".
log_level "default"
#zeroconf_name "Music Player"
audio_output {
type "shout"
encoding "mp3"
name "#1 station"
host "localhost"
port "8000"
mount "/#1"
password "etersoft8000"
quality "5.0"
format "44100:16:2"
protocol "icecast2"
always_on "yes"
description "Etersoft Radio"
genre "pop"
public "yes"
mixer_type "software"
}
#samplerate_converter "Fastest Sinc Interpolator"
mixer_type "alsa"
#mixer_device "default"
#mixer_control "PCM"
#mixer_type "software"
#replaygain "album"
#volume_normalization "no"
#audio_buffer_size "2048"
#buffer_before_play "10%"
#http_buffer_size "128"
#http_prebuffer_size "25%"
########################### HTTP PROXY ################################
#http_proxy_host "proxy"
#http_proxy_port "8080"
#http_proxy_user "user"
#http_proxy_password "password"
############################# LIMITS ##################################
#connection_timeout "60"
#max_connections "5"
#max_playlist_length "16384"
#max_command_list_size "2048"
#max_output_buffer_size "8192"
###################### CHARACTER ENCODINGS ############################
filesystem_charset "UTF-8"
id3v1_encoding "CP1251"
######################### OTHER OPTIONS ###############################
#gapless_mp3_playback "yes"
#save_absolute_paths_in_playlists "no"
#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
[Unit]
Description=MPD-STREAM
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/mpd
[Service]
Type=simple
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/mpd --no-daemon /home/icecastradio/#1.mpd.conf
User=icecastradio
Group=icecastradio
Restart=always
RestartSec=20
[Install]
WantedBy=multi-user.target
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment