eg-blog

Feed Rss

Archive for the ‘Subsonic on Synology DS’ Category

There it is: The new package.

After testing, scripting, reinstalling, testing again dozens of times.

At first the little things:

  • New icons for DSM 4.2
  • Minisub is now called Jamstash, it got a new icon as well
  • Jamstash now opens in an DSM internal window (you can still access it by adding /mini to your Subsonic url

The technical changes:

After hours and countless fails I’ve given up my “build your own ffmpeg” project. Which means this package comes without any transcoding features.

However there is a workaround thanks to Timo from timokisig.de.

Patters, the developer of the Java and Serviio packages always brings his Serviio packages with his own Synology ffmeg binaries, so I am now using his compilations. If you have Serviio installed already you can just update Subsonic and it will use Serviios binaries automatically. For those who haven’t but want to use transcoding:

Install Serviio first (it doesn’t have to be running).

Afterwards access your DS via SSH and type:

ln -s /var/packages/Serviio/target/bin/ffmpeg /var/packages/Subsonic/transcode/ffmpeg

To make it work smoothly you have to change the Subsonic transcoding line.

In Subsonic go to Settings->transcoding and look for the downsampling command. change it to:

ffmpeg -i %s -ab %bk -v 0 -vn -f mp3 -

 

Unfortunately there are still some bugs:

  • Hibernating still doesn’t work (it only works with Madsonic but I don’t have a clue why)
  • Subsonic may crash during the update process. I recommend to stop Subsonic before updating and wait at least a minute to start the update. Never stop Subsonic while it is scanning its library!

I really hope this one works better than the last packages.

 

scripts:

installer.sh

#!/bin/sh

#--------Subsonic installer script
#--------package maintained at eg-blog.de

#SYNO_CPU_ARCH="`uname -m`"
#NATIVE_BINS_FILE="serviio-native-${SYNO_CPU_ARCH}.tgz"  

source /etc/profile
TEMP_FOLDER="`find / -maxdepth 2 -name '@tmp' | head -n 1`"
PUBLIC_FOLDER="`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,4}\/public).*$/\1/'`"

PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | head -n 1 | awk '{print $1}'`
	echo "$(date +%d.%m.%y_%H:%M:%S): looking for PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
}


preinst ()
{
	source /etc/profile

	########################################
	#check if Java is installed

	if [ -z ${JAVA_HOME} ]; then
		echo "Java is not installed or not properly configured. JAVA_HOME is not defined. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	if [ ! -f ${JAVA_HOME}/bin/java ]; then
		echo "Java is not installed or not properly configured. The Java binary could not be located. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): found Java in ${JAVA_HOME}" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	
	#########################################
	#check if Subsonic folder is in public folder wehn restore is selected
	if [ ! -z ${install_restore} ]; then
		

		if [ ! -d $PUBLIC_FOLDER/Subsonic ]; then
			echo "Can't find a folder named 'Subsonic' in your public folder. " > $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Can't find a folder named 'Subsonic' in your public folder. " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> $SYNOPKG_TEMP_LOGFILE	
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			exit 1
		fi
	fi

	#########################################
	#is the User Home service enabled?
	UH_SERVICE=maybe
	synouser --add userhometest Testing123 "User Home test user" 0 "" ""
	UHT_HOMEDIR=`cat /etc/passwd | sed -r '/User Home test user/!d;s/^.*:User Home test user:(.*):.*$/\1/'`
	if echo $UHT_HOMEDIR | grep '/var/services/homes/' > /dev/null; then
		if [ ! -d $UHT_HOMEDIR ]; then
			UH_SERVICE=false
		fi
	fi
	synouser --del userhometest
	if [ ${UH_SERVICE} == "false" ]; then
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> $SYNOPKG_TEMP_LOGFILE
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else 
		echo "$(date +%d.%m.%y_%H:%M:%S): User home is enabled" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	
	exit 0
}


postinst ()
{
	#create subsonic daemon user
	synouser --add subsonic `${SYNOPKG_PKGDEST}/passgen 1 20` "Subsonic daemon user" 0 "" ""
	echo "$(date +%d.%m.%y_%H:%M:%S): create subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#determine the subsonic user homedir and save that variable in the user's profile
	#this is needed because librtmp needs to write a file called ~/.swfinfo
	#and new users seem to inherit a HOME value of /root which they have no permissions for
	SUBSONIC_HOMEDIR=`cat /etc/passwd | sed -r '/Subsonic daemon user/!d;s/^.*:Subsonic daemon user:(.*):.*$/\1/'`
	su - subsonic -s /bin/sh -c "echo export HOME=${SUBSONIC_HOMEDIR} >> .profile"

	
	#use the ffmpeg from serviio if available
        mkdir ${SYNOPKG_PKGDEST}/transcode
	if [ -f /var/packages/Serviio/target/bin/ffmpeg ]; then
		ln -s /var/packages/Serviio/target/bin/ffmpeg ${SYNOPKG_PKGDEST}/transcode/ffmpeg
		echo "$(date +%d.%m.%y_%H:%M:%S): Linked ffmpeg file to Serviio" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	
	#########################################
	##start Subsonic
	#fix file permissions
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic-booter-jar-with-dependencies.jar
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic.war
	chown -R subsonic:users ${SYNOPKG_PKGDEST}
	echo "$(date +%d.%m.%y_%H:%M:%S): start Subsonic for first initialisation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#set up symlink for the DSM GUI
	ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
			
	#create custom temp folder so temp files can be bigger
	if [ ! -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
	fi
	#create symlink to the created directory
	if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic /tmp/
	fi


	#start subsonic as subsonic user
	su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh

	sleep 10
	
	subsonic_get_pid
	if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo "Error: Can not start Subsonic during install" >> $SYNOPKG_TEMP_LOGFILE
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic during install" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	#give it some time to start up
	sleep 90

	#stop subsonic

	kill $PID
	sleep 5
	echo "$(date +%d.%m.%y_%H:%M:%S): Stopped Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	
	#Jamstash Update
	if [ -d /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/ ]; then 
		rm -r /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/*
		cp -r ${SYNOPKG_PKGDEST}/Jamstash/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
		echo "$(date +%d.%m.%y_%H:%M:%S): updated Jamstash" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can't find the Jamstash directory -> Jamstash will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo "Error: Can't find the Jamstash directory -> Jamstash will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log >> $SYNOPKG_TEMP_LOGFILE	
		exit 1
	fi
	rm -r ${SYNOPKG_PKGDEST}/Jamstash
	
	#Jamstash Link
	echo "$(date +%d.%m.%y_%H:%M:%S): create Jamstash DSM link" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	if [ -d ${SYNOPKG_PKGDEST}/Jamstashlink/ ]; then
		cp ${SYNOPKG_PKGDEST}/Jamstashlink/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
	fi
	rm -r ${SYNOPKG_PKGDEST}/Jamstashlink
	####################################

	#delete symlink
	rm /usr/syno/synoman/webman/3rdparty/Subsonic
	#delete temp files
	if [ -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
	fi


	#check Podcast folder for right permissions
	if [ -d /volume1/music/Podcast ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): reset permissions of Podcast folder (subsonic user has new uid)" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		chown -R admin:users /volume1/music/Podcast
		chmod -R 775 /volume1/music/Podcast	
	fi

	#########################################
	#install user backup from public folder

	if [ ! -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore previously made backup fron public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		#copy files
		cp -r ${PUBLIC_FOLDER}/Subsonic/* ${SYNOPKG_PKGDEST}/

		#new files might not be owned by subsonic user
		chown -R subsonic ${SYNOPKG_PKGDEST}/
			
		#make the Subsonic start script executable
		chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh 
	fi
	echo "$(date +%d.%m.%y_%H:%M:%S): ----installation complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 0
}


preuninst ()
{
	##############################################
	#stop Subsonic if it is running

	subsonic_get_pid
	if [ -z $PID ]; then
		sleep 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 5
		if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
			rm /usr/syno/synoman/webman/3rdparty/Subsonic
		fi

		if [ -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
			rm -r ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
		fi
	fi

	##############################################
	# create a backup in public folder in public folder
	if [ ! -z ${uninstall_backup} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): Create a backup of Subsonic in public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		
		if [ ! -d ${PUBLIC_FOLDER}/Subsonic ]; then
			mkdir ${PUBLIC_FOLDER}/Subsonic
		fi
		
		cp ${SYNOPKG_PKGDEST}/subsonic.properties *.index ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/db ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/lucene ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/thumbs ${PUBLIC_FOLDER}/Subsonic
	fi
	
	exit 0
}


postuninst ()
{
	synouser --del subsonic

	#remove DSM icon symlink
	if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
	fi

	#remove temp symlink
	rm /tmp/subsonic

	exit 0
}


preupgrade ()
{
	###########################
	#stop Subsonic if it is runing
	
	subsonic_get_pid
	if [ ! -z $PID ]; then 
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 5
	fi

	if [ -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
	fi

	###########################
	#backup subsonic.properties and db Folder

	if [ -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): create backup of Subsonic db in temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		if [ ! -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
			mkdir ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp ${SYNOPKG_PKGDEST}/subsonic.properties ${SYNOPKG_PKGDEST}*.index ${SYNOPKG_PKGDEST}/../subsonic_update_backup/
			cp -r ${SYNOPKG_PKGDEST}/db ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/lucene ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/thumbs ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		fi
	fi

	exit 0
}


postupgrade ()
{

	###############################
	#restore subsonic db index and settings
	if [ ! -z ${install_update} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore from temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		cp -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup/* ${SYNOPKG_PKGDEST}/
	fi	

	#remove backup folder
	#remove the next lines to keep a backup in the @appstore folder
	if [ -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): remove temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup
	fi


	#subsonic may not own all new files
	chown -R subsonic ${SYNOPKG_PKGDEST}/

	#make the Subsonic start script executable
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh 

	echo "$(date +%d.%m.%y_%H:%M:%S): ----update complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	exit 0
}

start-stop-status

 
#!/bin/sh

#--------Subsonic start-stop-status script
#--------package maintained at eg-blog.de

##############################################
#function to get the process id of Subsonic
PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | head -n 1 | awk '{print $1}'`
	#echo "$(date +%d.%m.%y_%H:%M:%S): looking for PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
}
get_time()
{
	TIME=$(date +%d.%m.%y_%H:%M:%S)
}

case "$1" in
   start)
	  ###---copied from patters start-stop-status.sh of his crashplan proe package---
	  DAEMON_ID="${SYNOPKG_PKGNAME} daemon user"
	  DAEMON_HOME="`cat /etc/passwd | grep "${DAEMON_ID}" | cut -f6 -d':'`"
    
	  #set the current timezone for Java so that log timestamps are accurate
	  #we need to use the modern timezone names so that Java can figure out DST 
	  SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'`
	  SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"`
	  grep "^export TZ" ${DAEMON_HOME}/.profile > /dev/null \
	  && sed -i "s%^export TZ=.*$%export TZ='${SYNO_TZ}'%" ${DAEMON_HOME}/.profile \
	  ###---end of copy---------------------------------------------------------------
	  
	  #set up symlinks for the DSM GUI icon
	  #Subsonic main
	  if [ -d /usr/syno/synoman/webman/3rdparty ]; then
		ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		
		#Jamstash
		if [ -d ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini ]; then
			ln -s ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini /usr/syno/synoman/webman/3rdparty/Subsonic_Jamstash
			echo "$(date +%d.%m.%y_%H:%M:%S): Jamstash DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
	else 
		echo "$(date +%d.%m.%y_%H:%M:%S) : Error: Directory for Subsonic DSM link was not found" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
      #create custom temp folder so temp files can be bigger
	  if [ ! -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  #create symlink to the created directory
	  if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic /tmp/
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  # starting subsonic as subsonic daemon user
	  echo "$(date +%d.%m.%y_%H:%M:%S): starting Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
      sleep 10
	  echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  subsonic_get_pid
	  if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is running----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  else
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	  fi
	   
	  exit 0
   ;;
   stop)
      #stop subsonic
	  subsonic_get_pid
      kill $PID
	  echo "$(date +%d.%m.%y_%H:%M:%S) : killed Subsonic PID: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      sleep 2 
	  #delete Symlinks and DSM icon
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_Jamstash ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_Jamstash
		echo "$(date +%d.%m.%y_%H:%M:%S): Jamstash DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -d ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST_VOL}/@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp files deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /tmp/subsonic ]; then
		rm /tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is stopped----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  exit 0
   ;;
   status)
      subsonic_get_pid
      if [ -z  $PID ]; then
	  #Subsonic is not running
		exit 3
	  else
	  #subsonic is running
		exit 0
      fi
   ;;
   log)
	  echo "${SYNOPKG_PKGDEST}/subsonic_package.log"
	  exit 0
   ;;
