build_gerbera.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/bin/bash
  2. Version=3.4
  3. XService=YES
  4. function print_centered {
  5. [[ $# == 0 ]] && return 1
  6. declare -i TERM_COLS="$(tput cols)"
  7. declare -i str_len="${#1}"
  8. [[ $str_len -ge $TERM_COLS ]] && {
  9. echo "$1";
  10. return 0;
  11. }
  12. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  13. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  14. filler=""
  15. for (( i = 0; i < filler_len; i++ )); do
  16. filler="${filler}${ch}"
  17. done
  18. printf "%s%s%s" "$filler" "$1" "$filler"
  19. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  20. printf "\n"
  21. return 0
  22. }
  23. # function to set terminal title
  24. function set-title() {
  25. if [[ -z "$ORIG" ]]; then
  26. ORIG=$PS1
  27. fi
  28. TITLE="\[\e]2;$*\a\]"
  29. PS1=${ORIG}${TITLE}
  30. }
  31. function intro_ {
  32. export TERM=xterm-256color
  33. print_centered "$(tput setaf 10)"
  34. print_centered " _____ __ ";
  35. print_centered " / ___/__ ____/ / ___ _______ _";
  36. print_centered "/ (_ / -_) __/ _ \/ -_) __/ _ \`/";
  37. print_centered "\___/\__/_/ /_.__/\__/_/ \_,_/ ";
  38. print_centered " ";
  39. echo -n "$(tput setaf 11)"
  40. print_centered "Gerbera UPNP installation script v$Version"
  41. echo -n "$(tput sgr0)"
  42. echo ""
  43. sleep 3
  44. }
  45. function update_ {
  46. echo -e "$(tput setaf 10)\nUpdate/install packages:$(tput sgr0)"
  47. sudo apt-get update
  48. sudo apt-get install uuid-dev libsqlite3-dev libmysqlclient-dev libmagic-dev libexif-dev libcurl4-openssl-dev libspdlog-dev libpugixml-dev -y
  49. sudo apt-get install libavutil-dev libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavresample-dev libswscale-dev libswresample-dev libpostproc-dev -y
  50. sudo apt-get install libebml-dev ffmpeg ffmpegthumbnailer libffmpegthumbnailer-dev imagemagick fmtools libfmt-dev libmatroska-dev -y
  51. echo -e ""
  52. }
  53. function version {
  54. echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
  55. }
  56. function cmake_ {
  57. pids=""
  58. ./tools/_cmake.sh & pids="$pids $!"
  59. wait $pids
  60. }
  61. function build_ {
  62. echo -e "$(tput setaf 10)\nBuild Gerbera:$(tput sgr0)"
  63. cd ~/Build_Cube/options
  64. if [ ! -d gerbera ]
  65. then
  66. #git clone https://github.com/gerbera/gerbera.git
  67. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/gerbera-1.12.1.tar.xz
  68. tar xvfJ gerbera-1.12.1.tar.xz
  69. mv gerbera-1.12.1 gerbera
  70. rm gerbera-1.12.1.tar.xz
  71. fi
  72. cd ~/Build_Cube/options/gerbera/scripts
  73. sudo ./install-pupnp.sh
  74. sudo ldconfig
  75. cd ~/Build_Cube/options/gerbera/scripts
  76. sudo ./install-fmt.sh
  77. cd ~/Build_Cube/options/gerbera/scripts
  78. sudo ./install-spdlog.sh
  79. cd ~/Build_Cube/options/gerbera/scripts
  80. sudo ./install-duktape.sh
  81. #cd ~/Build_Cube/options/gerbera/scripts
  82. #sudo ./install-lastfm.sh
  83. cd ~/Build_Cube/options/gerbera/scripts
  84. sudo ./install-pugixml.sh
  85. cd ~/Build_Cube/options/gerbera/scripts
  86. sudo ./install-taglib.sh
  87. echo -e ""
  88. sudo ldconfig
  89. cd ~/Build_Cube/options/gerbera
  90. mkdir build
  91. cd build
  92. cmake .. -DWITH_MAGIC=1 -DWITH_CURL=1 -DWITH_JS=1 -DWITH_TAGLIB=1 -DWITH_AVCODEC=1 -DWITH_FFMPEGTHUMBNAILER=1 -DWITH_EXIF=1 -DWITH_LASTFM=0 -DWITH_MYSQL=0
  93. make -j6
  94. sudo make install
  95. cd ~
  96. #sudo rm -r ~/Build_Cube/options/gerbera/
  97. wget -c http://folivier.homelinux.org/cube/pack/gerbera.tar.xz
  98. tar xvfJ gerbera.tar.xz
  99. rm gerbera.tar.xz
  100. echo -e "\n\e[97mEnd of process...\e[0m"
  101. }
  102. function service_ {
  103. sudo killall -9 gerbera > /dev/null 2>&1
  104. if ! getent passwd gerbera > /dev/null 2>&1
  105. then
  106. sudo useradd --system gerbera
  107. fi
  108. if ! [ -d /etc/gerbera ]
  109. then
  110. sudo mkdir /etc/gerbera
  111. sudo chown -Rv gerbera:gerbera /etc/gerbera
  112. fi
  113. sudo systemctl stop gerbera.service > /dev/null 2>&1
  114. cat <<'EOF'>> gerbera.service
  115. [Unit]
  116. Description=Gerbera Media Server
  117. After=network.target network-online.target
  118. Wants=network-online.target
  119. [Service]
  120. Type=simple
  121. User=wareck
  122. Group=adm
  123. ExecStart=/usr/local/bin/gerbera -c /home/wareck/.config/gerbera/config.xml
  124. Restart=on-failure
  125. RestartSec=5
  126. [Install]
  127. WantedBy=multi-user.target
  128. EOF
  129. sudo cp gerbera.service /lib/systemd/system/gerbera.service
  130. sudo rm gerbera.service
  131. sudo systemctl daemon-reload > /dev/null 2>&1
  132. sudo systemctl start gerbera > /dev/null 2>&1
  133. sudo systemctl enable gerbera > /dev/null 2>&1
  134. echo "Done"
  135. }
  136. intro_
  137. update_
  138. cmake_
  139. build_
  140. echo -e "$(tput setaf 10)\nService optional :$(tput sgr0)"
  141. if [ $XService = "YES" ]
  142. then
  143. service_
  144. fi
  145. #while true; do
  146. #read -p "Do you want to install service (y/n) ? " yn
  147. #
  148. #case $yn in
  149. # [Yy] ) service_ ;
  150. # exit 1;;
  151. # [Nn] ) echo exiting...;
  152. # exit;;
  153. # * ) echo invalid response;
  154. # exit 1;;
  155. #esac
  156. #done
  157. echo -e "\n\e[97mEnd of process...\e[0m"