build_gerbera.sh 4.4 KB

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