esac

 

 

OK I’ve done a lot today but I’m still not finished (for example the new 120×120 icon doesn’t show up in package manager)

My current version is online at my Dropbox folder

https://www.dropbox.com/sh/y9lcl2xsznvve80/31mcnc5gpE

 

a quick changelog:

 

subsonic4.8-032
o fixed some bugs
o added 120×120 package icon
o updated package compatibily to DSM 4.2
o MiniSub is now called Jamstash
o updated Jamstash DSM icon (thaks to KicknGuitar from the Subsonic Forum)
o contains Jamstash to 2.4.1
o contains Subsonic 4.8

So everyone who likes fiddling around with stuff pleas install this version and report any bugs to me especially if you own a x86 or power pc DS.

 

known bugs: DS doesn’t go in sleep mode, transcoding is buggy, 120×120 icon doesn’t work,

 

If you get any error during installation pleas check the /usr/syno/synoman/webman/3rdparty folder it should just contain Symlinks to different packages no actaul folders or files. If there are files or folders delete them, uninstall the package and install it again.

 

Good night and good luck, Eric ;)

 

 

As many of you are struggling with my “new scripted” versions 029 and 030 I rolled back to the 028, which means:

  • no downloading during install is required
  • because of that the .spk file contains everything that is needed to run Subsonic on all three plattforms (x86, ARM and PPC)

Another point is the separation of Subsonic and Madsonic (aka MashupMod) which means that from now on there are two independent packages. You can only install one at a time. I had to do this because a package that contains both would just be to large. Also I can now update the Madsonic package without touching the original one.

Also I have removed the Subtunes interface because I didn’t like it and it doesn’t seem to be continued anymore.

In DSM 4.2 “Perl” becomes an official Synology package. It was installed by default before, so I didn’t care about whether it’s installed or not. It is required during the installation process. Please make sure it is installed before you start the Subsonic installation.

 

By now both packages are available in my Dropbox beta Folder only:

https://www.dropbox.com/sh/y9lcl2xsznvve80/31mcnc5gpE

Madsonic4.7-B3158SE-001.spk

Subsonic4.7-031.spk

Please let me know whats wrong with these ones, especially during install and startup (I haven’t worked on the transcoding problems)

 

I haven’t encountered any problems using DSM 4.2. In fact I like the new package center design. I’ve added a few screen shots to the information section of Subsonic and ownCloud.

Edit: As you can see in the comments many of you are still having problems on this use the 029 version from my dropbox folder!
https://www.dropbox.com/sh/vd06e2fn2157gh0/kE6FO5J1cD

 

Hey I am back online and made a new package.

I’m sorry that it won’t please all of you (e.g. the flac transcoding still doesn’t work).

But there are a few fixes in it. All download problems should have been fixed. The Process ID check needed for start and stop procedure has been updated again. All additional packages are now up to date…

The Hibernation should work now (at least with the MashupMod version). I have done a lot of testing with this one, it doesn’t work right from the start but after a few hours when everything is scanned and sorted out the HDDs should stop, and the DiskStation goes into hibernation mode. After that the hibernation behaves like configured in DSM. The DS seems to wake up from time to time for no reason, but I encountered that before even with Subsonic stopped or uninstalled.

Because I just own an ARM DiskStation I can’t do any bug fixing on other DiskStations so please let me know if everything woks as described above or not.

Now have fun with it ;)

PS: I have to work away for the next Weeks so I’m not able to fix anything until I’m home again, but I will try to help you as much as I can ;)

Scripts:

installer.sh

#!/bin/sh

#--------Subsonic installer script
#--------package maintained at eg-blog.de

DOWNLOAD_URL_STANDARD="http://sourceforge.net/projects/subsonic/files/subsonic/4.7/subsonic-4.7-standalone.tar.gz/download"
DOWNLOAD_URL_MASHUPMOD="https://www.dropbox.com/s/71lxyirndqv0dgr/MashupMod-4.7_B3158SE.zip"
DOWNLOAD_URL_SUBTUNES="http://subtunes.googlecode.com/files/subtunes-0.9.4b.zip"
DOWNLOAD_URL_MINISUB="https://github.com/tsquillario/MiniSub/tarball/master"
SYNO_CPU_ARCH="`uname -m`"
NATIVE_BINS_URL="http://eg-blog.de/download/serviio-native-${SYNO_CPU_ARCH}.tgz"
NATIVE_BINS_FILE="`echo ${NATIVE_BINS_URL} | sed -r "s%^.*/(.*)%\1%"`"

SHA256_MINISUB="ce4acaa38dc9f3f893f04e49db9f98cd1e4d01a9451539a283156cd0c1158079"
SHA256_SUBTUNES="9b9be0d3be3dcb0154032d282e144f1a1ba59530aa437e0e5dd4eb01bc6b2c5d"
SHA256_MASHUPMOD="47a274b30d1387a069c13b72789bbfdca57e182d6efc7e5c64f14d216518746b"
SHA256_STANDARD="cb798a007a862b2e66ab1d7d345753b157ae287e5dccb094976d02305926bad0"
SHA256_armv5tel="9eeb23f4c5746ba495a014b6e30326c7762de0fd06f728e1092b40d59b7d019b"
SHA256_ppc="26ee8e796d752ee6c26fdd64726fb7aa4240d381efe2a26a464ca21a4949e11b"
SHA256_x86_64="62301d3461166b52724b55d32fb493f9b564aded9eba4fdff9b98bb3c83fdca1"

source /etc/profile
TEMP_FOLDER="`find / -maxdepth 2 -name '@tmp' | head -n 1`"
PUBLIC_FOLDER="`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,4}\/public).*$/\1/'`"

PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
	echo "$(date +%d.%m.%y_%H:%M:%S): looking for PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
}

preinst ()
{
	source /etc/profile

	########################################
	#check if Java is installed

	if [ -z ${JAVA_HOME} ]; then
		echo "Java is not installed or not properly configured. JAVA_HOME is not defined. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	if [ ! -f ${JAVA_HOME}/bin/java ]; then
		echo "Java is not installed or not properly configured. The Java binary could not be located. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): found Java in ${JAVA_HOME}" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#########################################
	#check if Subsonic folder is in public folder wehn restore is selected
	if [ ! -z ${install_restore} ]; then

		if [ ! -d $PUBLIC_FOLDER/Subsonic ]; then
			echo "Can't find a folder named 'Subsonic' in your public folder. " > $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Can't find a folder named 'Subsonic' in your public folder. " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			exit 1
		fi
	fi

	#########################################
	#is the User Home service enabled?
	UH_SERVICE=maybe
	synouser --add userhometest Testing123 "User Home test user" 0 "" ""
	UHT_HOMEDIR=`cat /etc/passwd | sed -r '/User Home test user/!d;s/^.*:User Home test user:(.*):.*$/\1/'`
	if echo $UHT_HOMEDIR | grep '/var/services/homes/' > /dev/null; then
		if [ ! -d $UHT_HOMEDIR ]; then
			UH_SERVICE=false
		fi
	fi
	synouser --del userhometest
	if [ ${UH_SERVICE} == "false" ]; then
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> $SYNOPKG_TEMP_LOGFILE
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): User home is enabled" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	exit 0
}

