eg-blog

Feed Rss

Archive for Februar, 2012

New package available here.

_______________________________________________________________________________

Today I’ve created a package of ownCloud3.0.0 for Synology NAS boxes.

Owncloud could be an alternative to the DSM filemanager, I don’t really know it, yet.

It is a clean install, no things are changed.   If I like it and it works well (and if I have any free time left) I will probably create another package e.g. with symlinks to the shared folders.

You can download it here:

owncloud3.0.0.spk (3MB)

Have fun with it ;)

First of all, again: If you already have a Subsonic package installed and running fine: Stay where you are!

Subsonic itself is the same and you might loose your settings during update, I still don’t know when and why this happens, the error is not really reproducible.

I’ve changed the installation/update/uninstallation procedure and included a backup and restore option.

  • While installing, you can select whether to restore a Backup of Subsonic (which was created during uninstall or with the Subsonic backup creator) or to perform a fresh install. To restore create a folder named Subsonic (with capital S) in your public folder. If you haven’t got a public folder (on multi-bay-nas) create a new shared folder in the DSM. Now place the backup-ed files into the Subsonic folder.
  • While updating you can select whether to update normally or restore a backup from the public folder.
  • While uninstalling you can select whether to create a backup in the public folder or not. (You don’t have to do anything to the folder if you want to restore it afterwards)

There is also a new ffmpeg version included, but still no x264 support,. If you are a pro and can compile such things properly or if you’ve got a compiled version for ARM or x86 please let me know, thanks ;) .

Thanks to patters I’ve included timezone support, so the log files should have the correct time now.

The package will be added to both package sources soon.

You can manually download them here:

Subsonic4.6-020-ARM.spk (32MB)

Subsonic4.6-020-x86.spk (32MB)

Scripts

INFO
package="Subsonic"
version="4.6-020"
description="Subsonic is a free, web-based media streamer, providing ubiquitous access to your music."
maintainer="Sindre Mehus, Synology package maintained at eg-blog.de"
arch="88f6281 88f6282"
adminport="4040"
adminurl="/"
firmware="3.1-1594"
helpurl="http://eg-blog.de"
package_icon="package_icon_in_base64_code_too_long_to_post_it_here"
install_reboot="yes"
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 "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

#########################################
#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 "Can't find a folder named 'Subsonic' in your public folder. " > $SYNOPKG_TEMP_LOGFILE
		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
		exit 1
	fi
fi

exit 0
postinst
#!/bin/sh

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

#variable for process ID
PID=""

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

####################################
#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"

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

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

#set ownership of Subsonic folder tree
chown -R subsonic ${SYNOPKG_PKGDEST}

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

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 "Can't find a folder named 'Subsonic' in your public folder." > $SYNOPKG_TEMP_LOGFILE
		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
		exit 1
	else
		#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

		#give it some time to start up
		sleep 90

		#stop subsonic
		subsonic_get_pid
		kill $PID
		sleep 5

		#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

		#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

		#copy files
		cp -r $PUBLIC/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
fi
exit 0
preupgrade
#!/bin/sh

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

#variable for process ID
PID=""

##############################################
#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
	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 ${update_restore} ]; then
	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
#!/bin/sh

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

#variable for process ID
PID=""

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

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

################################
#make it working again

#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

#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 bigge
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

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

#subsonic daemon user has been deleted and recreated so we need to reset ownership (new UID)
chown -R subsonic ${SYNOPKG_PKGDEST}/

#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 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

#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

###############################
#restore subsonic db index and settings
if [ ! -z ${update_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 "Can't find a folder named 'Subsonic' found in your public folder." > $SYNOPKG_TEMP_LOGFILE
		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
		exit 1
	else
		cp -r $PUBLIC/Subsonic/* ${SYNOPKG_PKGDEST}/
	fi
else
	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 ${SYNOPKG_PKGDEST}/../subsonic_update_backup
	fi
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

exit 0
preuninst
#!/bin/sh

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

#variable for process ID
PID=""

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

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

subsonic_get_pid

if [ -z $PID ]; then
	sleep 1
else
	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
	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.properties *.index $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/db $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/lucene $PUBLIC/Subsonic
	cp -r ${SYNOPKG_PKGDEST}/thumbs $PUBLIC/Subsonic
fi

exit 0
postuninst
#!/bin/sh

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

#remove subsonic daemon user
synouser --del subsonic

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

#remove temp symlink
rm /tmp/subsonic

exit 0
start-stop-status
#!/bin/sh

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

#variable for process ID
PID=""

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

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

case "$1" in
   start)
	  SUBSONIC_HOMEDIR=`cat /etc/passwd | sed -r '/Subsonic daemon user/!d;s/^.*:Subsonic daemon user:(.*):.*$/\1/'`

	  #set the current timezone for Java so that Subsonic log timestamps are accurate
      TZ=`cat /etc/TZ`
      grep "^export TZ" $SUBSONIC_HOMEDIR/.profile > /dev/null \
      && sed -i "s%^export TZ.*$%export TZ="$TZ"%" $SUBSONIC_HOMEDIR/.profile \
      || echo export TZ=${TZ} >> $SUBSONIC_HOMEDIR/.profile

	  #set up symlink for the DSM GUI icon
	  if [ -d /usr/syno/synoman/webman/3rdparty ]; then
		ln -s ${SYNOPKG_PKGDEST}/ /usr/syno/synoman/webman/3rdparty/Subsonic
	  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
	  fi
	  #create symlink to the created directory
	  if [ ! -L /tmp/subsonic ]; then
		ln -s ${SYNOPKG_PKGDEST}/../../@tmp/subsonic /tmp/
	  fi
	  # 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 Symlink and DSM icon
	  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
   ;;
   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
install_uifile
[{
	"step_title": "Restore Backup",
	"items":
	[{
		"type": "singleselect",
		"desc": "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",
		"subitems":
		[{
			"key": "install_restore",
			"desc": "Yes"
		},
		{
			"key": "no",
			"desc": "No"
		}]
	}]
}]
upgrade_uifile
[{
	"step_title": "Restore Backup",
	"items":
	[{
		"type": "singleselect",
		"desc": "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",
		"subitems":
		[{
			"key": "update_restore",
			"desc": "Yes, I have a custom backup, please restore it"
		},
		{
			"key": "no",
			"desc": "No, just update and leave Subsonic as it is now (all preferences and the library will be kept)"
		}]
	}]
}]
uninstall_uifile
[{
	"step_title": "Create Backup",
	"items":
	[{
		"type": "singleselect",
		"desc": "Would you like to create a backup of Subsonic in the public folder?",
		"subitems":
		[{
			"key": "uninstall_backup",
			"desc": "Yes"
		},
		{
			"key": "no",
			"desc": "No"
		}]
	}]
}]