Index: Slim/Utils/OS/SSODS.pm =================================================================== --- Slim/Utils/OS/SSODS.pm (Revision 0) +++ Slim/Utils/OS/SSODS.pm (Revision 0) @@ -0,0 +1,171 @@ +package Slim::Utils::OS::SSODS; + +# Squeezebox Server Copyright 2001-2009 Logitech. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License, +# version 2. +# +# This module written by Philippe Kehl +# +# Synology DiskStation (DS) and QNAP TurboStation (TS) include a wide range of +# NAS devices based on several architectures (PPC, ARM, PPCe500v2, ARMv5, x86, +# and maybe others). They all use a custom and minimal Linux system (Linux 2.6 +# based). SSODS (Squeezebox Server On DiskStation) and SSOTS (SqueezeboxServer +# On TurboStation), which is a re-branded SSODS, is an addon to the respective +# systems that provides the environment (i.e. perl, some tools, scripts and +# glue) to run Squeezebox Server on these devices. +# +# This module provides customisations for SSODS and SSOTS. + +use strict; + +use base qw(Slim::Utils::OS::Linux); + +use constant MAX_LOGSIZE => 1024*1024*1; # maximum log size: 1 MB + + +sub initDetails +{ + my $class = shift; + + $class->{osDetails} = $class->SUPER::initDetails(); + + if (-f '/etc/synoinfo.conf' || -f '/etc.defaults/synoinfo.conf') + { + # we have SSODS on a Synology DiskStation + $class->{osDetails}->{osName} = 'SSODS 4.x (Synology DiskStation)'; + $class->{osDetails}->{isSSODS} = 1; + } + elsif (-f '/proc/tsinfo/vendor') + { + # we have SSOTS on a QNAP TurboStation + $class->{osDetails}->{osName} = 'SSOTS 4.x (QNAP TurboStation)'; + $class->{osDetails}->{isSSOTS} = 1; + } + elsif (-f '/proc/therm-fan' || -f '/etc/gluesys/version') + { + # we have SSOEZ on a Xtreamer eTRAYz + $class->{osDetails}->{osName} = 'SSOEZ 4.x (Xtreamer eTRAYz)'; + $class->{osDetails}->{isSSOEZ} = 1; + } + else + { + # we have SSOXX, which is SSODS on some unknown, generic Linux + $class->{osDetails}->{osName} = 'SSOXX (SSODS 4.x, generic Linux)'; + } + + return $class->{osDetails}; +} + + +sub logRotate +{ + my $class = shift; + my $dir = shift || Slim::Utils::OSDetect::dirsFor('log'); + + # only keep small log files (1MB) because they are displayed + # (if at all) in a web interface + Slim::Utils::OS->logRotate($dir, MAX_LOGSIZE); +} + + +# directories on many Linux systems that won't contain any music +# FIXME: maybe this should go into Slim::Utils::OS::Linux or ::Unix +sub ignoredItemsCommon +{ + return ( + 'lost+found' => 1, + 'bin' => '/', + 'dev' => '/', + 'etc' => '/', + 'initrd' => '/', + 'lib' => '/', + 'linuxrc' => '/', + 'opt' => '/', + 'proc' => '/', + 'root' => '/', + 'sbin' => '/', + 'sys' => '/', + 'tmp' => '/', + 'usr' => '/', + 'var' => '/', + 'boot' => '/', + 'cdrom' => '/', + 'selinux' => '/', + ); +} + +# directories found on DiskStations that won't contain any music +sub ignoredItemsSSODS +{ + return ( + '@eaDir' => 1, # media indexer meta data + '@spool' => 1, # mail/print/.. spool + '@tmp' => 1, # system temporary files + '@appstore' => 1, # Synology package manager + '@database' => 1, # databases store + '@optware' => 1, # NSLU2-Linux Optware system + 'upd@te' => 1, # firmware update temporary directory + 'mnt' => '/', # not used on a DS + 'etc.defaults' => '/', # system configuration defaults/templates + 'var.defaults' => '/', # /var skeletton + ); +} + + +# directories found on TurboStations that won't contain any music +sub ignoredItemsSSOTS +{ + return ( + 'home' => '/', # home of database, webserver etc. + 'play' => '/', # no idea what it is + ); +} + +# directories found on Xtreamer eTRAYz that won't contain any music +sub ignoredItemsSSOEZ +{ + return ( ); +} + + +sub ignoredItems +{ + my $class = shift; + if ($class->{osDetails}->{isSSODS}) + { + # only data partition mount points /volume(|USB)[0-9] contain user data + return( ignoredItemsCommon(), ignoredItemsSSODS() ); + } + elsif ($class->{osDetails}->{isSSOTS}) + { + # only data partition mount points /share/* contain user data + return( ignoredItemsCommon(), ignoredItemsSSOTS() ); + } + elsif ($class->{osDetails}->{isSSOEZ}) + { + # only data partition mount points /share/* contain user data + return( ignoredItemsCommon(), ignoredItemsSSOEZ() ); + } + else # it's *some* Linux + { + # data should not be in system directories + return( ignoredItemsCommon() ); + } +} + + +sub restartServer +{ + my $class = shift; + # We'll use the 'ssctrl' script that comes with SSODS et al., which comes + # with sudo(1) that is configured to allow the user who runs Squeezbox + # Server to 'sudo ssctrl' passwordless. The ssctrl script will + # automatically take care of this. + my $log = Slim::Utils::Log::logger('server'); + $log->info("restarting SBS via SSODS"); + system('/opt/ssods4/bin/ssctrl restart &'); +} + +1; Index: Slim/Utils/OS/Linux.pm =================================================================== --- Slim/Utils/OS/Linux.pm (Revision 29710) +++ Slim/Utils/OS/Linux.pm (Arbeitskopie) @@ -27,6 +27,11 @@ return 'Netgear RAIDiator'; + # we need to check this early, because SSODS can also run on Debian etc. + } elsif ("@INC" =~ m{/opt/ssods4/lib/perl}) { + + return 'SSODS'; + } elsif (-f '/etc/squeezeos.version') { return 'SqueezeOS'; @@ -43,6 +48,7 @@ return 'SuSE'; + # SBS running on a DiskStation (but not SSODS) } elsif (-f '/etc/synoinfo.conf' || -f '/etc.defaults/synoinfo.conf') { return 'Synology DiskStation'; Index: Slim/Utils/OS/Synology.pm =================================================================== --- Slim/Utils/OS/Synology.pm (Revision 29710) +++ Slim/Utils/OS/Synology.pm (Arbeitskopie) @@ -19,11 +19,10 @@ # 3) "Optware", a package for feed for numerous add-on packages from the # NSLU2-Linux project, provides a Squeezebox Server package and its dependencies. # -# This module is trying to provide customisations for all these options. +# This module is trying to provide customisations for options 2) and 3). +# Option 1) is handled by Slim::Utils::SSODS.pm. use strict; -use File::Spec::Functions qw(:ALL); -use FindBin qw($Bin); use base qw(Slim::Utils::OS::Linux); @@ -36,25 +35,16 @@ $class->{osDetails} = $class->SUPER::initDetails(); - $class->{osDetails}->{isDiskStation} = 1; - - # check how this Squeezebox Server is run on the DiskStation - if (-f '/volume1/SSODS/etc/ssods/ssods.conf' - && "@INC" =~ m{/volume1/SSODS/lib/perl}) - { - $class->{osDetails}->{isSSODS} = 1; - $class->{osDetails}->{osName} .= ' (SSODS)'; - } - elsif (-d '/opt/share/squeezecenter' + if (-d '/opt/share/squeezecenter' && "@INC" =~ m{/opt/lib/perl}) { - $class->{osDetails}->{isOptware} = 1; + # Synology DiskStation running an NSLU2-Linux.org Optware package $class->{osDetails}->{osName} .= ' (NSLU2-Linux Optware)'; } elsif (-d '/volume1/@appstore/SqueezeCenter' && "@INC" =~ m{/usr/lib/perl}) { - $class->{osDetails}->{isSynology} = 1; + # Synology DiskStation running a DSM package $class->{osDetails}->{osName} .= ' (DSM Package Management)'; } Index: Slim/Utils/OSDetect.pm =================================================================== --- Slim/Utils/OSDetect.pm (Revision 29710) +++ Slim/Utils/OSDetect.pm (Arbeitskopie) @@ -107,8 +107,13 @@ require Slim::Utils::OS::Suse; $os = Slim::Utils::OS::Suse->new(); - } elsif ($os =~ /Synology/i) { + } elsif ($os eq 'SSODS') { + require Slim::Utils::OS::SSODS; + $os = Slim::Utils::OS::SSODS->new(); + + } elsif ($os eq 'Synology') { + require Slim::Utils::OS::Synology; $os = Slim::Utils::OS::Synology->new();