- The .spk Package is no longer tgz but tar
- backup folder /volumeX/@appstore/subsonic-update-backup/ will now be removed after uninstall
- Subsonic music folder is set to /volume1/music. Change it to wherever your music is.
Scripts
INFO
package="Subsonic"
version="4.6-18"
maintainer="Sindre Mehus, syno package maintained at synology-forum.de"
description="Subsonic is a free, web-based media streamer, providing ubiquitous access to your music."
arch="88f6281 88f6282"
firmware="3.1-1594"
package_icon="<base64 code of package center icon, far too long to post it here>"
install_reboot="yes"
preinst (this script and parts of other scripts were copied from scripts published on pcloadletter.co.uk)
#!/bin/sh
#--------Subsonic preinstall script
#--------package maintained at synology-forum.de
source /etc/profile
########################################
#check if Jva 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
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
exit 1
fi
exit 0
postinst
#!/bin/sh
#--------SUBSONIC postinstall script
#--------package maintained at synology-forum.de
####################################
#subsonic user settings
#create subsonic daemon user
synouser --add subsonic `${SYNOPKG_PKGDEST}/passgen 1 20` "Subsonic daemon user" 0 "" ""
#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"
#set ownership of Subsonic folder tree
chown -R subsonic ${SYNOPKG_PKGDEST}
#####################################
#other stuff
#make the Subsonic start script executable
chmod +x ${SYNOPKG_PKGDEST}/subsonic.sh
#set up symlink for the DSM GUI
if [ -d /usr/syno/synoman/webman/3rdparty ]; then
ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
fi
exit 0
preupgrade
#!/bin/sh
#--------Subsonic preupgrade script
#--------package maintained at synology-forum.de
#variable for process ID
PID=""
##############################################
#function to get the process id of Subsonic
subsonic_get_pid ()
{
#use "-f 1"
PID=`ps |grep java |grep subsonic |cut -d " " -f 1`
#if PID is <10000 than "-f 1" is empty so use "-f 2"
if [ -z $PID ]; then
PID=`ps |grep java |grep subsonic |cut -d " " -f 2`
fi
}
###########################
#stop Subsonic if it is runing
subsonic_get_pid
kill $PID
sleep 5
#delete temp files
rm -r /tmp/subsonic
###########################
#backup subsonic.properties and db Folder
mkdir ${SYNOPKG_PKGDEST}/../subsonic_update_backup
cp ${SYNOPKG_PKGDEST}/subsonic.properties *.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
exit 0
postupgrade
#!/bin/sh
#--------SUBSONIC postupgrade script
#--------package maintained at synology-forum.de
#variable for process ID
PID=""
##############################################
#function to get the process id of Subsonic
subsonic_get_pid ()
{
#use "-f 1"
PID=`ps |grep java |grep subsonic |cut -d " " -f 1`
#if PID is <10000 than "-f 1" is empty so use "-f 2"
if [ -z $PID ]; then
PID=`ps |grep java |grep subsonic |cut -d " " -f 2`
fi
}
################################
#make it working again
#subsonic daemon user has been deleted and recreated so we need to reset ownership (new UID)
chown -R subsonic ${SYNOPKG_PKGDEST}/
#restart Web Station to clear webserver caches
if [ -f /usr/syno/etc/rc.d/S97apache-user.sh ]; then
/usr/syno/etc/rc.d/S97apache-user.sh restart
fi
###############################
#start and stop subsonic for first initialisation
#start subsonic as subsonic user
su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
#give it some time to start up
sleep 90
#stop subsonic
subsonic_get_pid
kill $PID
sleep 5
#delete temp files
rm -r /tmp/subsonic
#sleep 5
###############################
#restore subsonic db index and settings
cp -r ${SYNOPKG_PKGDEST}/../subsonic_update_backup/* ${SYNOPKG_PKGDEST}/
#remove backup folder
#remove the next lines to keep a backup in the @appstore folder
if [ -d ${SYNOPKG_PKGDEST}/../subsonic_update_backup ]; then
rm -r ../subsonic_update_backup
fi
exit 0
preuninst
#!/bin/sh
#--------SUBSONIC preuninstall script
#--------package maintained at synology-forum.de
#variable for process ID
PID=""
##############################################
#function to get the process id of Subsonic
subsonic_get_pid ()
{
#use "-f 1"
PID=`ps |grep java |grep subsonic |cut -d " " -f 1`
#if PID is <10000 than "-f 1" is empty so use "-f 2"
if [ -z $PID ]; then
PID=`ps |grep java |grep subsonic |cut -d " " -f 2`
fi
}
subsonic_get_pid
if [ -z $PID ]; then
sleep 1
else
kill $PID
sleep 5
#delete temp files
rm -r /tmp/subsonic
fi
exit 0
postuninst
#!/bin/sh
#--------SUBSONIC postuninstall script
#--------package maintained at synology-forum.de
#remove subsonic daemon user
synouser --del subsonic
#remove DSM icon symlink
rm /usr/syno/synoman/webman/3rdparty/Subsonic
exit 0
start-stop-status
#!/bin/sh
#--------Subsonic start-stop-status script
#--------package maintained at synology-forum.de
#variable for process ID
PID=""
##############################################
#function to get the process id of Subsonic
subsonic_get_pid ()
{
#use "-f 1"
PID=`ps |grep java |grep subsonic |cut -d " " -f 1`
#if PID is <10000 than "-f 1" is empty so use "-f 2"
if [ -z $PID ]; then
PID=`ps |grep java |grep subsonic |cut -d " " -f 2`
fi
}
case "$1" in
start)
# starting subsonic as subsonic daemon user
su - subsonic -s /bin/sh -c /usr/syno/synoman/webman/3rdparty/Subsonic/subsonic.sh
sleep 5
exit 0
;;
stop)
#stop subsonic
subsonic_get_pid
kill $PID
sleep 2
#delete temp files
rm -r /tmp/subsonic
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.log"
exit 0
;;
esac