postinst ()
{
	#create subsonic daemon user
	synouser --add subsonic `${SYNOPKG_PKGDEST}/passgen 1 20` "Subsonic daemon user" 0 "" ""
	echo "$(date +%d.%m.%y_%H:%M:%S): create subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#determine the subsonic user homedir and save that variable in the user's profile
	#this is needed because librtmp needs to write a file called ~/.swfinfo
	#and new users seem to inherit a HOME value of /root which they have no permissions for
	SUBSONIC_HOMEDIR=`cat /etc/passwd | sed -r '/Subsonic daemon user/!d;s/^.*:Subsonic daemon user:(.*):.*$/\1/'`
	su - subsonic -s /bin/sh -c "echo export HOME=${SUBSONIC_HOMEDIR} >> .profile"

	#########################################
	##download stuff
	#select the right mods / version to download/install
	if [ ! -z ${mashupmod_install} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): download and install MashupMod" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		#download Mashupmod
		wget ${DOWNLOAD_URL_MASHUPMOD} --no-check-certificate --output-document=${SYNOPKG_PKGDEST}/MashupMod.zip
		if [ -f ${SYNOPKG_PKGDEST}/MashupMod.zip ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): downloaded MashupMod from $DOWNLOAD_URL_MASHUPMOD" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			#CheckSum
			if [ `/opt/bin/sha256sum ${SYNOPKG_PKGDEST}/MashupMod.zip  | awk '{ print $1 }` = $SHA256_MASHUPMOD ]; then
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum OK" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum failed for MashupMod.zip" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
				echo "SHA256 checksum failed for MashupMod.zip. The file was probaply modified or updated" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi
		else
			if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/Mashupmod.zip ]; then
				cp ${PUBLIC_FOLDER}/Mashupmod.zip ${SYNOPKG_PKGDEST}
				echo "$(date +%d.%m.%y_%H:%M:%S): copied Mashupmod install files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "There was a problem downloading  Mashupmod from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
				echo "which was ${DOWNLOAD_URL_MASHUPMOD}" >> $SYNOPKG_TEMP_LOGFILE
				echo "Alternatively, you may download this file manually and place it in the 'public' shared folder. and name it Mashupmod.zip" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi
		fi
		unzip ${SYNOPKG_PKGDEST}/MashupMod.zip -d ${SYNOPKG_PKGDEST}
		echo "$(date +%d.%m.%y_%H:%M:%S): extracted MashupMod" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm ${SYNOPKG_PKGDEST}/MashupMod.zip
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		#download Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): download and install Subsonic standard" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		wget ${DOWNLOAD_URL_STANDARD} --output-document=${SYNOPKG_PKGDEST}/Subsonic.tgz
		if [ -f ${SYNOPKG_PKGDEST}/Subsonic.tgz ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): downloaded Subsonic install file from $DOWNLOAD_URL_STANDARD" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			#Checksum
			if [ `/opt/bin/sha256sum ${SYNOPKG_PKGDEST}/Subsonic.tgz  | awk '{ print $1 }` = $SHA256_STANDARD ]; then
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum OK" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum failed for Subsonic.tgz" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
				echo "SHA256 checksum failed for Subsonic.tgz. The file was probaply modified or updated" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi
		else
			if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/Subsonic.tar.gz ]; then
				cp ${PUBLIC_FOLDER}/Subsonic.tgz ${SYNOPKG_PKGDEST}
				echo "$(date +%d.%m.%y_%H:%M:%S): copied Subsonic install files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "There was a problem downloading  Subsonic from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
				echo "which was ${DOWNLOAD_URL_STANDARD}" >> $SYNOPKG_TEMP_LOGFILE
				echo "Alternatively, you may download this file manually and place it in the 'public' shared folder. and name it Subsonic.tgz" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi

		fi
		tar xzf ${SYNOPKG_PKGDEST}/Subsonic.tgz -C ${SYNOPKG_PKGDEST}
		echo "$(date +%d.%m.%y_%H:%M:%S): extracted Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm ${SYNOPKG_PKGDEST}/Subsonic.tgz
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	fi
	#delete the original subsonic.sh and use the edited file for Synology
	if [ -f ${SYNOPKG_PKGDEST}/subsonic.sh ]; then
		rm ${SYNOPKG_PKGDEST}/subsonic.sh
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted original subsonic.sh file" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	if [ -f ${SYNOPKG_PKGDEST}/subsonic_synology.sh ]; then
		mv ${SYNOPKG_PKGDEST}/subsonic_synology.sh ${SYNOPKG_PKGDEST}/subsonic.sh
		echo "$(date +%d.%m.%y_%H:%M:%S): now using edited subsonic.sh file for Synology" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#download and install ffmpeg binarys
	wget ${NATIVE_BINS_URL} --output-document=${SYNOPKG_PKGDEST}/ffmpeg.tgz
	if [ -f ${SYNOPKG_PKGDEST}/ffmpeg.tgz ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): downloaded ffmpeg files from $NATIVE_BINS_URL" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		#Checksum
		if [ `/opt/bin/sha256sum ${SYNOPKG_PKGDEST}/ffmpeg.tgz  | awk '{ print $1 }` = $(eval "echo \$SHA256_$SYNO_CPU_ARCH") ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum OK" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum failed for ffmpeg.tgz" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "SHA256 checksum failed for ffmpeg.tgz. The file was probaply modified or updated" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
	else
		if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/ffmpeg.tgz ]; then
			cp ${PUBLIC_FOLDER}/ffmpeg.tgz ${SYNOPKG_PKGDEST}
			echo "$(date +%d.%m.%y_%H:%M:%S): copied ffmpeg files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "There was a problem downloading  ffmpeg from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
			echo "which was ${NATIVE_BINS_URL}" >> $SYNOPKG_TEMP_LOGFILE
			echo "Alternatively, you may download this file manually and place it in the 'public' shared folder and neme it ffmpeg.tgz" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
	fi
	if [ ! -d  ${SYNOPKG_PKGDEST}/transcode ]; then
		mkdir ${SYNOPKG_PKGDEST}/transcode
		echo "$(date +%d.%m.%y_%H:%M:%S): created transcode directory" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	if [ ! -d  ${SYNOPKG_PKGDEST}/lib ]; then
		mkdir ${SYNOPKG_PKGDEST}/lib
		echo "$(date +%d.%m.%y_%H:%M:%S): created lib directory" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	tar xzvf ${SYNOPKG_PKGDEST}/ffmpeg.tgz -C ${SYNOPKG_PKGDEST}/transcode
	cp -r ${SYNOPKG_PKGDEST}/transcode/lib* ${SYNOPKG_PKGDEST}/lib/
	rm -r ${SYNOPKG_PKGDEST}/transcode/lib*
	rm ${SYNOPKG_PKGDEST}/ffmpeg.tgz
	echo "$(date +%d.%m.%y_%H:%M:%S): copied ffmpeg file and libraries" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#########################################
	##start Subsonic
	#fix file permissions
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic-booter-jar-with-dependencies.jar
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic.war
	chown -R subsonic:users ${SYNOPKG_PKGDEST}
	echo "$(date +%d.%m.%y_%H:%M:%S): start Subsonic for first initialisation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#set up symlink for the DSM GUI
	ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic

	#create custom temp folder so temp files can be bigger
	if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi
	#create symlink to the created directory
	if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
	fi

	#start subsonic as subsonic user
	su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh

	sleep 5

	subsonic_get_pid
	if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo "Error: Can not start Subsonic during install" >> $SYNOPKG_TEMP_LOGFILE
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic during install" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	#give it some time to start up
	sleep 90

	#stop subsonic

	kill $PID
	sleep 5
	echo "$(date +%d.%m.%y_%H:%M:%S): Stopped Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	####################################
	##download and install additional features
	echo "$(date +%d.%m.%y_%H:%M:%S): Download and install additional Features" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	#Subtunes
	if [ ! -z ${subtunes_install} ]; then
		wget ${DOWNLOAD_URL_SUBTUNES}  --output-document=${SYNOPKG_PKGDEST}/Subtunes.zip
		if [ -f ${SYNOPKG_PKGDEST}/Subtunes.zip ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): Downloaded Subtunes" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			#Checksum
			if [ `/opt/bin/sha256sum ${SYNOPKG_PKGDEST}/Subtunes.zip  | awk '{ print $1 }` = $SHA256_SUBTUNES ]; then
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum OK" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum failed for Subtunes.zip" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
				echo "SHA256 checksum failed for Subtunes.zip. The file was probaply modified or updated" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi
			mkdir ${SYNOPKG_PKGDEST}/Subtunes
			unzip ${SYNOPKG_PKGDEST}/Subtunes.zip -d ${SYNOPKG_PKGDEST}/Subtunes/
			echo "$(date +%d.%m.%y_%H:%M:%S): extracted Subtunes" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: Subtunes could not be downloaded" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check the internet connection of your Diskstation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: Subtunes could not be downloaded" > $SYNOPKG_TEMP_LOGFILE
			echo "Please check the internet connection of your Diskstation" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi

		cp -r ${SYNOPKG_PKGDEST}/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/
		rm -r ${SYNOPKG_PKGDEST}/Subtunes
		rm ${SYNOPKG_PKGDEST}/Subtunes.zip

		echo "$(date +%d.%m.%y_%H:%M:%S): copied Subtunes and deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		#Subtuneslink
		if [ -d ${SYNOPKG_PKGDEST}/Subtuneslink ]; then
			cp ${SYNOPKG_PKGDEST}/Subtuneslink/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/Subtunes/
		fi

	fi
	rm -r ${SYNOPKG_PKGDEST}/Subtuneslink

	#MiniSub Update
	if [ ! -z ${minisub_install} ]; then
		wget ${DOWNLOAD_URL_MINISUB} --no-check-certificate --output-document=${SYNOPKG_PKGDEST}/MiniSub.tgz
		if [ -f ${SYNOPKG_PKGDEST}/MiniSub.tgz ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): Downloaded MiniSub" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
						#Checksum
			#if [ `/opt/bin/sha256sum ${SYNOPKG_PKGDEST}/MiniSub.tgz  | awk '{ print $1 }` = $SHA256_MINISUB ]; then
			#	echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum OK" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			#else
			#	echo "$(date +%d.%m.%y_%H:%M:%S): SHA256 checksum failed for MiniSub.tgz" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			#	echo "SHA256 checksum failed for MiniSub.tgz. The file was probaply modified or updated" >> $SYNOPKG_TEMP_LOGFILE
			#fi
			mkdir ${SYNOPKG_PKGDEST}/MiniSub
			tar xzf ${SYNOPKG_PKGDEST}/MiniSub.tgz -C ${SYNOPKG_PKGDEST}/MiniSub
			echo "$(date +%d.%m.%y_%H:%M:%S): extracted MiniSub" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: MiniSub could not be downloaded" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check the internet connection of your Diskstation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: MiniSub could not be downloaded" > $SYNOPKG_TEMP_LOGFILE
			echo "Please check the internet connection of your Diskstation" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
		if [ -d /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/ ]; then
			rm -r /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/*
			cp -r ${SYNOPKG_PKGDEST}/MiniSub/*/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can't find the MiniSub directory -> MiniSub will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: Can't find the MiniSub directory -> MiniSub will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
		rm -r ${SYNOPKG_PKGDEST}/MiniSub
		rm ${SYNOPKG_PKGDEST}/MiniSub.tgz
		echo "$(date +%d.%m.%y_%H:%M:%S): copied MiniSub and deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#MiniSub Link
	echo "$(date +%d.%m.%y_%H:%M:%S): create MiniSub DSM link" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	if [ -d ${SYNOPKG_PKGDEST}/MiniSublink/ ]; then
		cp ${SYNOPKG_PKGDEST}/MiniSublink/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
	fi
	rm -r ${SYNOPKG_PKGDEST}/MiniSublink
	####################################

	#delete symlink
	rm /usr/syno/synoman/webman/3rdparty/Subsonic
	#delete temp files
	if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi

	#check Podcast folder for right permissions
	if [ -d /volume1/music/Podcast ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): reset permissions of Podcast folder (subsonic user has new uid)" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		chown -R admin:users /volume1/music/Podcast
		chmod -R 775 /volume1/music/Podcast
	fi

	#########################################
	#install user backup from public folder

	if [ ! -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore previously made backup fron public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		#copy files
		cp -r ${PUBLIC_FOLDER}/Subsonic/* ${SYNOPKG_PKGDEST}/

		#new files might not be owned by subsonic user
		chown -R subsonic ${SYNOPKG_PKGDEST}/

		#make the Subsonic start script executable
		chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
	fi
	echo "$(date +%d.%m.%y_%H:%M:%S): ----installation complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 0
}

preuninst ()
{
	##############################################
	stop Subsonic if it is running

	subsonic_get_pid
	if [ -z $PID ]; then
		sleep 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 5
		if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
			rm /usr/syno/synoman/webman/3rdparty/Subsonic
		fi

		if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
			rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		fi
	fi

	##############################################
	# create a backup in public folder in public folder
	if [ ! -z ${uninstall_backup} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): Create a backup of Subsonic in public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		if [ ! -d ${PUBLIC_FOLDER}/Subsonic ]; then
			mkdir ${PUBLIC_FOLDER}/Subsonic
		fi

		cp ${SYNOPKG_PKGDEST}/subsonic.properties *.index ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/db ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/lucene ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/thumbs ${PUBLIC_FOLDER}/Subsonic
	fi

	exit 0
}

postuninst ()
{
	synouser --del subsonic

	#remove DSM icon symlink
	if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
	fi

	#remove temp symlink
	rm /tmp/subsonic

	exit 0
}

preupgrade ()
{
	###########################
	#stop Subsonic if it is runing

	subsonic_get_pid
	if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 5
	fi

	if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi

	###########################
	#backup subsonic.properties and db Folder

	if [ -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): create backup of Subsonic db in temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		if [ ! -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
			mkdir ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp ${SYNOPKG_PKGDEST}/subsonic.properties ${SYNOPKG_PKGDEST}*.index ${SYNOPKG_PKGDEST}/../subsonic_update_backup/
			cp -r ${SYNOPKG_PKGDEST}/db ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/lucene ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/thumbs ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		fi
	fi

	exit 0
}

postupgrade ()
{

	###############################
	#restore subsonic db index and settings
	if [ ! -z ${install_update} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore from temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		cp -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup/* ${SYNOPKG_PKGDEST}/
	fi

	#remove backup folder
	#remove the next lines to keep a backup in the @appstore folder
	if [ -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): remove temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup
	fi

	#subsonic may not own all new files
	chown -R subsonic ${SYNOPKG_PKGDEST}/

	#make the Subsonic start script executable
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh

	echo "$(date +%d.%m.%y_%H:%M:%S): ----update complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	exit 0
}

start-stop-status

#!/bin/sh

#--------Subsonic start-stop-status script
#--------package maintained at eg-blog.de

##############################################
#function to get the process id of Subsonic
PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
	#echo "$(date +%d.%m.%y_%H:%M:%S): looking for PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
}
get_time()
{
	TIME=$(date +%d.%m.%y_%H:%M:%S)
}

case "$1" in
   start)
	  ###---copied from patters start-stop-status.sh of his crashplan proe package---
	  DAEMON_ID="${SYNOPKG_PKGNAME} daemon user"
	  DAEMON_HOME="`cat /etc/passwd | grep "${DAEMON_ID}" | cut -f6 -d':'`"

	  #set the current timezone for Java so that log timestamps are accurate
	  #we need to use the modern timezone names so that Java can figure out DST
	  SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'`
	  SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"`
	  grep "^export TZ" ${DAEMON_HOME}/.profile > /dev/null \
	  && sed -i "s%^export TZ=.*$%export TZ='${SYNO_TZ}'%" ${DAEMON_HOME}/.profile \
	  ###---end of copy---------------------------------------------------------------

	  #set up symlinks for the DSM GUI icon
	  #Subsonic main
	  if [ -d /usr/syno/synoman/webman/3rdparty ]; then
		ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		#MiniSub
		if [ -d ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini ]; then
			ln -s ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
			echo "$(date +%d.%m.%y_%H:%M:%S): MiniSub DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
		#Subtunes
		if [ -d ${SYNOPKG_PKGDEST}/jetty/*/webapp/Subtunes ]; then
			ln -s ${SYNOPKG_PKGDEST}/jetty/*/webapp/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
			echo "$(date +%d.%m.%y_%H:%M:%S): Subtunes DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
	  else
		echo "$(date +%d.%m.%y_%H:%M:%S) : Error: Directory for Subsonic DSM link was not found" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
      #create custom temp folder so temp files can be bigger
	  if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  #create symlink to the created directory
	  if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  # starting subsonic as subsonic daemon user
	  echo "$(date +%d.%m.%y_%H:%M:%S): starting Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
      sleep 10
	  echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  subsonic_get_pid
	  if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is running----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  else
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	  fi

	  exit 0
   ;;
   stop)
      #stop subsonic
	  subsonic_get_pid
      kill $PID
	  echo "$(date +%d.%m.%y_%H:%M:%S) : killed Subsonic PID: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      sleep 2
	  #delete Symlinks and DSM icon
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
		echo "$(date +%d.%m.%y_%H:%M:%S): MiniSub DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
		echo "$(date +%d.%m.%y_%H:%M:%S): Subtunes DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp files deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /tmp/subsonic ]; then
		rm /tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is stopped----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  exit 0
   ;;
   status)
      subsonic_get_pid
      if [ -z  $PID ]; then
	  #Subsonic is not running
		exit 1
	  else
	  #subsonic is running
		exit 0
      fi
   ;;
   log)
	  echo "${SYNOPKG_PKGDEST}/subsonic_package.log"
	  exit 0
   ;;
esac

I’ve added a new test file to my beta folder.

It works fine for me, but I’m not releasing it, yet.

Pleas tell me if it works fine for you.

  • changed the PID detection back to the old one because I got too much wrong detections saying Subsonic is running when it wasn’t
  • updated minisub md5sum for new version
  • changed mashupmod download from the original uploaded.net source to my dropbox, becaus uploaded is too slow and you can only download one file per hour

 

 

Errors errors errors…fixes fixes fixes (hopefully)

Many of you had troubles starting my last build of the Subsonic package. I changed the detection method of the PID. Now it will most certainly run. But As I din’t have any errors I can’t really guarantee a smooth operation because there was no real bug fixing possible to me…

 

 

The rest is equal to the previous package.

Download from Dropbox folder:

https://www.dropbox.com/sh/vd06e2fn2157gh0/kE6FO5J1cD

 

Update button in the Package Center will appear soon.

 

 

 

 

 

 

 

Attention: There are some serious issues with this package on x86 and ppc Disk Stations. I will fix them as soon as I can. Until then: Don’t update if your Subsonic runs fine now!

Hi everyone,

I’ve spent the last 2 days completely rewriting the install script, updating ffmpeg and adding power pc support for this package and here it is:

What is different?

  • Support of new Powerpc Qoriq powered Diskstations DS413 and DS213+
  • completely rewrote installation script
  • Now Subsonic, MashupMod, MiniSub, Subtunes and the ffmpeg packages are downloaded from the original sources during install
  • There is just one .spk for all CPU architectures
  • Updated MiniSub to the latest version (which is detected during install thanks to github) – now with Podcast support
  • Updated MashupMod to 4.7_B3158SE
  • now the Synology standard scripts are calling one big installer.sh which contains every script (inspired by patters from pcloadletter.co.uk)
  • fixed a few old bugs and many many new ones created during recoding

But my Diskstation is not connected to the Internet, what can I do?

  • Download Subsonic Stand alone from here  http://www.subsonic.org/pages/download.jsp and rename the downloaded file to Subsonic.tgz
  • OR if you want to use MashupMod download the newest SE version from here http://uploaded.net/f/zryfjb and rename the downloaded file to Mashupmod.zip
  • Download the correct ffmpeg binary from here http://www.eg-blog.de/download/ (yes they are called serviio-native because I am using the ones from patters) and rename it to ffmpeg.tgz
  • Put the two downloaded files into your public folder and start the installation, the script will detect and use them.
  • Note: you can not update MiniSub or install Subtunes with this method, but you can download them separately and place them into /volumeX/@appstore/Subsonic/jetty/<number>/webapp/mini or …/subtunes to install/update them.

Note for MashupMod users who use transcoding:

  • Go to Settings->Transcoding and change the three “Audioffmpeg” lines in “Step 1″ into “ffmpeg”.
  • Copy the “Step1″ field from mp3 audio into the one from m4a/FLAC audio.
  • Afterwards it should look like this:

Download from Dropbox: https://www.dropbox.com/sh/vd06e2fn2157gh0/kE6FO5J1cD

scripts:

installer.sh:

#!/bin/sh

#--------Subsonic installer script
#--------package maintained at eg-blog.de

DOWNLOAD_URL_STANDARD="http://sourceforge.net/projects/subsonic/files/subsonic/4.7/subsonic-4.7-standalone.tar.gz/download"
DOWNLOAD_URL_MASHUPMOD="http://uploaded.net/file/6kzehtl6/from/zryfjb"
DOWNLOAD_URL_SUBTUNES="http://subtunes.googlecode.com/files/subtunes-0.9.4b.zip"
DOWNLOAD_URL_MINISUB="https://github.com/tsquillario/MiniSub/tarball/master"
SYNO_CPU_ARCH="`uname -m`"
NATIVE_BINS_URL="http://eg-blog.de/download/serviio-native-${SYNO_CPU_ARCH}.tgz"
NATIVE_BINS_FILE="`echo ${NATIVE_BINS_URL} | sed -r "s%^.*/(.*)%\1%"`"

