From e754e07aa905e5040ee223644d025eb69c6dee7d Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Wed, 30 Jan 2019 12:50:30 +0000 Subject: [PATCH] Add media-sound/logitechmediaserver-bin --- media-sound/logitechmediaserver-bin/Manifest | 11 + .../files/Gentoo-detailed-changelog.txt | 3 + .../files/Gentoo-plugins-README.txt | 25 ++ .../files/gentoo-filepaths.pm | 76 +++++ ...er-bin-7.9.1-client-playlists-gentoo.patch | 11 + ...echmediaserver-bin-7.9.1-uuid-gentoo.patch | 14 + .../files/logitechmediaserver.conf.d | 11 + .../files/logitechmediaserver.init.d | 50 ++++ .../files/logitechmediaserver.logrotate.d | 12 + .../files/logitechmediaserver.service | 17 ++ .../logitechmediaserver-bin-7.9.1-r1.ebuild | 263 ++++++++++++++++++ 11 files changed, 493 insertions(+) create mode 100644 media-sound/logitechmediaserver-bin/Manifest create mode 100644 media-sound/logitechmediaserver-bin/files/Gentoo-detailed-changelog.txt create mode 100644 media-sound/logitechmediaserver-bin/files/Gentoo-plugins-README.txt create mode 100644 media-sound/logitechmediaserver-bin/files/gentoo-filepaths.pm create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-client-playlists-gentoo.patch create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-uuid-gentoo.patch create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver.conf.d create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver.init.d create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver.logrotate.d create mode 100644 media-sound/logitechmediaserver-bin/files/logitechmediaserver.service create mode 100644 media-sound/logitechmediaserver-bin/logitechmediaserver-bin-7.9.1-r1.ebuild diff --git a/media-sound/logitechmediaserver-bin/Manifest b/media-sound/logitechmediaserver-bin/Manifest new file mode 100644 index 0000000..5cc617e --- /dev/null +++ b/media-sound/logitechmediaserver-bin/Manifest @@ -0,0 +1,11 @@ +AUX Gentoo-detailed-changelog.txt 62 BLAKE2B c748b93bfa5fdf69857eb38cb7f5291d81d568c4a1203b7bc5db6aa25e7aecd79670775fc1e49668fae8a399a8c79e0fa7d8a220d7f85044c8bdf14ae982a725 SHA512 57513b5b61b4bcbf6e15f5b414030172b1b50b058b9ea2d237929d0a83a25d0d57cbdf1385614fd0fc4a5e684d9ccf36cb1f2b6fcf42bd2fa0c07c56cf659738 +AUX Gentoo-plugins-README.txt 884 BLAKE2B a6c16d810d236b6d6b7b6d97f51ccbf0d51db239604fd5505666742c95bbf47d19bf28bd6184de25c1502d70e5392da9ab1ed1726a684bb8d296f2f55f298910 SHA512 3248240c97f866fa63674553622daf4e5060c20d2dbf7f5ab92cc5d9f6a2002852d7c5ccb30b7f0c6fe7fb3b136fa03770977cd3b767d9c241fa65861517ec2a +AUX gentoo-filepaths.pm 1790 BLAKE2B a9913907eda9d6ffa4451d6732d43be464706cca31297e711524e620057c6ff1e040153a80833e855ca15cec1db90e310162d9bf000707927c941e37e40ae39b SHA512 8f9236bdbb4894bb39856acda6316c230f65600190d240b4bb68aaa71e592317951047403e595eb00d02f34e7381f62f78018e80610d7864b234c9c58242131c +AUX logitechmediaserver-bin-7.9.1-client-playlists-gentoo.patch 394 BLAKE2B 96415c48c43593bb7aa98b1ea9f9d7f7d8aa645dc53099d084790613f84849ac673c324b716d7411476fa8080e59ae6b286f76445927b29032dee24c41c8851d SHA512 222c19829c00a767198e8c96187f9df113c3e38bd8066e7650d72d23ace515cddc1c00437bf22e395645a982ce50e7af7fa969a450439c0ac9e785b1edb019bb +AUX logitechmediaserver-bin-7.9.1-uuid-gentoo.patch 524 BLAKE2B 0c2d23d746c3c56694c0d3b537c30736e3d82d556a97e5349112340e6235443d4f8de3710ca34a2c6bd14a65f9f4f2e65b45079d90620157203841b5a5e5322d SHA512 99e14b1e42825d8fab22c54d7c3780498f6719eb5e91261c8d71d1c284e183d430a8799c4eb9a6bd953b64faf73e6472d587fe2fe4a74e3f0fd18eb9a9fcdffb +AUX logitechmediaserver.conf.d 477 BLAKE2B 3797f09c77cebd5a0c90db10e53da21f73b341ab33e56309e1aaf272faa1434ee1f3eba5f4a2c9df837ac385e9fa054913beaa563f88d55a7bd4565a693c6456 SHA512 686c00e7a28df15369aad74d46700d5a943bf539a57828f83e313d82014c8610c41481aff2678908f90f6bf702c0ac5408bfc7909b155c21ddc5fec21fccac28 +AUX logitechmediaserver.init.d 1127 BLAKE2B f7f1889634e622b1379f51ad090a0b63136f31923245f16224149ea1e7569f2db9880b59e2111b73dbb13a923039bd7e0b19a5bb287fcc1053bfa77c2441e462 SHA512 ae2d5580a4706703927cd6a05aa64f3e5fa2a7bd2260885591323266f1fb127e5ef30cb94f5ced2313aabc0d59f9df06178301266d71978561b86419c4d86ae4 +AUX logitechmediaserver.logrotate.d 347 BLAKE2B 218cc90d93e8739112a3379c48e5cbb830f4c21548328ef8630deff1e4ad5a3e5ccf4b12b1fb6d4a0f93a6aa8549394714e531425d29b1a6bd293c34e09990c8 SHA512 5787166d7318e494c574e965f47f6074805371283f5fd33955e02302ba43ffc64b2aa18f1c5a081d23ba49fb76cf512cfd966e5d68496fa54c05f911bab422b6 +AUX logitechmediaserver.service 506 BLAKE2B 473f08b16ca9a33c3b1d7f3a485ea2315c61e1a0c393b8a58175990f5277b50d4c5adec49addf84e51e610a624d38ddb1b178fca4c8b62350a3b6f1c6a0d1ea3 SHA512 fee5905f3c9b4ea14a983b5536ef3526943be7fb9b1e0b1c4534bb82c831eb45b6bca5a5f46e021e93ab5140b281dd7583483961f356fc1772c33cdfc00fe422 +DIST logitechmediaserver-7.9.1.tgz 188341171 BLAKE2B f2e16df3aab81a7d5aa544a3c45f74b70ee753296f6c170094e607a9962790cfad633dbdc9559fab44599fa23ae6bd9a5aee25e5bb9ddbe11807e51fb7e8fb22 SHA512 af1abe32c6507ec5701d246515aa2604a3eeb9acd48a6729a8ebbaab355943e72daf02bc1dbed1e9b829a4b32b47beced5c9227feeba57df84aaa296edc4ff21 +EBUILD logitechmediaserver-bin-7.9.1-r1.ebuild 8687 BLAKE2B 6738055ddfbb7921e6956890b2ac692554ae0af767c51859ff6aac64477342dff3aa72b58ebdf14e4722e641cab3036915f213ff036dbed35078bbddaaabce6d SHA512 d1ac7320991257535bd659a9da645718a932c6ae8b044777667a06dc319b5c86e96d53dcf4182c80440de9b878e2ab34feb5b561a043144b0efbc997d6fcfc81 diff --git a/media-sound/logitechmediaserver-bin/files/Gentoo-detailed-changelog.txt b/media-sound/logitechmediaserver-bin/files/Gentoo-detailed-changelog.txt new file mode 100644 index 0000000..b46f738 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/Gentoo-detailed-changelog.txt @@ -0,0 +1,3 @@ +---- logitechmediaserver-bin-7.8.1_preXXXXX + +Initial version. diff --git a/media-sound/logitechmediaserver-bin/files/Gentoo-plugins-README.txt b/media-sound/logitechmediaserver-bin/files/Gentoo-plugins-README.txt new file mode 100644 index 0000000..437b9b4 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/Gentoo-plugins-README.txt @@ -0,0 +1,25 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header$ + +The standard Logitech Media Server package is installed differently on Gentoo +in order that the installation complies with Gentoo's filesystem layout. These +notes are provided to give guidance for installing plugins within this +modified layout. + +MANUALLY INSTALLING PLUGINS + +The installation instructions of plugins should be followed but with the +following Gentoo specifics: + +* Plugins should be installed into the directory: + /var/lib/logitechmediaserver/Plugins +* Extension binaries (which sometimes accompany plugins) should be installed + into the directory: + /opt/logitechmediaserver/Bin + +BACKGROUND + +Those interested can refer to the following for details of Gentoo's filesystem +standard: +http://devmanual.gentoo.org/general-concepts/filesystem/index.html diff --git a/media-sound/logitechmediaserver-bin/files/gentoo-filepaths.pm b/media-sound/logitechmediaserver-bin/files/gentoo-filepaths.pm new file mode 100644 index 0000000..eb239e2 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/gentoo-filepaths.pm @@ -0,0 +1,76 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header$ + +# This file contains a custom OS package to provide information on the +# installation structure on Gentoo. + +package Slim::Utils::OS::Custom; + +use strict; + +use base qw(Slim::Utils::OS::Linux); + +sub initDetails { + my $class = shift; + + $class->{osDetails} = $class->SUPER::initDetails(); + + $class->{osDetails}->{isGentoo} = 1 ; + + # Ensure we find manually installed plugin files. + push @INC, '/var/lib/logitechmediaserver'; + push @INC, '/var/lib/logitechmediaserver/Plugins'; + + return $class->{osDetails}; +} + +=head2 dirsFor( $dir ) + +Return OS Specific directories. + +Argument $dir is a string to indicate which of the Logitech Media Server +directories we need information for. + +=cut + +sub dirsFor { + my ($class, $dir) = @_; + + my @dirs = (); + + # Overrides for specific directories. + if ($dir eq 'Plugins') { + + # Look in the normal places. + push @dirs, $class->SUPER::dirsFor($dir); + + # User-installed plugins are in a different place, so add it. + push @dirs, '/var/lib/logitechmediaserver/Plugins'; + + } elsif ($dir eq 'ClientPlaylists') { + + # LMS would normally try to put client playlists in the prefs + # directory, but they aren't really prefs since they're dynamic + # state of the clients. Effectively, they're the same as the + # database cache, so we move these under /var/lib. + push @dirs, '/var/lib/logitechmediaserver/ClientPlaylists'; + + } elsif ($dir =~ /^(?:prefs)$/) { + + # Server and plugin preferences are in a different place. + push @dirs, $::prefsdir || '/etc/logitechmediaserver'; + + } else { + + # Use the default behaviour to locate the directory. + push @dirs, $class->SUPER::dirsFor($dir); + + } + + return wantarray() ? @dirs : $dirs[0]; +} + +1; + +__END__ diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-client-playlists-gentoo.patch b/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-client-playlists-gentoo.patch new file mode 100644 index 0000000..b1e4381 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-client-playlists-gentoo.patch @@ -0,0 +1,11 @@ +--- a/Slim/Player/Playlist.pm 2015-08-16 16:39:04.469868701 +0100 ++++ b/Slim/Player/Playlist.pm 2015-08-16 16:39:04.469868701 +0100 +@@ -1042,7 +1042,7 @@ + $id =~ s/://g; + + return Slim::Utils::Misc::fileURLFromPath( +- catfile(Slim::Utils::OSDetect::dirsFor('prefs'), "clientplaylist_$id.m3u") ++ catfile(Slim::Utils::OSDetect::dirsFor('ClientPlaylists'), "clientplaylist_$id.m3u") + ); + } + diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-uuid-gentoo.patch b/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-uuid-gentoo.patch new file mode 100644 index 0000000..f4b5305 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver-bin-7.9.1-uuid-gentoo.patch @@ -0,0 +1,14 @@ +--- a/slimserver.pl 2015-08-16 16:39:04.469868701 +0100 ++++ b/slimserver.pl 2015-08-16 16:39:04.469868701 +0100 +@@ -440,8 +440,9 @@ + + # Generate a UUID for this SC instance on first-run + if ( !$prefs->get('server_uuid') ) { +- require UUID::Tiny; +- $prefs->set( server_uuid => UUID::Tiny::create_UUID_as_string( UUID::Tiny::UUID_V4() ) ); ++ require Data::UUID; ++ my $ug = new Data::UUID; ++ $prefs->set( server_uuid => lc $ug->create_str() ); + } + + main::INFOLOG && $log->info("Server binary search path init..."); diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver.conf.d b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.conf.d new file mode 100644 index 0000000..146d957 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.conf.d @@ -0,0 +1,11 @@ +# /etc/conf.d/logitechmediaserver + +# The following contains any other options you want to specify, such as default +# logging options. The example below will prevent the discovery and display of +# UPnP devices within your players. +# +# See "/opt/logitechmediaserver/slimserver.pl --help" for a full list of possible +# options, but note that many of them are supplied by +# /etc/init.d/logitechmediaserver and so don't need to be present here. +#LMS_OPTS="--d_startup" +LMS_OPTS="" diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver.init.d b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.init.d new file mode 100644 index 0000000..284df12 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.init.d @@ -0,0 +1,50 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# These fit the Logitech Media Server ebuild and so shouldn't need to be +# changed; user-servicable parts go in /etc/conf.d/logitechmediaserver. +lms=logitechmediaserver +rundir=/var/run/${lms} +logdir=/var/log/${lms} +optdir=/opt/${lms} +vardir=/var/lib/${lms} +pidfile=${rundir}/${lms}.pid +cachedir=${vardir}/cache +prefsdir=/etc/${lms} +lmsuser=${lms} +lmsbin=${optdir}/slimserver.pl + +depend() { + need net +} + +start_pre() { + checkpath -q -d -o ${lmsuser}:${lmsuser} -m 0770 "${rundir}" +} + +start() { + ebegin "Starting Logitech Media Server" + + cd / + start-stop-daemon \ + --start --exec ${lmsbin} \ + --pidfile ${pidfile} \ + --user ${lmsuser} \ + --background \ + -- \ + --quiet \ + --pidfile=${pidfile} \ + --cachedir=${cachedir} \ + --prefsdir=${prefsdir} \ + --logdir=${logdir} \ + ${LMS_OPTS} + + eend $? "Failed to start Logitech Media Server" +} + +stop() { + ebegin "Stopping Logitech Media Server" + start-stop-daemon --retry 10 --stop --pidfile ${pidfile} + eend $? "Failed to stop Logitech Media Server" +} diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver.logrotate.d b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.logrotate.d new file mode 100644 index 0000000..1ae4cc0 --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.logrotate.d @@ -0,0 +1,12 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header$ + +/var/log/logitechmediaserver/scanner.log /var/log/logitechmediaserver/server.log /var/log/logitechmediaserver/perfmon.log { + missingok + notifempty + copytruncate + rotate 5 + size 100k + su logitechmediaserver logitechmediaserver +} diff --git a/media-sound/logitechmediaserver-bin/files/logitechmediaserver.service b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.service new file mode 100644 index 0000000..4487bbb --- /dev/null +++ b/media-sound/logitechmediaserver-bin/files/logitechmediaserver.service @@ -0,0 +1,17 @@ +# unit file for media-sound/logitechmediaserver-bin +# +# Thanks to Caj Zell for the draft. + +[Unit] +Description=Logitech Media Server Daemon +After=network.target + +[Service] +User=logitechmediaserver +Group=logitechmediaserver +WorkingDirectory=/opt/logitechmediaserver +#EnvironmentFile=/etc/conf.d/logitechmediaserver +ExecStart=/opt/logitechmediaserver/slimserver.pl --prefsdir=/etc/logitechmediaserver --cachedir=/var/lib/logitechmediaserver/cache --logfile=syslog $LMS_OPTS + +[Install] +WantedBy=network.target diff --git a/media-sound/logitechmediaserver-bin/logitechmediaserver-bin-7.9.1-r1.ebuild b/media-sound/logitechmediaserver-bin/logitechmediaserver-bin-7.9.1-r1.ebuild new file mode 100644 index 0000000..0f90cdf --- /dev/null +++ b/media-sound/logitechmediaserver-bin/logitechmediaserver-bin-7.9.1-r1.ebuild @@ -0,0 +1,263 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" + +MY_PN="${PN/-bin}" + +if [[ ${PV} == *_pre* ]] ; then + GIT_COMMIT="c17601c5892eaac40a359d1392e454ad5c69db9d" + SRC_URI="https://github.com/Logitech/slimserver/archive/${GIT_COMMIT}.zip" + HOMEPAGE="http://github.com/Logitech/slimserver" + S="${WORKDIR}/slimserver-${GIT_COMMIT}" + INHERIT_VCS="" + KEYWORDS="~amd64 ~x86" +elif [[ ${PV} == "9999" ]] ; then + EGIT_BRANCH="public/7.9" + EGIT_REPO_URI="https://github.com/Logitech/slimserver.git" + HOMEPAGE="http://github.com/Logitech/slimserver" + S="${WORKDIR}/${PN}-${PV}" + INHERIT_VCS="git-r3" +else + MY_PV="${PV/_*}" + MY_P="${MY_PN}-${MY_PV}" + SRC_DIR="LogitechMediaServer_v${PV}" + SRC_URI="http://downloads.slimdevices.com/${SRC_DIR}/${MY_P}.tgz" + HOMEPAGE="http://www.mysqueezebox.com/download" + S="${WORKDIR}/${MY_P}" + INHERIT_VCS="" + KEYWORDS="~amd64 ~x86" +fi + +inherit ${INHERIT_VCS} eutils user systemd + +DESCRIPTION="Logitech Media Server (streaming audio server)" +HOMEPAGE="http://github.com/Logitech/slimserver" +LICENSE="${PN}" +RESTRICT="bindist mirror" +SLOT="0" +IUSE="" + +# Installation dependencies. +DEPEND=" + !media-sound/squeezecenter + !media-sound/squeezeboxserver + app-arch/unzip + " + +# Runtime dependencies. +RDEPEND=" + !prefix? ( >=sys-apps/baselayout-2.0.0 ) + !prefix? ( virtual/logger ) + >=dev-lang/perl-5.8.8[ithreads] + x86? ( =dev-perl/Data-UUID-1.202 + " + +# This is a binary package and contains prebuilt executable and library +# files. We need to identify those to suppress the QA warnings during +# installation. +QA_PREBUILT=" + opt/logitechmediaserver/Bin/i386-linux/* + opt/logitechmediaserver/Bin/x86_64-linux/* + opt/logitechmediaserver/CPAN/arch/5.24/* + opt/logitechmediaserver/CPAN/arch/5.26/* +" + +RUN_UID=logitechmediaserver +RUN_GID=logitechmediaserver + +# Installation locations +OPTDIR="/opt/${MY_PN}" +VARDIR="/var/lib/${MY_PN}" +CACHEDIR="${VARDIR}/cache" +USRPLUGINSDIR="${VARDIR}/Plugins" +SVRPLUGINSDIR="${CACHEDIR}/InstalledPlugins" +CLIENTPLAYLISTSDIR="${VARDIR}/ClientPlaylists" +PREFSDIR="/etc/${MY_PN}" +LOGDIR="/var/log/${MY_PN}" +SVRPREFS="${PREFSDIR}/server.prefs" + +# Old Squeezebox Server file locations +SBS_PREFSDIR='/etc/squeezeboxserver/prefs' +SBS_SVRPREFS="${SBS_PREFSDIR}/server.prefs" +SBS_VARLIBDIR='/var/lib/squeezeboxserver' +SBS_SVRPLUGINSDIR="${SBS_VARLIBDIR}/cache/InstalledPlugins" +SBS_USRPLUGINSDIR="${SBS_VARLIBDIR}/Plugins" + +PATCHES=( + "${FILESDIR}/${P}-uuid-gentoo.patch" + "${FILESDIR}/${P}-client-playlists-gentoo.patch" +) + +pkg_setup() { + # Create the user and group if not already present + enewgroup ${RUN_GID} + enewuser ${RUN_UID} -1 -1 "/dev/null" ${RUN_GID} +} + +src_prepare() { + (cd Bin && rm -rf aarch64-linux arm*-linux i86pc-solaris* sparc-linux powerpc-linux) + (cd CPAN/arch && rm -rf 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22) + rm -rf CPAN/arch/*/aarch64* CPAN/arch/*/arm* + if use amd64 ; then + rm -rf Bin/i386-linux CPAN/arch/*/i386-linux-thread-multi-64int + elif use x86 ; then + rm -rf Bin/x86_64-linux CPAN/arch/*/x86_64-linux-thread-multi + fi + default +} + +src_install() { + + # The custom OS module for Gentoo - provides OS-specific path details + cp "${FILESDIR}/gentoo-filepaths.pm" "Slim/Utils/OS/Custom.pm" || die "Unable to install Gentoo custom OS module" + + # Everthing into our package in the /opt hierarchy (LHS) + dodir "${OPTDIR}" + cp -aR "${S}"/* "${ED}${OPTDIR}" || die "Unable to install package files" + + # Documentation + dodoc Changelog*.html + dodoc Installation.txt + dodoc License*.txt + dodoc "${FILESDIR}/Gentoo-plugins-README.txt" + dodoc "${FILESDIR}/Gentoo-detailed-changelog.txt" + + # Install init scripts (OpenRC) + newconfd "${FILESDIR}/logitechmediaserver.conf.d" "${MY_PN}" + newinitd "${FILESDIR}/logitechmediaserver.init.d" "${MY_PN}" + + # Install unit file (systemd) + systemd_dounit "${FILESDIR}/${MY_PN}.service" + + diropts -m 0770 -o ${RUN_UID} -g ${RUN_GID} + keepdir "${PREFSDIR}" "${CLIENTPLAYLISTSDIR}" "${USRPLUGINSDIR}" "${CACHEDIR}" + + # Initialize the log directory + dodir "${LOGDIR}" + touch "${ED}/${LOGDIR}/server.log" + touch "${ED}/${LOGDIR}/scanner.log" + touch "${ED}/${LOGDIR}/perfmon.log" + fowners ${RUN_UID}:${RUN_GID} "${LOGDIR}/server.log" + fowners ${RUN_UID}:${RUN_GID} "${LOGDIR}/scanner.log" + fowners ${RUN_UID}:${RUN_GID} "${LOGDIR}/perfmon.log" + + # Install logrotate support + insinto /etc/logrotate.d + newins "${FILESDIR}/logitechmediaserver.logrotate.d" "${MY_PN}" +} + +lms_starting_instr() { + elog "Logitech Media Server can be started with the following command (OpenRC):" + elog "\t/etc/init.d/logitechmediaserver start" + elog "or (systemd):" + elog "\tsystemctl start logitechmediaserver" + elog "" + elog "Logitech Media Server can be automatically started on each boot" + elog "with the following command (OpenRC):" + elog "\trc-update add logitechmediaserver default" + elog "or (systemd):" + elog "\tsystemctl enable logitechmediaserver" + elog "" + elog "You might want to examine and modify the following configuration" + elog "file before starting Logitech Media Server:" + elog "\t/etc/conf.d/logitechmediaserver" + elog "" + + # Discover the port number from the preferences, but if it isn't there + # then report the standard one. + httpport=$(gawk '$1 == "httpport:" { print $2 }' "${ROOT}${SVRPREFS}" 2>/dev/null) + elog "You may access and configure Logitech Media Server by browsing to:" + elog "\thttp://localhost:${httpport:-9000}/" + elog "" +} + +pkg_postinst() { + + # Point user to database configuration step, if an old installation + # of SBS is found. + if [ -f "${SBS_SVRPREFS}" ]; then + elog "If this is a new installation of Logitech Media Server and you" + elog "previously used Squeezebox Server (media-sound/squeezeboxserver)" + elog "then you may migrate your previous preferences and plugins by" + elog "running the following command (note that this will overwrite any" + elog "current preferences and plugins):" + elog "\temerge --config =${CATEGORY}/${PF}" + elog "" + fi + + # Tell use user where they should put any manually-installed plugins. + elog "Manually installed plugins should be placed in the following" + elog "directory:" + elog "\t${USRPLUGINSDIR}" + elog "" + + # Show some instructions on starting and accessing the server. + lms_starting_instr +} + +lms_remove_db_prefs() { + MY_PREFS=$1 + + einfo "Correcting database connection configuration:" + einfo "\t${MY_PREFS}" + TMPPREFS="${T}"/lmsserver-prefs-$$ + touch "${EROOT}${MY_PREFS}" + sed -e '/^dbusername:/d' -e '/^dbpassword:/d' -e '/^dbsource:/d' < "${EROOT}${MY_PREFS}" > "${TMPPREFS}" + mv "${TMPPREFS}" "${EROOT}${MY_PREFS}" + chown ${RUN_UID}:${RUN_GID} "${EROOT}${MY_PREFS}" + chmod 660 "${EROOT}${MY_PREFS}" +} + +pkg_config() { + einfo "Press ENTER to migrate any preferences from a previous installation of" + einfo "Squeezebox Server (media-sound/squeezeboxserver) to this installation" + einfo "of Logitech Media Server." + einfo "" + einfo "Note that this will remove any current preferences and plugins and" + einfo "therefore you should take a backup if you wish to preseve any files" + einfo "from this current Logitech Media Server installation." + einfo "" + einfo "Alternatively, press Control-C to abort now..." + read + + # Preferences. + einfo "Migrating previous Squeezebox Server configuration:" + if [ -f "${SBS_SVRPREFS}" ]; then + [ -d "${EROOT}${PREFSDIR}" ] && rm -rf "${EROOT}${PREFSDIR}" + einfo "\tPreferences (${SBS_PREFSDIR})" + cp -r "${EROOT}${SBS_PREFSDIR}" "${EROOT}${PREFSDIR}" + chown -R ${RUN_UID}:${RUN_GID} "${EROOT}${PREFSDIR}" + chmod -R u+w,g+w "${EROOT}${PREFSDIR}" + chmod 770 "${EROOT}${PREFSDIR}" + fi + + # Plugins installed through the built-in extension manager. + if [ -d "${EROOT}${SBS_SVRPLUGINSDIR}" ]; then + einfo "\tServer plugins (${SBS_SVRPLUGINSDIR})" + [ -d "${EROOT}${SVRPLUGINSDIR}" ] && rm -rf "${EROOT}${SVRPLUGINSDIR}" + cp -r "${EROOT}${SBS_SVRPLUGINSDIR}" "${EROOT}${SVRPLUGINSDIR}" + chown -R ${RUN_UID}:${RUN_GID} "${EROOT}${SVRPLUGINSDIR}" + chmod -R u+w,g+w "${EROOT}${SVRPLUGINSDIR}" + chmod 770 "${EROOT}${SVRPLUGINSDIR}" + fi + + # Plugins manually installed by the user. + if [ -d "${EROOT}${SBS_USRPLUGINSDIR}" ]; then + einfo "\tUser plugins (${SBS_USRPLUGINSDIR})" + [ -d "${EROOT}${USRPLUGINSDIR}" ] && rm -rf "${EROOT}${USRPLUGINSDIR}" + cp -r "${EROOT}${SBS_USRPLUGINSDIR}" "${EROOT}${USRPLUGINSDIR}" + chown -R ${RUN_UID}:${RUN_GID} "${EROOT}${USRPLUGINSDIR}" + chmod -R u+w,g+w "${EROOT}${USRPLUGINSDIR}" + chmod 770 "${EROOT}${USRPLUGINSDIR}" + fi + + # Remove the existing MySQL preferences from Squeezebox Server (if any). + lms_remove_db_prefs "${SVRPREFS}" + + # Phew - all done. Give some tips on what to do now. + einfo "Done." + einfo "" +}