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
