Paketmanagement

Status
Für weitere Antworten geschlossen.

itari

Benutzer
Mitglied seit
15. Mai 2008
Beiträge
21.900
Punkte für Reaktionen
14
Punkte
0
Mit der aktuellen Firmware (722) ist ein neues Paketmanagement eingeführt worden. Die ladbaren Paket-Dateien habe die Endung .spk. Zur Zeit gibt es ein Paket im Synology-Download: SqueezeCenter-7.2.0-011. Ich habe mir mal den Inhalt des Archivs angesehen und folgende Directories-Struktur vorgefunden:

INFO
package.tgz
scripts
--postinst
--preinst
--start-stop-status
--postuninst
--preuninst

Inhalt der Datei INFO:
Rich (BBCode):
package="SqueezeCenter"
version="7.2"
maintainer="Synology Inc."
description="SqueezeCenter is the best software to stream your music."
adminport="9002"
arch="noarch"

Inhalt der Datei postinst:
Rich (BBCode):
#!/bin/sh

eval $(env | grep "^SYNOPKG_PKGDEST=")
ret=`chown -R admin.users $SYNOPKG_PKGDEST`
if [ "x" == "x$ret" ]; then
	exit 0 
else
	exit 0 
fi

Inhalt der Datei preinst, postuninst und preuninst:
Rich (BBCode):
#!/bin/sh

exit 0

Inhalt der Datei start-stop-status:
Rich (BBCode):
#!/bin/sh
PKGPATH="/var/packages/SqueezeCenter"

SLIMPKG=`ls -l $PKGPATH/target | awk -F "-> " '{print $2}'`
SLIMPORT=`/bin/get_key_value $PKGPATH/INFO adminport`
CACHEPATH="Cache"
LOGPATH="Logs"
PREFSPATH="prefs"
PIDFILENAME="${CACHEPATH}/slimserver.pid"
MYSQLPIDFILENAME="${CACHEPATH}/squeezecenter-mysql.pid"
LOGFILENAME="${LOGPATH}/server.log"

SLIMPIDFILE="${SLIMPKG}/${PIDFILENAME}"
SLIMMYSQLPIDFILE="${SLIMPKG}/${MYSQLPIDFILENAME}"
SLIMLOGFILE="${SLIMPKG}/${LOGFILENAME}"
SLIMCACHEPATH="${SLIMPKG}/${CACHEPATH}"
SLIMLOGPATH="${SLIMPKG}/${LOGPATH}"
SLIMPREFSPATH="${SLIMPKG}/${PREFSPATH}"

SLIMSERVERBIN="slimserver.pl"
SLIMSCANNERBIN="scanner.pl"

get_pid()
{
	if [ ! -f ${SLIMPIDFILE} ]; then
		return 1
	else
		pid=`cat ${SLIMPIDFILE} 2>/dev/null`
		if [ -f /proc/$pid/cmdline ]; then
			echo $pid
			return 0
		else
			rm -f ${SLIMPIDFILE}
			return 2
		fi
	fi
}

