# # $Id: Custom.pm 1439 2010-01-18 18:12:37Z flip $ # # SSODS et al. customisation routines for Squeezebox Server # # Copyright (c) 2010 Philippe Kehl # # Partly based on code found in 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 3 as published by the # Free Software Foundation. # # See the documentation for details and copying conditions. # # Installation: # cp /opt/ssods4/share/sbs/Custom.pm \ # /opt/ssods4/var/home/SqueezeboxServer/Slim/Utils/OS/ # package Slim::Utils::OS::Custom; 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; # abort if we're not running SSODS return undef if ("@INC" !~ m{/opt/ssods4/lib/perl}); # initialise $class->{osDetails} = $class->SUPER::initDetails(); # set machine details 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 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 point /home 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;