Auto Install for Linux (ubuntu/mint)
Posted: Tue Jun 10, 2014 7:14 am
I created a script to install the UMS, I'm sharing it here, maybe someone can help
You can choose to use the UMSBuilder or packages ready and want to install the alphas or not
The script takes the newest version found in http://www.universalmediaserver.com/news
The script now also adds to boot linux as tips found here in the forum even
To configure the boot UMS start as root (sudo /usr/ums/UMS.sh)
I only tested it on Ubuntu and Mint do not know if it works in other distros
as'm from Brazil and I hardly know English all my translations were made by google translator so may be bad
Hope this helps someone
You can choose to use the UMSBuilder or packages ready and want to install the alphas or not
The script takes the newest version found in http://www.universalmediaserver.com/news
The script now also adds to boot linux as tips found here in the forum even
To configure the boot UMS start as root (sudo /usr/ums/UMS.sh)
I only tested it on Ubuntu and Mint do not know if it works in other distros
as'm from Brazil and I hardly know English all my translations were made by google translator so may be bad
Hope this helps someone
Code: Select all
#!/bin/bash
function pause(){
read -p "$*"
}
sudo echo "Teste de SUDO" | clear
echo Installing dialog...
sudo apt-get install dialog -y --force-yes > /dev/null 2>&1
dialog --title 'Aguarde' --infobox '\nInstalling the dependencies UniversalMediaServer...' 0 0
sudo apt-get install ttf-ubuntu-font-family -y --force-yes > /dev/null 2>&1
sudo apt-get install ttf-ubuntu-title -y --force-yes > /dev/null 2>&1
sudo apt-get install mencoder -y --force-yes > /dev/null 2>&1
sudo apt-get install ffmpeg -y --force-yes > /dev/null 2>&1
sudo apt-get install mplayer -y --force-yes > /dev/null 2>&1
sudo apt-get install vlc -y --force-yes > /dev/null 2>&1
sudo apt-get install mediainfo -y --force-yes > /dev/null 2>&1
sudo apt-get install w3m -y --force-yes > /dev/null 2>&1
sudo apt-get install curl -y --force-yes > /dev/null 2>&1
sudo rm -rf /usr/ums
pasta=${PWD}
dialog --stdout --defaultno --yesno 'Want to make a new Build the UniversalMediaServer?' 0 0
compileUMS=$?
if [ "$compileUMS" == "0" ]; then
dialog --title 'Aguarde' --infobox '\nCreating a new Build the UniversalMediaServer (will take a long time).' 0 0
BuilderUMS=$( curl -s -b "a=b" "http://www.universalmediaserver.com/news/" | w3m -dump -T text/html | grep UMSBuilder -F | cut -d ' ' -f 3 | grep -v "a" | sed -n 1p )
cd /tmp
rm -rf /tmp/UMSBuilder*
wget "http://downloads.sourceforge.net/project/unimediaserver/Official%20Releases/Linux/UMSBuilder-$BuilderUMS.tgz" -O UMSBuilder.tgz > /dev/null 2>&1
mkdir /tmp/UMSBuilder && tar xvf UMSBuilder.tgz -C /tmp/UMSBuilder --strip-components=1 >/dev/null 2>&1
cd UMSBuilder
sudo mkdir /usr/ums
sudo bash -c "./build.sh >/dev/null 2>&1 && tar xvf ums*distribution.tar.gz -C /usr/ums --strip-components=1 >/dev/null 2>&1"
sudo echo "Teste de SUDO" | clear
else
dialog --title 'Aguarde' --infobox '\nInstalling UniversalMediaServer...' 0 0
dialog --stdout --defaultno --yesno 'You will accept installation including alpha versions of UniversalMediaServer?' 0 0
alphaUMS=$?
if [ "$alphaUMS" == "0" ]; then
VersionUMS=$( curl -s -b "a=b" "http://www.universalmediaserver.com/news/" | w3m -dump -T text/html | grep Version -F | cut -d ' ' -f 3 | sed -n 1p )
else
VersionUMS=$( curl -s -b "a=b" "http://www.universalmediaserver.com/news/" | w3m -dump -T text/html | grep Version -F | cut -d ' ' -f 3 | grep -v "a" | sed -n 1p )
fi
cd /tmp
rm -rf /tmp/UMS*
wget "http://downloads.sourceforge.net/project/unimediaserver/Official%20Releases/Linux/UMS-$VersionUMS.tgz" -O UMS.tgz > /dev/null 2>&1
sudo mkdir /usr/ums
sudo bash -c "tar xvf UMS.tgz -C /usr/ums --strip-components=1 >/dev/null 2>&1"
fi
sudo echo "Teste de SUDO" | clear
sudo touch /etc/init.d/UMS.sh
sudo chmod 755 /etc/init.d/UMS.sh
echo '#!/bin/bash' > /tmp/UMS.sh
echo "#" >> /tmp/UMS.sh
echo "### BEGIN INIT INFO" >> /tmp/UMS.sh
echo "# Provides: ums" >> /tmp/UMS.sh
echo "# Required-Start: \$local_fs \$remote_fs \$network" >> /tmp/UMS.sh
echo "# Required-Stop: \$local_fs \$remote_fs \$network" >> /tmp/UMS.sh
echo "# Default-Start: 2 3 4 5" >> /tmp/UMS.sh
echo "# Default-Stop: 0 1 6" >> /tmp/UMS.sh
echo "# Short-Description: Starts UMS program." >> /tmp/UMS.sh
echo "# Description: Java Upnp Media Server dedicated to PS3" >> /tmp/UMS.sh
echo "### END INIT INFO" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "#set -x" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "# Author: Papa Issa DIAKHATE <[email protected]>" >> /tmp/UMS.sh
echo "#" >> /tmp/UMS.sh
echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /tmp/UMS.sh
echo "DESC=\"Universal Media Server\"" >> /tmp/UMS.sh
echo "NAME=UMS.sh" >> /tmp/UMS.sh
echo "UMS_PROFILE=/etc/\$NAME" >> /tmp/UMS.sh
echo "DAEMON=/usr/ums/\$NAME" >> /tmp/UMS.sh
echo "DAEMON_OPTS=\"console\"" >> /tmp/UMS.sh
echo "SCRIPTNAME=/etc/init.d/\$NAME" >> /tmp/UMS.sh
echo "UMS_START=1 # Wether to start or not UMS ver at boot time." >> /tmp/UMS.sh
echo "DODTIME=30 # Time to wait for the server to die, in seconds." >> /tmp/UMS.sh
echo " # If this value is set too low you might not" >> /tmp/UMS.sh
echo " # let the program to die gracefully and 'restart' will not work" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "test -x \$DAEMON || exit 1" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "# Load the VERBOSE setting and other rcS variables" >> /tmp/UMS.sh
echo ". /lib/init/vars.sh" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "# Define LSB log_* functions." >> /tmp/UMS.sh
echo "# Depend on lsb-base (>= 3.0-6) to ensure that this file is present." >> /tmp/UMS.sh
echo ". /lib/lsb/init-functions" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "# Include ums defaults if available" >> /tmp/UMS.sh
echo "if [[ -f \"/etc/default/\$NAME\" ]] ; then" >> /tmp/UMS.sh
echo " . /etc/default/\$NAME" >> /tmp/UMS.sh
echo "fi" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "# May we run the init.d script ?" >> /tmp/UMS.sh
echo "[[ \$UMS_START = 1 ]] || exit 1" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "# Some color codes" >> /tmp/UMS.sh
echo "txtred=\$'\e[0;31m' # Red" >> /tmp/UMS.sh
echo "txtylw=\$'\e[0;33m' # Yellow" >> /tmp/UMS.sh
echo "txtrst=\$'\e[0m' # Text Reset" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "warnout(){" >> /tmp/UMS.sh
echo " echo >&2 -e \"\"\$txtylw\"Warning:\$txtrst \$1\"" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "running(){" >> /tmp/UMS.sh
echo " pid=\`pgrep -f 'java .*ums.jar.*'\`" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "do_start(){" >> /tmp/UMS.sh
echo " running && { warnout \"\$NAME is already running \!\"; exit 0; }" >> /tmp/UMS.sh
echo " echo \"Starting \$DESC : \$NAME\"" >> /tmp/UMS.sh
echo " UMS_PROFILE=\"\$UMS_PROFILE\" start-stop-daemon --start --quiet --background --oknodo \\" >> /tmp/UMS.sh
echo " --exec \$DAEMON -- \$DAEMON_OPTS" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "do_stop(){" >> /tmp/UMS.sh
echo " running || { warnout \"\$NAME is NOT running \!\"; exit 0; } " >> /tmp/UMS.sh
echo " local countdown=\"\$DODTIME\"" >> /tmp/UMS.sh
echo " echo -e \"Stopping \$DESC : \$NAME \c \"" >> /tmp/UMS.sh
echo " kill -9 \$pid" >> /tmp/UMS.sh
echo " while running; do" >> /tmp/UMS.sh
echo " if ((\$countdown >= 0)); then" >> /tmp/UMS.sh
echo " sleep 1; echo -n .;" >> /tmp/UMS.sh
echo " ((--countdown))" >> /tmp/UMS.sh
echo " else" >> /tmp/UMS.sh
echo " break;" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo " done" >> /tmp/UMS.sh
echo " echo" >> /tmp/UMS.sh
echo " # If still running, then try to send SIGINT signal" >> /tmp/UMS.sh
echo " running && { \\" >> /tmp/UMS.sh
echo " echo >&2 \"Using kill -s SIGINT instead\"; \\" >> /tmp/UMS.sh
echo " echo >&2 \"If you see this message again, then you should increase the value of DODTIME in '\$0'.\"; \\" >> /tmp/UMS.sh
echo " kill -2 \$pid; \\" >> /tmp/UMS.sh
echo " }" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log\" ]; then" >> /tmp/UMS.sh
echo " count=9" >> /tmp/UMS.sh
echo " while [ \$count -ge 1 ]" >> /tmp/UMS.sh
echo " do" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log.\$count\" ]; then" >> /tmp/UMS.sh
echo " plus=\$((count+1))" >> /tmp/UMS.sh
echo " mv \"/usr/share/ums/debug.log.\$count\" \"/usr/share/ums/debug.log.\$plus\"" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo " count=\$((count-1))" >> /tmp/UMS.sh
echo " done" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log\" ]; then" >> /tmp/UMS.sh
echo " mv \"/usr/share/ums/debug.log\" \"/usr/share/ums/debug.log.1\"" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo " return 0" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "do_force-stop(){" >> /tmp/UMS.sh
echo " running || { warnout \"\$NAME is NOT running \!\"; exit 0; } " >> /tmp/UMS.sh
echo " echo \"Stopping \$DESC : \$NAME\"" >> /tmp/UMS.sh
echo " kill -9 \$pid" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log\" ]; then" >> /tmp/UMS.sh
echo " count=9" >> /tmp/UMS.sh
echo " while [ \$count -ge 1 ]" >> /tmp/UMS.sh
echo " do" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log.\$count\" ]; then" >> /tmp/UMS.sh
echo " plus=\$((count+1))" >> /tmp/UMS.sh
echo " mv \"/usr/share/ums/debug.log.\$count\" \"/usr/share/ums/debug.log.\$plus\"" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo " count=\$((count-1))" >> /tmp/UMS.sh
echo " done" >> /tmp/UMS.sh
echo " if [ -e \"/usr/share/ums/debug.log\" ]; then" >> /tmp/UMS.sh
echo " mv \"/usr/share/ums/debug.log\" \"/usr/share/ums/debug.log.1\"" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo " fi" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "do_status(){" >> /tmp/UMS.sh
echo " echo -n \" * \$NAME is \"" >> /tmp/UMS.sh
echo " ( running || { echo \"NOT running \"; exit 0; } )" >> /tmp/UMS.sh
echo " ( running && { echo \"running (PID -> \$(echo \$pid))\"; exit 0; } )" >> /tmp/UMS.sh
echo "}" >> /tmp/UMS.sh
echo "#--------------------------------------------------------------------------" >> /tmp/UMS.sh
echo "case \"\$1\" in" >> /tmp/UMS.sh
echo "" >> /tmp/UMS.sh
echo " start|stop|force-stop|status)" >> /tmp/UMS.sh
echo " do_\${1}" >> /tmp/UMS.sh
echo " ;;" >> /tmp/UMS.sh
echo " restart|reload)" >> /tmp/UMS.sh
echo " do_stop" >> /tmp/UMS.sh
echo " do_start" >> /tmp/UMS.sh
echo " ;;" >> /tmp/UMS.sh
echo " force-restart|force-reload)" >> /tmp/UMS.sh
echo " do_force-stop" >> /tmp/UMS.sh
echo " do_start" >> /tmp/UMS.sh
echo " ;;" >> /tmp/UMS.sh
echo " *)" >> /tmp/UMS.sh
echo " echo \"Usage: \$SCRIPTNAME {start|stop|force-stop|restart|force-restart|reload|force-reload|status}\"" >> /tmp/UMS.sh
echo " exit 1" >> /tmp/UMS.sh
echo " ;;" >> /tmp/UMS.sh
echo "esac" >> /tmp/UMS.sh
sudo mv /tmp/UMS.sh /etc/init.d/UMS.sh
sudo mkdir /root/.config/UMS > /dev/null 2>&1
sudo touch /root/.config/UMS/UMS.conf > /dev/null 2>&1
sudo touch /root/.config/UMS/UMS.cred > /dev/null 2>&1
sudo ln -s /root/.config/UMS/UMS.conf /etc/UMS.sh > /dev/null 2>&1
sudo ln -s /root/.config/UMS/UMS.cred /etc/UMS.cred > /dev/null 2>&1
sudo chmod +x /etc/init.d/UMS.sh > /dev/null 2>&1
sudo update-rc.d UMS.sh defaults > /dev/null 2>&1
cd "$pasta"