case $1 in
	start)
		slimperl="${SLIMPKG}/${SLIMSERVERBIN}"
		cmd="${slimperl} --daemon --user admin --pidfile ${SLIMPIDFILE}"
		cmd="$cmd --cachedir ${SLIMCACHEPATH} --logdir ${SLIMLOGPATH} --prefsdir ${SLIMPREFSPATH}"
		if [ "x${SLIMPORT}" != "x" ]; then
			cmd="$cmd --httpport ${SLIMPORT}"
		fi
		`$cmd`
		if [ -f "{$SLIMPIDFILE}" ]; then
			`chown admin.users ${SLIMPIDFILE}`
		fi
		exit 0
	;;
	stop)
		#0 if pid exist but proc/pid do not exist, program crashed
		SLIM_PID=`get_pid`
		RET=$?
		case "$RET" in
			2)
				exit 2
			;;
			1)
				exit 1
			;;                                                  
		esac
		#1 kill pid and check that pidfile is removed
		# send kill signal and wait maximum 30 seconds for the process to end
		`kill ${SLIM_PID}`
		waittime=0
		while [ -d /proc/$SLIM_PID ]; do
			`sleep 1`
                        waittime=`expr $waittime + 1`
			if [ $waittime -ge 30 ]; then
				break
			fi
		done
		`$0 killall`
		#2 check proc/pid do not exist
		if [ ! -d /proc/$SLIM_PID ]; then
			[ -f ${SLIMPIDFILE} ] && rm -f ${SLIMPIDFILE}
			exit 0
		else
			exit 1
		fi
	;;
	status)
		SLIM_PID=`get_pid`
		RET=$?
		exit $RET
	;;
	killall)
		SlimPLPID=`pidof ${SLIMSERVERBIN}`
		if [ ! -z "${SlimPLPID}" ]; then
			`kill -9 ${SlimPLPID}`
		fi
		SlimSQLPID=`ps | grep mysqld | grep SqueezeCenter |grep -v grep | awk '{print $1}'`
		if [ ! -z "${SlimSQLPID}" ]; then
			`kill -9 ${SlimSQLPID}`
		fi
		SlimScannerPID=`pidof ${SLIMSCANNERBIN}`
		if [ ! -z "${SlimScannerPID}" ]; then
			`kill -9 ${SlimScannerPID}`
		fi
        ;;
	log)
		echo "${SLIMLOGFILE}"
		exit 0
	;;
esac

Vielleicht hat ja jemand das Paket installiert und kann mal schauen, wo (in welchem rc-Verzeichnis) und unter welchem Namen das start-stop-status-Skript gelagert wird. Und vielleicht kann derjenige auch schauen, wo das Paket hinkopiert wurde.

Vielen Dank bereits jetzt

itari
 

Trolli

Benutzer
Mitglied seit
12. Jul 2007
Beiträge
9.848
Punkte für Reaktionen
1
Punkte
0

itari

Benutzer
Mitglied seit
15. Mai 2008
Beiträge
21.900
Punkte für Reaktionen
14
Punkte
0
Joa, soweit sind wir nur auch schon gewesen ...

Ich denke, dass wird erst so richtig werden, wenn die Synology-Leute eine Anleitung veröffentlichen und da ein wenig beschreiben, was wo wie hinkopiert wird. Denn im Moment seh ich nicht, wo man die Verzeichnisse konfigurieren kann. Ich weiß es deshalb nicht, weil ich annehme, dass das Start-Stop-Skript einfach als rc-File kopiert wird und die darin vereinbarten Verzeichnisse nur für die Start/Stop-Geschichte drin sind. Was ich meine, ist, dass sowas wie ein Installationsskript fehlt, in dem Pfade angegeben werden können.

Und das nur durch Trial&Error herauszutesten, da ist mir die Zeit zu schade.

itari
 

Henryk42

Benutzer
Mitglied seit
11. Mai 2007
Beiträge
135
Punkte für Reaktionen
0
Punkte
16
Vielleicht hat ja jemand das Paket installiert und kann mal schauen, wo (in welchem rc-Verzeichnis) und unter welchem Namen das start-stop-status-Skript gelagert wird. Und vielleicht kann derjenige auch schauen, wo das Paket hinkopiert wurde.

Vielen Dank bereits jetzt

itari

Hallo itari,
unter:
/root/usr/local/etc/rc.d
habe ich die Datei SqueezeCenter.sh gefunden
kann dir das Helfen ?

mfg
Henryk42
 

Anhänge

  • SqueezeCenter.sh.txt
    2,5 KB · Aufrufe: 50

itari

Benutzer
Mitglied seit
15. Mai 2008
Beiträge
21.900
Punkte für Reaktionen
14
Punkte
0
qHenryk42,

ah ja. Hatte ich fast vermutet und ist nun zur Gewissheit geworden. Erstens, dass es tatsächlich ausschließlich das rc-Skript ist und zweitens, dass es genau da ist, wo sich auch die anderen rc-skripte tummeln.

Danke sehr.

itari
 

b00n

Benutzer
Mitglied seit
17. Apr 2008
Beiträge
131
Punkte für Reaktionen
0
Punkte
16
Im englischen Forum hat der User merty eine Erklärung zu .spk packages gepostet. Ich zitiere es ausnahmsweise, da ich nicht weiss, wie lange synology.com heute down ist (Wartung).