source /etc/profile
TEMP_FOLDER="`find / -maxdepth 2 -name '@tmp' | head -n 1`"
PUBLIC_FOLDER="`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,4}\/public).*$/\1/'`"

PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
}

preinst ()
{
	source /etc/profile

	########################################
	#check if Java is installed

	if [ -z ${JAVA_HOME} ]; then
		echo "Java is not installed or not properly configured. JAVA_HOME is not defined. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	if [ ! -f ${JAVA_HOME}/bin/java ]; then
		echo "Java is not installed or not properly configured. The Java binary could not be located. " > $SYNOPKG_TEMP_LOGFILE
			echo "Download and install the Java Synology package from http://wp.me/pVshC-z5" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Download and install the Java Synology package from http://wp.me/pVshC-z5" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): found Java in ${JAVA_HOME}" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#########################################
	#check if Subsonic folder is in public folder wehn restore is selected
	if [ ! -z ${install_restore} ]; then

		if [ ! -d $PUBLIC_FOLDER/Subsonic ]; then
			echo "Can't find a folder named 'Subsonic' in your public folder. " > $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Can't find a folder named 'Subsonic' in your public folder. " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> $SYNOPKG_TEMP_LOGFILE
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			exit 1
		fi
	fi

	#########################################
	#is the User Home service enabled?
	UH_SERVICE=maybe
	synouser --add userhometest Testing123 "User Home test user" 0 "" ""
	UHT_HOMEDIR=`cat /etc/passwd | sed -r '/User Home test user/!d;s/^.*:User Home test user:(.*):.*$/\1/'`
	if echo $UHT_HOMEDIR | grep '/var/services/homes/' > /dev/null; then
		if [ ! -d $UHT_HOMEDIR ]; then
			UH_SERVICE=false
		fi
	fi
	synouser --del userhometest
	if [ ${UH_SERVICE} == "false" ]; then
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> $SYNOPKG_TEMP_LOGFILE
		echo "The User Home service is not enabled. Please enable this feature in the User control panel in DSM." >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): User home is enabled" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	exit 0
}

postinst ()
{
	#create subsonic daemon user
	synouser --add subsonic `${SYNOPKG_PKGDEST}/passgen 1 20` "Subsonic daemon user" 0 "" ""
	echo "$(date +%d.%m.%y_%H:%M:%S): create subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#determine the subsonic user homedir and save that variable in the user's profile
	#this is needed because librtmp needs to write a file called ~/.swfinfo
	#and new users seem to inherit a HOME value of /root which they have no permissions for
	SUBSONIC_HOMEDIR=`cat /etc/passwd | sed -r '/Subsonic daemon user/!d;s/^.*:Subsonic daemon user:(.*):.*$/\1/'`
	su - subsonic -s /bin/sh -c "echo export HOME=${SUBSONIC_HOMEDIR} >> .profile"

	#########################################
	##download stuff
	#select the right mods / version to download/install
	if [ ! -z ${mashupmod_install} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): download and install MashupMod" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		wget ${DOWNLOAD_URL_MASHUPMOD} --output-document=${SYNOPKG_PKGDEST}/MashupMod.zip
		if [ -f ${SYNOPKG_PKGDEST}/MashupMod.zip ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): downloaded MashupMod from $DOWNLOAD_URL_MASHUPMOD" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/Mashupmod.zip ]; then
				cp ${PUBLIC_FOLDER}/Mashupmod.zip ${SYNOPKG_PKGDEST}
				echo "$(date +%d.%m.%y_%H:%M:%S): copied Mashupmod install files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "There was a problem downloading  Mashupmod from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
				echo "which was ${DOWNLOAD_URL_MASHUPMOD}" >> $SYNOPKG_TEMP_LOGFILE
				echo "Alternatively, you may download this file manually and place it in the 'public' shared folder. and name it Mashupmod.zip" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi
		fi
		unzip ${SYNOPKG_PKGDEST}/MashupMod.zip -d ${SYNOPKG_PKGDEST}
		echo "$(date +%d.%m.%y_%H:%M:%S): extracted MashupMod" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm ${SYNOPKG_PKGDEST}/MashupMod.zip
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		#download Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): download and install Subsonic standard" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		wget ${DOWNLOAD_URL_STANDARD} --output-document=${SYNOPKG_PKGDEST}/Subsonic.tgz
		if [ -f ${SYNOPKG_PKGDEST}/Subsonic.tgz ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): downloaded Subsonic install file from $DOWNLOAD_URL_STANDARD" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/Subsonic.tar.gz ]; then
				cp ${PUBLIC_FOLDER}/Subsonic.tgz ${SYNOPKG_PKGDEST}
				echo "$(date +%d.%m.%y_%H:%M:%S): copied Subsonic install files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			else
				echo "There was a problem downloading  Subsonic from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
				echo "which was ${DOWNLOAD_URL_STANDARD}" >> $SYNOPKG_TEMP_LOGFILE
				echo "Alternatively, you may download this file manually and place it in the 'public' shared folder. and name it Subsonic.tgz" >> $SYNOPKG_TEMP_LOGFILE
				exit 1
			fi

		fi
		tar xzf ${SYNOPKG_PKGDEST}/Subsonic.tgz -C ${SYNOPKG_PKGDEST}
		echo "$(date +%d.%m.%y_%H:%M:%S): extracted Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm ${SYNOPKG_PKGDEST}/Subsonic.tgz
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	fi
	#delete the original subsonic.sh and use the edited file for Synology
	if [ -f ${SYNOPKG_PKGDEST}/subsonic.sh ]; then
		rm ${SYNOPKG_PKGDEST}/subsonic.sh
		echo "$(date +%d.%m.%y_%H:%M:%S): deleted original subsonic.sh file" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	if [ -f ${SYNOPKG_PKGDEST}/subsonic_synology.sh ]; then
		mv ${SYNOPKG_PKGDEST}/subsonic_synology.sh ${SYNOPKG_PKGDEST}/subsonic.sh
		echo "$(date +%d.%m.%y_%H:%M:%S): now using edited subsonic.sh file for Synology" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#download and install ffmpeg binarys
	wget ${NATIVE_BINS_URL} --output-document=${SYNOPKG_PKGDEST}/ffmpeg.tgz
	if [ ! -f ${SYNOPKG_PKGDEST}/ffmpeg.tgz ]; then
		if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/ffmpeg.tgz ]; then
			cp ${PUBLIC_FOLDER}/ffmpeg.tgz ${SYNOPKG_PKGDEST}
			echo "$(date +%d.%m.%y_%H:%M:%S): copied ffmpeg files from public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "There was a problem downloading  ffmpeg from the official download link, " >> $SYNOPKG_TEMP_LOGFILE
			echo "which was ${NATIVE_BINS_URL}" >> $SYNOPKG_TEMP_LOGFILE
			echo "Alternatively, you may download this file manually and place it in the 'public' shared folder and neme it ffmpeg.tgz" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): downloaded ffmpeg files from $NATIVE_BINS_URL" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	if [ ! -d  ${SYNOPKG_PKGDEST}/transcode ]; then
		mkdir ${SYNOPKG_PKGDEST}/transcode
		echo "$(date +%d.%m.%y_%H:%M:%S): created transcode directory" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi
	if [ ! -d  ${SYNOPKG_PKGDEST}/lib ]; then
		mkdir ${SYNOPKG_PKGDEST}/lib
		echo "$(date +%d.%m.%y_%H:%M:%S): created lib directory" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	tar xzvf ${SYNOPKG_PKGDEST}/ffmpeg.tgz -C ${SYNOPKG_PKGDEST}/transcode
	cp -r ${SYNOPKG_PKGDEST}/transcode/lib* ${SYNOPKG_PKGDEST}/lib/
	rm -r ${SYNOPKG_PKGDEST}/transcode/lib*
	rm ${SYNOPKG_PKGDEST}/ffmpeg.tgz
	echo "$(date +%d.%m.%y_%H:%M:%S): copied ffmpeg file and libraries" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#########################################
	##start Subsonic
	#fix file permissions
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic-booter-jar-with-dependencies.jar
	chmod 775 ${SYNOPKG_PKGDEST}/subsonic.war
	chown -R subsonic:users ${SYNOPKG_PKGDEST}
	echo "$(date +%d.%m.%y_%H:%M:%S): start Subsonic for first initialisation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	#set up symlink for the DSM GUI
	ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic

	#create custom temp folder so temp files can be bigger
	if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi
	#create symlink to the created directory
	if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
	fi

	#start subsonic as subsonic user
	su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh

	sleep 5

	subsonic_get_pid
	if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo "Error: Can not start Subsonic during install" >> $SYNOPKG_TEMP_LOGFILE
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic during install" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi

	#give it some time to start up
	sleep 90

	#stop subsonic

	kill $PID
	sleep 5
	echo "$(date +%d.%m.%y_%H:%M:%S): Stopped Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	####################################
	##download and install additional features
	echo "$(date +%d.%m.%y_%H:%M:%S): Download and install additional Features" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	#Subtunes
	if [ ! -z ${subtunes_install} ]; then
		wget ${DOWNLOAD_URL_SUBTUNES}  --output-document=${SYNOPKG_PKGDEST}/Subtunes.zip
		if [ -f ${SYNOPKG_PKGDEST}/Subtunes.zip ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): Downloaded Subtunes" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			unzip ${SYNOPKG_PKGDEST}/Subtunes.zip -d ${SYNOPKG_PKGDEST}/Subtunes/
			echo "$(date +%d.%m.%y_%H:%M:%S): extracted Subtunes" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: Subtunes could not be downloaded" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check the internet connection of your Diskstation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: Subtunes could not be downloaded" > $SYNOPKG_TEMP_LOGFILE
			echo "Please check the internet connection of your Diskstation" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi

		cp -r ${SYNOPKG_PKGDEST}/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/
		rm -r ${SYNOPKG_PKGDEST}/Subtunes
		rm ${SYNOPKG_PKGDEST}/Subtunes.zip

		echo "$(date +%d.%m.%y_%H:%M:%S): copied Subtunes and deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		#Subtuneslink
		if [ -d ${SYNOPKG_PKGDEST}/Subtuneslink ]; then
			cp ${SYNOPKG_PKGDEST}/Subtuneslink/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
		fi

	fi
	rm -r ${SYNOPKG_PKGDEST}/Subtuneslink

	#MiniSub Update
	if [ ! -z ${minisub_install} ]; then
		wget ${DOWNLOAD_URL_MINISUB} --no-check-certificate --output-document=${SYNOPKG_PKGDEST}/MiniSub.tgz
		if [ -f ${SYNOPKG_PKGDEST}/MiniSub.tgz ]; then
			echo "$(date +%d.%m.%y_%H:%M:%S): Downloaded MiniSub" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			tar xzf ${SYNOPKG_PKGDEST}/MiniSub.tgz -C ${SYNOPKG_PKGDEST}/MiniSub
			echo "$(date +%d.%m.%y_%H:%M:%S): extracted MiniSub" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: MiniSub could not be downloaded" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "$(date +%d.%m.%y_%H:%M:%S): Please check the internet connection of your Diskstation" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: MiniSub could not be downloaded" > $SYNOPKG_TEMP_LOGFILE
			echo "Please check the internet connection of your Diskstation" >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
		if [ -d /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/ ]; then
			rm -r /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/*
			cp -r ${SYNOPKG_PKGDEST}/MiniSub/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
		else
			echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can't find the MiniSub directory -> MiniSub will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log
			echo "Error: Can't find the MiniSub directory -> MiniSub will not be updated " >> ${SYNOPKG_PKGDEST}/subsonic_package.log >> $SYNOPKG_TEMP_LOGFILE
			exit 1
		fi
		rm -r ${SYNOPKG_PKGDEST}/MiniSub
		rm ${SYNOPKG_PKGDEST}/MiniSub.tgz
		echo "$(date +%d.%m.%y_%H:%M:%S): copied MiniSub and deleted downloaded files" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	fi

	#MiniSub Link
	echo "$(date +%d.%m.%y_%H:%M:%S): create MiniSub DSM link" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	if [ -d ${SYNOPKG_PKGDEST}/MiniSublink/ ]; then
		cp ${SYNOPKG_PKGDEST}/MiniSublink/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
	fi
	rm -r ${SYNOPKG_PKGDEST}/MiniSublink
	####################################

	#delete symlink
	rm /usr/syno/synoman/webman/3rdparty/Subsonic
	#delete temp files
	if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi

	#check Podcast folder for right permissions
	if [ -d /volume1/music/Podcast ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): reset permissions of Podcast folder (subsonic user has new uid)" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		chown -R admin:users /volume1/music/Podcast
		chmod -R 775 /volume1/music/Podcast
	fi

	#########################################
	#install user backup from public folder

	if [ ! -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore previously made backup fron public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		#copy files
		cp -r ${PUBLIC_FOLDER}/Subsonic/* ${SYNOPKG_PKGDEST}/

		#new files might not be owned by subsonic user
		chown -R subsonic ${SYNOPKG_PKGDEST}/

		#make the Subsonic start script executable
		chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
	fi
	echo "$(date +%d.%m.%y_%H:%M:%S): ----installation complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 0
}

preuninst ()
{
	##############################################
	stop Subsonic if it is running

	subsonic_get_pid
	if [ -z $PID ]; then
		sleep 1
	else
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 2
		if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
			rm /usr/syno/synoman/webman/3rdparty/Subsonic
		fi

		if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
			rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		fi
	fi

	##############################################
	# create a backup in public folder in public folder
	if [ ! -z ${uninstall_backup} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): Create a backup of Subsonic in public folder" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		if [ ! -d ${PUBLIC_FOLDER}/Subsonic ]; then
			mkdir ${PUBLIC_FOLDER}/Subsonic
		fi

		cp ${SYNOPKG_PKGDEST}/subsonic.properties *.index ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/db ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/lucene ${PUBLIC_FOLDER}/Subsonic
		cp -r ${SYNOPKG_PKGDEST}/thumbs ${PUBLIC_FOLDER}/Subsonic
	fi

	exit 0
}

postuninst ()
{
	synouser --del subsonic

	#remove DSM icon symlink
	if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
	fi

	#remove temp symlink
	rm /tmp/subsonic

	exit 0
}

preupgrade ()
{
	###########################
	#stop Subsonic if it is runing

	subsonic_get_pid
	if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): stopping subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		kill $PID
		sleep 2
	fi

	if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi

	###########################
	#backup subsonic.properties and db Folder

	if [ -z ${install_restore} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): create backup of Subsonic db in temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		if [ ! -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
			mkdir ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp ${SYNOPKG_PKGDEST}/subsonic.properties ${SYNOPKG_PKGDEST}*.index ${SYNOPKG_PKGDEST}/../subsonic_update_backup/
			cp -r ${SYNOPKG_PKGDEST}/db ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/lucene ${SYNOPKG_PKGDEST}/../subsonic_update_backup
			cp -r ${SYNOPKG_PKGDEST}/thumbs ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		fi
	fi

	exit 0
}

postupgrade ()
{

	###############################
	#restore subsonic db index and settings
	if [ ! -z ${install_update} ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): restore from temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		cp -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup/* ${SYNOPKG_PKGDEST}/
	fi

	#remove backup folder
	#remove the next lines to keep a backup in the @appstore folder
	if [ -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): remove temporary backup dir" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		rm -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup
	fi

	#subsonic may not own all new files
	chown -R subsonic ${SYNOPKG_PKGDEST}/

	#make the Subsonic start script executable
	chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh

	echo "$(date +%d.%m.%y_%H:%M:%S): ----update complete----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

	exit 0
}

start-stop-status

#!/bin/sh

#--------Subsonic start-stop-status script
#--------package maintained at eg-blog.de

##############################################
#function to get the process id of Subsonic
PID=""
subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
}
get_time()
{
	TIME=$(date +%d.%m.%y_%H:%M:%S)
}

case "$1" in
   start)
	  ###---copied from patters start-stop-status.sh of his crashplan proe package---
	  DAEMON_ID="${SYNOPKG_PKGNAME} daemon user"
	  DAEMON_HOME="`cat /etc/passwd | grep "${DAEMON_ID}" | cut -f6 -d':'`"

	  #set the current timezone for Java so that log timestamps are accurate
	  #we need to use the modern timezone names so that Java can figure out DST
	  SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'`
	  SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"`
	  grep "^export TZ" ${DAEMON_HOME}/.profile > /dev/null \
	  && sed -i "s%^export TZ=.*$%export TZ='${SYNO_TZ}'%" ${DAEMON_HOME}/.profile \
	  ###---end of copy---------------------------------------------------------------

	  #set up symlinks for the DSM GUI icon
	  #Subsonic main
	  if [ -d /usr/syno/synoman/webman/3rdparty ]; then
		ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log

		#MiniSub
		if [ -d ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini ]; then
			ln -s ${SYNOPKG_PKGDEST}/jetty/*/webapp/mini /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
			echo "$(date +%d.%m.%y_%H:%M:%S): MiniSub DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
		#Subtunes
		if [ -d ${SYNOPKG_PKGDEST}/jetty/*/webapp/Subtunes ]; then
			ln -s ${SYNOPKG_PKGDEST}/jetty/*/webapp/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
			echo "$(date +%d.%m.%y_%H:%M:%S): Subtunes DSM link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
	  else
		echo "$(date +%d.%m.%y_%H:%M:%S) : Error: Directory for Subsonic DSM link was not found" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
      #create custom temp folder so temp files can be bigger
	  if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  #create symlink to the created directory
	  if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp directory link created" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  # starting subsonic as subsonic daemon user
	  echo "$(date +%d.%m.%y_%H:%M:%S): starting Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
      sleep 10
	  echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic as subsonic daemon user" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  subsonic_get_pid
	  if [ ! -z $PID ]; then
		echo "$(date +%d.%m.%y_%H:%M:%S): started Subsonic successfully. PID is: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is running----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  else
		echo "$(date +%d.%m.%y_%H:%M:%S): Error: Can not start Subsonic" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	  fi

	  exit 0
   ;;
   stop)
      #stop subsonic
	  subsonic_get_pid
      kill $PID
	  echo "$(date +%d.%m.%y_%H:%M:%S) : killed Subsonic PID: $PID" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
      sleep 2
	  #delete Symlinks and DSM icon
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Subsonic DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
		echo "$(date +%d.%m.%y_%H:%M:%S): MiniSub DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
		echo "$(date +%d.%m.%y_%H:%M:%S): Subtunes DSM link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp files deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /tmp/subsonic ]; then
		rm /tmp/subsonic
		echo "$(date +%d.%m.%y_%H:%M:%S): Temp link deleted" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  echo "$(date +%d.%m.%y_%H:%M:%S): ----subsonic is stopped----" >> ${SYNOPKG_PKGDEST}/subsonic_package.log
	  exit 0
   ;;
   status)
      subsonic_get_pid
      if [ -z  $PID ]; then
	  #Subsonic is not running
		exit 1
	  else
	  #subsonic is running
		exit 0
      fi
   ;;
   log)
	  echo "${SYNOPKG_PKGDEST}/subsonic_package.log"
	  exit 0
   ;;