merty schrieb:
Hi,

why
When the new firmware came out, I noticed, like many others, the new 'package management' option. Finally a simple way for non-experienced users to 'update' their disk stations with other programs and possibilities. As an experienced unix developer, I was interested in the way those packages works so that I would be able to create them on my own. However, at the moment, there is no documentation whatsoever how this will work. Luckely enough, the first package, squeezecenter, was also released. By looking at the code en playing around with home-made-packages, I was able to determine how packages and packaging manager works. I'll try to explain in this posting how to make .spk files and how they are able to work. Doing this, I hope more developers will develop packages that can be used and downloaded by users without any knowledge about linux, toolchains, command lines and other scary stuff..
Mind you, I'm not affiliated with Synology in any way, I'm just an enthusiastic user of a DS408..
To create packages, one must have a basic understanding of unix tools and writing shell scripts.

Package Structure
An .spk file is nothing more then a tar file, containing a standard structure and files. It is not related to any existing .spk packaging formats that I know off and as far as I can see, this .spk structure is designed/defined by Synology themselves and in no way compatible with any other packaging methods. You can 'unpack' any spk file simply by untarring (tar -xvf filename) the file. Every package will contain the following files/directories (mind the capitals!):

  • INFO
    This is a file containing information that will be displayed and used during installation. It consists of multiple key="value" lines. The following keys are used:
    package : The - unique! - name of the package, as will be displayed during install en will be used as directory name under which the whole package will reside.
    version : guess what...
    maintainer: Who is the 'owner' of the package. Only used for information purposes
    description: A small description of the package. Only used for information purposes
    arch: Architecture. Not sure what valuable options are. At least "noarch" will work on every disk station. I presume other options will be "ppc" or "arm". When trying to install a package that doesn't fit the architecture of you disk station, it will fail (since it will not work anyway).
    adminport: optional. If the program is installed and has it own "administration" webpage, this will be the port number the server listens to. There is no way to set the complete URL or path..

    WARNING: Since most keywords and values might be parsed by unix programs and shell scripts during the installation process, it is recommended not to use any special characters (like '"';-[!@]\ ....) , just stick with regular ASCII.
    package.tgz
    This is a compressed (gzip) tar file containing all the files that are needed. The installer will automatically unpack this package. WARNING Any other name will be ignored and not unpacked..
    scripts
    This is a directory containing multiple unix sh shell scripts:

    • * postinst
      * postuninst
      * preinst
      * preuninst
      * start-stop-status
    all '*inst' scripts are used during installation and uninstallation of the package. Returning anything other then '0' as result will break the installation or uninstallation. Preinst will be called before anything is installed (this is the place to check if all installation requirements are met, for example), Postinst after (to set the file rights of the installed files, for example). Same fore the "*uninst" but then when using the 'uninstall' button on the package manager page. The start-stop-status script will be called by the package manager. This script will always be given an argument via the package manager. Hitting "run" in packagemanager will start this script with the 'start' argument, 'stop' result in 'stop'. When (re-)loading the packagemanager page, it will also call the script for a 'status' update. Finally, there is the possibility to show the log file via the info window. In all cases, returning '0' means 'all ok' and '1' means 'error occurred' or 'not running' (when checking status). When given the 'log' argument in the start-stop-status script, you are able to echo the filename of the logfile to STDOUT and the content of that file will be displayed under the 'log' tab of the info window.