esac

Good news for everyone with a new DS 423 or DS 213+. These DiskStations are powered by a 1GHz PPC CPU so the the java package had do be reconfigured to match these devices. This job was thankfully done by patters from pcloadletter.co.uk. See his release notes to download and install the package on your new NAS.

This means it is now possible to run Subsonic (and all other java based programs) on every DiskStation exept the old PPCs from 2010 and earlier.

You can’t install Subsonic on these DiskStations, yet because I have to upload a specified package for that. Also I have to look for a special compiled ffmpeg file to enable transcoding.

I will work on this package during the next week, so you can expect the release for the next weekend.

Thanks to MoBos hint I made a new package for those of you who aren’t able to install Java 7 and wanted to install Madevils MashupMod.

I also uploaded a new ARM version to the Dropbox folder, because the latest version of MashupMod is now included. But I will not update the repository for this little change.

For the Atom users: The update button in your Package center will appear soon. If it doesn’t work at the first start, wait two minutes, stop Subsonic, reboot and restart Subsonic again.

 

There are just changes at the MashupMod  version, If you aren’t using it, you don’t have to install this update!

Finally…

The second major release for the time I am working on these packages is out.

What is new?

From the package site I only added an own install/start/stop log to the package center, but Subsonic itself has many new features (Change log here). It now scans my library with about 45k songs in under 10 minutes and has the MiniSub html5 interface on board (in Subsonic go to More -> MiniSub). You can still have direct Access to it with adding /mini after your Subsonic URL or Add an icon to your DSM during update process. Also Madevil has finished his MashupMod so i included this again.

What do I have to consider?

As far as my testing went today I can say that the library of 4.6 and 4.7 are incompatible so you will loose all your settings. (It isn’t that bad because file searching is now about 10 times faster than in 4.6). If you want to backup and restore your users read this article in the Subsonic Forum (thanks to MoBO).

With installing the MashupMod version you will get many benefits but you can not register your Subsonic to get the <name>.subsonic.org address.

Also MashupMod requires Java 7 wich hasn’t been released for Atom based Diskstations, yet. You have to stick to the normal 4.7 version. I disabled the option to install MashupMod on x86 Systems.

As there is no Java package for the new PPC Diskstations DS213+ and DS413 you can not install any Java programs there, including Subsonic.

Now have fun with it the effort of upgrading is totally worth it.

The update button will appear in you package center soon (check my Subsonic install instructions on how to do this). You want to download and install it it manually? Here you go:

https://www.dropbox.com/sh/pylh8ilr0fi80ub/XAixHmKbKd/stable

btw. it runs fine on DSM 4.1…

Scripts:

preinst:

#!/bin/sh

#--------Subsonic preinstall script
#--------package maintained at synology-forum.de

source /etc/profile

########################################
#check if Java is installed

if [ -z ${JAVA_HOME} ]; then
	echo &quot;Java is not installed or not properly configured. JAVA_HOME is not defined. &quot; &gt; $SYNOPKG_TEMP_LOGFILE
        echo &quot;Download and install the Java Synology package from http://wp.me/pVshC-z5&quot; &gt;&gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Download and install the Java Synology package from http://wp.me/pVshC-z5&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 1
fi

if [ ! -f ${JAVA_HOME}/bin/java ]; then
	echo &quot;Java is not installed or not properly configured. The Java binary could not be located. &quot; &gt; $SYNOPKG_TEMP_LOGFILE
        echo &quot;Download and install the Java Synology package from http://wp.me/pVshC-z5&quot; &gt;&gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Download and install the Java Synology package from http://wp.me/pVshC-z5&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 1
fi

#########################################
#check if Subsonic folder is in public folder wehn restore is selected
if [ ! -z ${install_restore} ]; then
	PUBLIC=`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,3}\/public).*$/\1/'`

	if [ ! -d $PUBLIC/Subsonic ]; then
		echo &quot;Can't find a folder named 'Subsonic' in your public folder. &quot; &gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Can't find a folder named 'Subsonic' in your public folder. &quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo &quot;Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally&quot; &gt;&gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Please check your public folder and make sure there is a folder called Subsonic (with Capital S) in it. Or select 'No' if you don't want to restore anything and just install Subsonic normally&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		exit 1
	fi
fi

exit 0

postinst

#!/bin/sh

#--------SUBSONIC postinstall script
#--------package maintained at eg-blog.de

#variable for process ID
PID=&quot;&quot;

subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
}

####################################
##subsonic user settings

#create subsonic daemon user
synouser --add subsonic `${SYNOPKG_PKGDEST}/Subsonic/passgen 1 20` &quot;Subsonic daemon user&quot; 0 &quot;&quot; &quot;&quot;
echo &quot;$(date +%m%d%y%H%M%S): create subsonic daemon user&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

#determine the subsonic user homedir and save that variable in the user's profile
#this is needed because librtmp needs to write a file called ~/.swfinfo
#and new users seem to inherit a HOME value of /root which they have no permissions for
SUBSONIC_HOMEDIR=`cat /etc/passwd | sed -r '/Subsonic daemon user/!d;s/^.*:Subsonic daemon user:(.*):.*$/\1/'`
su - subsonic -s /bin/sh -c &quot;echo export HOME=${SUBSONIC_HOMEDIR} &gt;&gt; .profile&quot;

#set ownership of Subsonic folder tree
chown -R subsonic ${SYNOPKG_PKGDEST}
echo &quot;$(date +%m%d%y%H%M%S): set ownership of Subsonic folder tree&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

#####################################
##other stuff

#select the right mods / version to download/install
if [ ! -z ${mashupmod_install} ]; then
	#download and install MashupMod
	echo &quot;$(date +%m%d%y%H%M%S): download and install MashupMod&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	wget https://dl.dropbox.com/u/33279357/synology_packages/addons/MashupMod_4.7B3125SE.tgz --no-check-certificate --output-document=${SYNOPKG_PKGDEST}/MashupMod.tgz
	if [ -f ${SYNOPKG_PKGDEST}/MashupMod.tgz ]; then
		tar xzf ${SYNOPKG_PKGDEST}/MashupMod.tgz -C ${SYNOPKG_PKGDEST}
		echo &quot;$(date +%m%d%y%H%M%S): extracted MashupMod&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo &quot;Error: MashupMod could not be downloaded&quot; &gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Please check the internet connection of your Diskstation&quot; &gt;&gt; $SYNOPKG_TEMP_LOGFILE
		exit 1
	fi
	cp -r ${SYNOPKG_PKGDEST}/MashupMod/* ${SYNOPKG_PKGDEST}/Subsonic
	rm -r ${SYNOPKG_PKGDEST}/MashupMod
	rm ${SYNOPKG_PKGDEST}/MashupMod.tgz
	echo &quot;$(date +%m%d%y%H%M%S): copied Mashupmod and deleted downloaded files&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

else
	#install standard Subsonic
	cp -r ${SYNOPKG_PKGDEST}/install_standard/* ${SYNOPKG_PKGDEST}/Subsonic
	echo &quot;$(date +%m%d%y%H%M%S): copied standard Subsonic files&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
fi

rm -r ${SYNOPKG_PKGDEST}/install_standard

#make the Subsonic start script executable
chmod +x ${SYNOPKG_PKGDEST}/Subsonic/subsonic.sh

#####################################
##start Subsonic
echo &quot;$(date +%m%d%y%H%M%S): start Subsonic for first initialisation&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

#set up symlink for the DSM GUI
ln -s ${SYNOPKG_PKGDEST}/Subsonic /usr/syno/synoman/webman/3rdparty/Subsonic

#create custom temp folder so temp files can be bigger
if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
	mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
fi
#create symlink to the created directory
if [ ! -L /tmp/subsonic ]; then
	ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
fi

#start subsonic as subsonic user
su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh

sleep 5

subsonic_get_pid

if [ ! -z $PID ]; then
	echo &quot;$(date +%m%d%y%H%M%S): started Subsonic successfully. PID is: $PID&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
else
	echo &quot;Error: Can not start Subsonic during install&quot; &gt; $SYNOPKG_TEMP_LOGFILE
	echo &quot;$(date +%m%d%y%H%M%S): Error: Can not start Subsonic during install&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	exit 1
fi

#give it some time to start up
sleep 90

#stop subsonic

kill $PID
sleep 5
echo &quot;$(date +%m%d%y%H%M%S): Stopped Subsonic&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

####################################
##download and install additional features
echo &quot;$(date +%m%d%y%H%M%S): Download and install additional Features&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
#Subtunes
if [ ! -z ${subtunes_install} ]; then
	wget https://dl.dropbox.com/u/33279357/synology_packages/addons/Subtunes_0.9.4b.tgz --no-check-certificate --output-document=${SYNOPKG_PKGDEST}/Subtunes.tgz
	if [ -f ${SYNOPKG_PKGDEST}/Subtunes.tgz ]; then
		echo &quot;$(date +%m%d%y%H%M%S): Downloaded Subtunes&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		tar xzf ${SYNOPKG_PKGDEST}/Subtunes.tgz -C ${SYNOPKG_PKGDEST}
		echo &quot;$(date +%m%d%y%H%M%S): extracted Subtunes&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	else
		echo &quot;$(date +%m%d%y%H%M%S): Error: Subtunes could not be downloaded&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo &quot;$(date +%m%d%y%H%M%S): Please check the internet connection of your Diskstation&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		echo &quot;Error: Subtunes could not be downloaded&quot; &gt; $SYNOPKG_TEMP_LOGFILE
		echo &quot;Please check the internet connection of your Diskstation&quot; &gt;&gt; $SYNOPKG_TEMP_LOGFILE
		exit 1
	fi

	cp -r ${SYNOPKG_PKGDEST}/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/
	rm -r ${SYNOPKG_PKGDEST}/Subtunes
	rm ${SYNOPKG_PKGDEST}/Subtunes.tgz
	echo &quot;$(date +%m%d%y%H%M%S): copied Subtunes and deleted downloaded files&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
fi

#MiniSub Link
if [ ! -z ${minisub_link} ]; then
	echo &quot;$(date +%m%d%y%H%M%S): create MiniSub DSM link&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	if [ -f ${SYNOPKG_PKGDEST}/Subsonic/MiniSublink/config ]; then
		cp ${SYNOPKG_PKGDEST}/Subsonic/MiniSublink/config /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
		cp -r ${SYNOPKG_PKGDEST}/Subsonic/images/* /usr/syno/synoman/webman/3rdparty/Subsonic/jetty/*/webapp/mini/
	fi
fi
rm -r ${SYNOPKG_PKGDEST}/Subsonic/MiniSublink

chown -R subsonic ${SYNOPKG_PKGDEST}/

####################################

#delete symlink
rm /usr/syno/synoman/webman/3rdparty/Subsonic
#delete temp files
if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
	rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
fi

#########################################
#install user backup from public folder

if [ ! -z ${install_restore} ]; then
	echo &quot;$(date +%m%d%y%H%M%S): restore previously made backup fron public folder&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	PUBLIC=`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,3}\/public).*$/\1/'`
	#copy files
	cp -r $PUBLIC/Subsonic/* ${SYNOPKG_PKGDEST}/Subsonic

	#new files might not be owned by subsonic user
	chown -R subsonic ${SYNOPKG_PKGDEST}/

	#make the Subsonic start script executable
	chmod +x ${SYNOPKG_PKGDEST}/Subsonic/subsonic.sh
fi
echo &quot;$(date +%m%d%y%H%M%S): ----installation complete----&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
exit 0

preupgrade:

#!/bin/sh

#--------Subsonic preupgrade script
#--------package maintained at eg-blog.de

#variable for process ID
PID=&quot;&quot;

##############################################
#function to get the process id of Subsonic

subsonic_get_pid ()
{
   PID=`ps | grep java | grep subsonic | awk '{print $1}'`
}

###########################
#stop Subsonic if it is runing

subsonic_get_pid

if [ ! -z $PID ]; then
	echo &quot;$(date +%m%d%y%H%M%S): stopping subsonic&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	kill $PID
	sleep 2
fi

if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
	rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
fi

###########################
#backup subsonic.properties and db Folder

if [ -z ${install_restore} ]; then
	echo &quot;$(date +%m%d%y%H%M%S): create backup of Subsonic db in temporary backup dir&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	if [ ! -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
		mkdir ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		cp ${SYNOPKG_PKGDEST}/Subsonic/subsonic.properties ${SYNOPKG_PKGDEST}/Subsonic/*.index ${SYNOPKG_PKGDEST}/../subsonic_update_backup/
		cp -r ${SYNOPKG_PKGDEST}/Subsonic/db ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		cp -r ${SYNOPKG_PKGDEST}/Subsonic/lucene ${SYNOPKG_PKGDEST}/../subsonic_update_backup
		cp -r ${SYNOPKG_PKGDEST}/Subsonic/thumbs ${SYNOPKG_PKGDEST}/../subsonic_update_backup
	fi
fi

exit 0

postupgrade:

#!/bin/sh

#--------SUBSONIC postupgrade script
#--------package maintained at eg-blog.de

###############################
#restore subsonic db index and settings
if [ ! -z ${install_update} ]; then
	echo &quot;$(date +%m%d%y%H%M%S): restore from temporary backup dir&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	cp -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup/* ${SYNOPKG_PKGDEST}/Subsonic/
fi

#remove backup folder
#remove the next lines to keep a backup in the @appstore folder
if [ -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
	echo &quot;$(date +%m%d%y%H%M%S): remove temporary backup dir&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	rm -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup
fi

#subsonic may not own all new files
chown -R subsonic ${SYNOPKG_PKGDEST}/

#make the Subsonic start script executable
chmod +x ${SYNOPKG_PKGDEST}/Subsonic/subsonic.sh

echo &quot;$(date +%m%d%y%H%M%S): ----update complete----&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

exit 0

preuninst:

#!/bin/sh

#--------SUBSONIC preuninstall script
#--------package maintained at eg-blog.de

###############################################
##stop Subsonic if it is running

PID=`ps | grep java | grep subsonic | awk '{print $1}'`
if [ -z $PID ]; then
	sleep 1
else
	echo &quot;$(date +%m%d%y%H%M%S): stopping Subsonic&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	kill $PID
	sleep 2
	if [ -d /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
	fi

	if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
	fi
fi

################################################
#create a backup in public folder in public folder
if [ ! -z ${uninstall_backup} ]; then
	echo &quot;$(date +%m%d%y%H%M%S): Create a backup of Subsonic in public folder&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	PUBLIC=`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,3}\/public).*$/\1/'`
	if [ ! -d $PUBLIC/Subsonic ]; then
		mkdir $PUBLIC/Subsonic
	fi

	cp ${SYNOPKG_PKGDEST}/Subsonic/subsonic.properties *.index $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/Subsonic/db $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/Subsonic/lucene $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/Subsonic/thumbs $PUBLIC/Subsonic
fi

exit 0

postuninst:

#!/bin/sh

#--------SUBSONIC postuninstall script
#--------package maintained at eg-blog.de

#remove subsonic daemon user
echo &quot;$(date +%m%d%y%H%M%S): remove Subsonic user&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
synouser --del subsonic

#remove DSM icon symlink
if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
	rm /usr/syno/synoman/webman/3rdparty/Subsonic
fi

#remove temp symlink
rm /tmp/subsonic

echo &quot;$(date +%m%d%y%H%M%S): ----uninstall complete----&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

exit 0

start-stop-status:

#!/bin/sh

#--------Subsonic start-stop-status script
#--------package maintained at eg-blog.de

#variable for process ID
PID=&quot;&quot;

##############################################
#function to get the process id of Subsonic

subsonic_get_pid ()
{
	PID=`ps | grep java | grep subsonic | awk '{print $1}'`
}
get_time()
{
	TIME=$(date +%m%d%y%H%M%S)
}

case &quot;$1&quot; in
   start)
	  ###---copied from patters start-stop-status.sh of his crashplan proe package---
	  DAEMON_ID=&quot;${SYNOPKG_PKGNAME} daemon user&quot;
	  DAEMON_HOME=&quot;`cat /etc/passwd | grep &quot;${DAEMON_ID}&quot; | cut -f6 -d':'`&quot;

	  #set the current timezone for Java so that log timestamps are accurate
	  #we need to use the modern timezone names so that Java can figure out DST
	  SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'&quot;'`
	  SYNO_TZ=`grep &quot;^${SYNO_TZ}&quot; /usr/share/zoneinfo/Timezone/tzname | sed -e &quot;s/^.*= //&quot;`
	  grep &quot;^export TZ&quot; ${DAEMON_HOME}/.profile &gt; /dev/null \
	  &amp;&amp; sed -i &quot;s%^export TZ=.*$%export TZ='${SYNO_TZ}'%&quot; ${DAEMON_HOME}/.profile \
	  ###---end of copy---------------------------------------------------------------

	  #set up symlinks for the DSM GUI icon
	  #Subsonic main
	  if [ -d /usr/syno/synoman/webman/3rdparty ]; then
		ln -s ${SYNOPKG_PKGDEST}/Subsonic/ /usr/syno/synoman/webman/3rdparty/Subsonic
		echo &quot;$(date +%m%d%y%H%M%S): Subsonic DSM link created&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

		#MiniSub
		if [ -d ${SYNOPKG_PKGDEST}/Subsonic/jetty/*/webapp/mini ]; then
			ln -s ${SYNOPKG_PKGDEST}/Subsonic/jetty/*/webapp/mini /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
			echo &quot;$(date +%m%d%y%H%M%S): MiniSub DSM link created&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
		#Subtunes
		if [ -d ${SYNOPKG_PKGDEST}/Subsonic/jetty/*/webapp/Subtunes ]; then
			ln -s ${SYNOPKG_PKGDEST}/Subsonic/jetty/*/webapp/Subtunes /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
			echo &quot;$(date +%m%d%y%H%M%S): Subtunes DSM link created&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
		fi
	  else
		echo &quot;$(date +%m%d%y%H%M%S) : Error: Directory for Subsonic DSM link was not found&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
      #create custom temp folder so temp files can be bigger
	  if [ ! -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		mkdir ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		chown -R subsonic ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo &quot;$(date +%m%d%y%H%M%S): Temp directory created&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  #create symlink to the created directory
	  if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
		echo &quot;$(date +%m%d%y%H%M%S): Temp directory link created&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  # starting subsonic as subsonic daemon user
	  echo &quot;$(date +%m%d%y%H%M%S): starting Subsonic as subsonic daemon user&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
      su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
      sleep 10
	  echo &quot;$(date +%m%d%y%H%M%S): started Subsonic as subsonic daemon user&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  subsonic_get_pid
	  echo &quot;$(date +%m%d%y%H%M%S): PID is: $PID&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  echo &quot;$(date +%m%d%y%H%M%S): ----subsonic is running----&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log

	  exit 0
   ;;
   stop)
      #stop subsonic
	  subsonic_get_pid
      kill $PID
	  echo &quot;$(date +%m%d%y%H%M%S) : killed Subsonic PID: $PID&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
      sleep 2
	  #delete Symlinks and DSM icon
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic
		echo &quot;$(date +%m%d%y%H%M%S): Subsonic DSM link deleted&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_MiniSub
		echo &quot;$(date +%m%d%y%H%M%S): MiniSub DSM link deleted&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes ]; then
		rm /usr/syno/synoman/webman/3rdparty/Subsonic_Subtunes
		echo &quot;$(date +%m%d%y%H%M%S): Subtunes DSM link deleted&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -d ${SYNOPKG_PKGDEST}/../../@tmp/subsonic ]; then
		rm -r ${SYNOPKG_PKGDEST}/../../@tmp/subsonic
		echo &quot;$(date +%m%d%y%H%M%S): Temp files deleted&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  if [ -L /tmp/subsonic ]; then
		rm /tmp/subsonic
		echo &quot;$(date +%m%d%y%H%M%S): Temp link deleted&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  fi
	  echo &quot;$(date +%m%d%y%H%M%S): ----subsonic is stopped----&quot; &gt;&gt; ${SYNOPKG_PKGDEST}/subsonic_package.log
	  exit 0
   ;;
   status)
      subsonic_get_pid
      if [ -z  $PID ]; then
	  #Subsonic is not running
		exit 1
	  else
	  #subsonic is running
		exit 0
      fi
   ;;
   log)
	  echo &quot;${SYNOPKG_PKGDEST}/subsonic_package.log&quot;
	  exit 0
   ;;
esac

install_uifile:

[{
	&quot;step_title&quot;: &quot;Restore Backup&quot;,
	&quot;items&quot;:
	[{
		&quot;type&quot;: &quot;singleselect&quot;,
		&quot;desc&quot;: &quot;Would you like to restore a backup of Subsonic?
Create a folder with all relevant files in it,
name it Subsonic (with capital S)and
place it into your public folder&quot;,
		&quot;subitems&quot;:
		[{
			&quot;key&quot;: &quot;No&quot;,
			&quot;desc&quot;: &quot;No&quot;
		 },
		 {
			&quot;key&quot;: &quot;install_restore&quot;,
			&quot;desc&quot;: &quot;Yes&quot;
		}]
	}]
},
{
	&quot;step_title&quot;: &quot;Add-ons / Mods&quot;,
	&quot;items&quot;:
	[{
		&quot;type&quot;: &quot;multiselect&quot;,
		&quot;desc&quot;: &quot;Which mods or additional features would you like to download and install?
Requires internet connection of your Diskstation&quot;,
		&quot;subitems&quot;:
		[{
			&quot;key&quot;: &quot;subtunes_install&quot;,
			&quot;desc&quot;: &quot;Subtunes html5 web interface (3,8 MB)&quot;
		},
		{
			&quot;key&quot;: &quot;mashupmod_install&quot;,
			&quot;desc&quot;: &quot;Mashupmod (30MB) (it is not beta anymore but be aware of what you are doing: check eg-blog.de!)&quot;
		},
		{
			&quot;key&quot;: &quot;minisub_link&quot;,
			&quot;desc&quot;: &quot;Create a link in DSM to MiniSub. MiniSub is a html5 based webinterface included in Subsonic&quot;
		}]
	}]
}]

upgrade_uifile

[{
	&quot;step_title&quot;: &quot;Choose update mode&quot;,
	&quot;items&quot;:
	[{
		&quot;type&quot;: &quot;singleselect&quot;,
		&quot;desc&quot;: &quot;A previously installed version of Subsonic has been detected.
Which update mode would you like to perform?&quot;,
		&quot;subitems&quot;:
		[{
			&quot;key&quot;: &quot;install_update&quot;,
			&quot;desc&quot;: &quot;Just update normally (library will be kept)&quot;
		 },
		 {
			&quot;key&quot;: &quot;install_restore&quot;,
			&quot;desc&quot;: &quot;Restore a previously made backup from /public/Subsonic folder&quot;
		 },
		 {
			&quot;key&quot;: &quot;install_fresh&quot;,
			&quot;desc&quot;: &quot;Preform a fresh install. All previously created files of Subsonic will be deleted!&quot;
		}]
	}]
},
{
	&quot;step_title&quot;: &quot;Add-ons / Mods&quot;,
	&quot;items&quot;:
	[{
		&quot;type&quot;: &quot;multiselect&quot;,
		&quot;desc&quot;: &quot;Which mods or additional features would you like to download and install?
Requires internet connection of your Diskstation&quot;,
		&quot;subitems&quot;:
		[{
			&quot;key&quot;: &quot;subtunes_install&quot;,
			&quot;desc&quot;: &quot;Subtunes html5 web interface (3,8 MB)&quot;
		},
		{
			&quot;key&quot;: &quot;mashupmod_install&quot;,
			&quot;desc&quot;: &quot;Mashupmod (30MB)
It is not beta anymore but be aware of what you are doing: check eg-blog.de!&quot;
		},
		{
			&quot;key&quot;: &quot;minisub_link&quot;,
			&quot;desc&quot;: &quot;Create a link in DSM to MiniSub.
MiniSub is a html5 based webinterface included in Subsonic&quot;
		}]
	}]
}]

uninstall_uifile:

[{
	&quot;step_title&quot;: &quot;Create Backup&quot;,
	&quot;items&quot;:
	[{
		&quot;type&quot;: &quot;singleselect&quot;,
		&quot;desc&quot;: &quot;Would you like to create a backup of Subsonic in the public folder?&quot;,
		&quot;subitems&quot;:
		[{
			&quot;key&quot;: &quot;no&quot;,
			&quot;desc&quot;: &quot;No&quot;
		},
		{
			&quot;key&quot;: &quot;uninstall_backup&quot;,
			&quot;desc&quot;: &quot;Yes&quot;
		}]
	}]
}]

INFO

package=&quot;Subsonic&quot;
version=&quot;4.7-026&quot;
description=&quot;Subsonic is a free, web-based media streamer, providing ubiquitous access to your music.&quot;
maintainer=&quot;Subsonic is developed by Sindre Mehus (subsonic.org), MiniSub is developed by tsquillario (forum.subsonic.org), Subtunes is develpoed by mattgoldspink1 (code.google.com/p/subtunes/), MashupMod is developed by MadEvil (forum.subsonic.org), Synology package is maintained at eg-blog.de&quot;
arch=&quot;88f6281 88f6282&quot;
adminport=&quot;4040&quot;
adminurl=&quot;/&quot;
firmware=&quot;3.1-1594&quot;
helpurl=&quot;http://eg-blog.de&quot;
report_url=&quot;http://eg-blog.de&quot;
package_icon=&quot;base 64 code, too long to post it here&quot;
install_reboot=&quot;yes&quot;

Config (Subsonic):

{
	&quot;.url&quot;: {
		&quot;de.eg-blog.subsonic&quot;: {
			&quot;type&quot;: &quot;url&quot;,
			&quot;allUsers&quot;: true,
			&quot;title&quot;: &quot;Subsonic&quot;,
			&quot;desc&quot;: &quot;Subsonic Music Streamer&quot;,
			&quot;icon&quot;: &quot;images/icon_48.png&quot;,
			&quot;protocol&quot;: &quot;http&quot;,
			&quot;url&quot;: &quot;/&quot;,
			&quot;port&quot;: &quot;4040&quot;
		}
	}
}

Config (MiniSub):

{
	&quot;.url&quot;: {
		&quot;de.eg-blog.subsonic.MiniSub&quot;: {
			&quot;type&quot;: &quot;url&quot;,
			&quot;allUsers&quot;: true,
			&quot;title&quot;: &quot;MiniSub&quot;,
			&quot;desc&quot;: &quot;Subsonic Music Streamer - MiniSub html5 interface&quot;,
			&quot;icon&quot;: &quot;icon_48.png&quot;,
			&quot;protocol&quot;: &quot;http&quot;,
			&quot;url&quot;: &quot;/mini/&quot;,
			&quot;port&quot;: &quot;4040&quot;
		}
	}
}

Config (Subtunes):

{
	&quot;.url&quot;: {
		&quot;de.eg-blog.subsonic.Subtunes&quot;: {
			&quot;type&quot;: &quot;url&quot;,
			&quot;allUsers&quot;: true,
			&quot;title&quot;: &quot;Subtunes&quot;,
			&quot;desc&quot;: &quot;Subsonic Music Streamer - Subtunes html5 interface&quot;,
			&quot;icon&quot;: &quot;icons/icon_48.png&quot;,
			&quot;protocol&quot;: &quot;http&quot;,
			&quot;url&quot;: &quot;/Subtunes/&quot;,
			&quot;port&quot;: &quot;4040&quot;
		}
	}
}

subsonic.sh (changed)

#!/bin/sh

###################################################################################
# Shell script for starting Subsonic.  See http://subsonic.org.
#
# Author: Sindre Mehus
###################################################################################

###added by gigon, see eg-blog.de for details---------------------------
RAM=$((`free | grep Mem: | sed -e &quot;s/^ *Mem: *\([0-9]*\).*$/\1/&quot;`/1024))
if [ $RAM -le 128 ]; then
    SUBSONIC_MAX_MEMORY=80
elif [ $RAM -le 256 ]; then
    SUBSONIC_MAX_MEMORY=192
elif [ $RAM -gt 256 ]; then
	SUBSONIC_MAX_MEMORY=384
fi
###---------------------------------------------------------------------

SUBSONIC_HOME=/usr/syno/synoman/webman/3rdparty/Subsonic
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=4040
SUBSONIC_HTTPS_PORT=4041
SUBSONIC_CONTEXT_PATH=/

#remove the # in the next line if you want to set the max memory manually
#SUBSONIC_MAX_MEMORY=100

SUBSONIC_PIDFILE=
SUBSONIC_DEFAULT_MUSIC_FOLDER=/volume1/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/volume1/music/Podcast
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/volume1/music/playlists

quiet=0

usage() {
    echo &quot;Usage: subsonic.sh [options]&quot;
    echo &quot;  --help               This small usage guide.&quot;
    echo &quot;  --home=DIR           The directory where Subsonic will create files.&quot;
    echo &quot;                       Make sure it is writable. Default: /var/subsonic&quot;
    echo &quot;  --host=HOST          The host name or IP address on which to bind Subsonic.&quot;
    echo &quot;                       Only relevant if you have multiple network interfaces and want&quot;
    echo &quot;                       to make Subsonic available on only one of them. The default value&quot;
    echo &quot;                       will bind Subsonic to all available network interfaces. Default: 0.0.0.0&quot;
    echo &quot;  --port=PORT          The port on which Subsonic will listen for&quot;
    echo &quot;                       incoming HTTP traffic. Default: 4040&quot;
    echo &quot;  --https-port=PORT    The port on which Subsonic will listen for&quot;
    echo &quot;                       incoming HTTPS traffic. Default: 0 (disabled)&quot;
    echo &quot;  --context-path=PATH  The context path, i.e., the last part of the Subsonic&quot;
    echo &quot;                       URL. Typically '/' or '/subsonic'. Default '/'&quot;
    echo &quot;  --max-memory=MB      The memory limit (max Java heap size) in megabytes.&quot;
    echo &quot;                       Default: 100&quot;
    echo &quot;  --pidfile=PIDFILE    Write PID to this file. Default not created.&quot;
    echo &quot;  --quiet              Don't print anything to standard out. Default false.&quot;
    echo &quot;  --default-music-folder=DIR    Configure Subsonic to use this folder for music.  This option &quot;
    echo &quot;                                only has effect the first time Subsonic is started. Default '/var/music'&quot;
    echo &quot;  --default-podcast-folder=DIR  Configure Subsonic to use this folder for Podcasts.  This option &quot;
    echo &quot;                                only has effect the first time Subsonic is started. Default '/var/music/Podcast'&quot;
    echo &quot;  --default-playlist-folder=DIR Configure Subsonic to use this folder for playlists.  This option &quot;
    echo &quot;                                only has effect the first time Subsonic is started. Default '/var/playlists'&quot;
    exit 1
}

# Parse arguments.
while [ $# -ge 1 ]; do
    case $1 in
        --help)
            usage
            ;;
        --home=?*)
            SUBSONIC_HOME=${1#--home=}
            ;;
        --host=?*)
            SUBSONIC_HOST=${1#--host=}
            ;;
        --port=?*)
            SUBSONIC_PORT=${1#--port=}
            ;;
        --https-port=?*)
            SUBSONIC_HTTPS_PORT=${1#--https-port=}
            ;;
        --context-path=?*)
            SUBSONIC_CONTEXT_PATH=${1#--context-path=}
            ;;
        --max-memory=?*)
            SUBSONIC_MAX_MEMORY=${1#--max-memory=}
            ;;
        --pidfile=?*)
            SUBSONIC_PIDFILE=${1#--pidfile=}
            ;;
        --quiet)
            quiet=1
            ;;
        --default-music-folder=?*)
            SUBSONIC_DEFAULT_MUSIC_FOLDER=${1#--default-music-folder=}
            ;;
        --default-podcast-folder=?*)
            SUBSONIC_DEFAULT_PODCAST_FOLDER=${1#--default-podcast-folder=}
            ;;
        --default-playlist-folder=?*)
            SUBSONIC_DEFAULT_PLAYLIST_FOLDER=${1#--default-playlist-folder=}
            ;;
        *)
            usage
            ;;
    esac
    shift
done

# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA=java
if [ -e &quot;${JAVA_HOME}&quot; ]
    then
    JAVA=${JAVA_HOME}/bin/java
fi

# Create Subsonic home directory.
mkdir -p ${SUBSONIC_HOME}
LOG=${SUBSONIC_HOME}/subsonic_sh.log
rm -f ${LOG}

cd $(dirname $0)
if [ -L $0 ] &amp;&amp; ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
    cd $(dirname $(readlink $0))
fi

${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
  -Dsubsonic.home=${SUBSONIC_HOME} \
  -Dsubsonic.host=${SUBSONIC_HOST} \
  -Dsubsonic.port=${SUBSONIC_PORT} \
  -Dsubsonic.httpsPort=${SUBSONIC_HTTPS_PORT} \
  -Dsubsonic.contextPath=${SUBSONIC_CONTEXT_PATH} \
  -Dsubsonic.defaultMusicFolder=${SUBSONIC_DEFAULT_MUSIC_FOLDER} \
  -Dsubsonic.defaultPodcastFolder=${SUBSONIC_DEFAULT_PODCAST_FOLDER} \
  -Dsubsonic.defaultPlaylistFolder=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER} \
  -Djava.awt.headless=true \
  -verbose:gc \
  -jar subsonic-booter-jar-with-dependencies.jar &gt; ${LOG} 2&gt;&amp;1 &amp;

# Write pid to pidfile if it is defined.
if [ $SUBSONIC_PIDFILE ]; then
    echo $! &gt; ${SUBSONIC_PIDFILE}
fi

if [ $quiet = 0 ]; then
    echo Started Subsonic [PID $!, ${LOG}]
fi