Installation process
When uploading a .spk file, the file will be uploaded to a temporary directory (can be found in the environment variable 'SYNOPKG_PKGINST_TEMP_DIR, during the running of the 'preinst' script). Normally, this will be in a '@tmp' dir on the root of volume1. It will be unpacked (not the package.tgz yet) and script 'preinst' will be called. After that, the user has to select a volume to install to.Under the root of this volume, a '@appstore will be created, if this directory not exists already. In this directory, a directory using the name given in the INFO file as value of key 'package' will be created (this name can also be found in the SYNOPKG_PKGNAME environment variable). The 'package.tgz' will be uncompressed and unpacked under that directory (which can be found in environment variable 'SYNOPKG_PKGDEST'. After this, in the directory /var/packages will be a directory created by the name of the package. In this directory there will be the scripts dir and INFO file of the package. Also a link called 'target' which will point to the unpacked directory under your @appstore dir in the destination volume. The directories under /var/packages/ will be used by the packagemanager. Finally, the script 'postinst' will be called and all temporary files will be removed.

Note that the 'adminport' option under INFO is a bit strange. It will only be used when displaying management page URL if the program status returns 'running' . The packagemanager will automaticly create the url out of 'http://' +hostname+':'+adminport. There is no way to change that url other then the port number.

Adding a 3rdparty program into the package
Even before the new firmware, it was possible to create a '3rdparty' option in the disk station manager. Using the package installer, this will become much easier to do.
It's quite simple:
1. Create an application.cfg file and image directory as described in '3rd party apps integration guide'
2. place that file along with program files, images, cgi scripts and all in package.tgz
3. Create a softlink (ln -s ) from /usr/syno/synoman/3rdparty/webman/$SYNOPKG_PKGNAME to $SYNOPKG_PKGDEST in your postinst script and make sure link is removed in the postuninst
4. Make sure start-stop-status script will always return '0' (or '1' for status info, since nothing is running all the time)
5. Create other files (scripts, INFO) and pack them (tar -cvf whatevername.spk *) into a .spk .

Thats it. By installing it, it will also create a 3rdparty directory. If you press 'reload' you will see the package can also be found in the navigation tree. Uninstallation removes all the files of the package, including the softlink.

Warnings/tips
* Installation is done under 'root' rights. THIS CAN BE EXTREMELY DANGEROUS. Be sure in what you are doing. Stay away from any 'normal' directories like /sbin /usr/bin /usr/syno/bin, unless you know what you are doing. Dont install .spk unless you trust the sender or checked the installation scripts.
* Installing and using .spk files is at your own risk. Don't blame Synology -or even me- for not working correctly or not giving the right answers. Read the disclaimer of this forum !
* Creating softlinks from /usr/syno/synoman/webman/3rdparty/ to the package on a volume is a better idea then to place all under /usr/syno... directory itself. Doing this way, you prevent that disk doesn't run out of space
* You can add your 'own' key="value" pairs to the INFO file. These will be ignored by the installer, but can be used for 'global configuration keys' during your post/preinstall scripts.
* Make sure the read-right-execute rights are in place. Use the 'chown' and 'chmod' commands in the scripts to make sure they are.
* 3rdparty options always points to webpages. If you are using the same webserver/port as the disk station manager, '.nph' files will not work (without altering configuration), but ".cgi" files will. They will be treated the 'old cgi way', which means the webserver just executes them and the cgi program makes sure they spit out the relevant HTML code.
* Because the installation process is called via the webmanager interface, it is possible to retrieve more information via the environment variables that might be needed during the installation process. You can think of "USERNAME" => logged in user or "DOCUMENT_ROOT" => handy to know where to install .html or .cgi files for use under the webmanager interface.

Example
You can find a example .spk file made by me at http://merty.xs4all.nl/syno/. After installing this package, you will notice a 3rdpary entry in the navigation tree on the left with the name 'Current Connections'. When clicking on it, it will show all network and windows filesharing connections from/to the diskstation. It isn't that great, but a good working example how to use packages and 3rdparty option.

Remco Schellekens
 

itari

Benutzer
Mitglied seit
15. Mai 2008
Beiträge
21.900
Punkte für Reaktionen
14
Punkte
0
Ich hoffe, du hast meine Fragen zu dem Paket-Management auch im internationalen Forum gelesen und bemerkt, dass ich ein wenig skeptisch bin, solange die Frage nach einem update-Prozess nicht vernünftig beantwortet ist. Wollen wir ähnliche Verhältnisse wie beim katastrophalen Firmware-Update auch für die Applications? Insbesondere, wo wir einen guten update-Prozess durch das ipkg gewohnt sind? Andere Herstellen machen es da im meinen Augen besser. Aber es kann sich ja noch ändern - die Hoffnung stirbt ja bekanntlich immer zuletzt ...

itari
 

Trolli

Benutzer
Mitglied seit
12. Jul 2007
Beiträge
9.848
Punkte für Reaktionen
1
Punkte
0
Status
Für weitere Antworten geschlossen.
 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat