summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Rabert2017-08-05 21:19:18 -0400
committerAndrew Rabert2017-08-05 21:19:18 -0400
commite22800377d5f7da555cb51f55fd575b0068718f5 (patch)
treef57556b4998c42963ac78134ca6f6bfcb97e582a
downloadaur-e22800377d5f7da555cb51f55fd575b0068718f5.tar.gz
init
-rw-r--r--.SRCINFO31
-rw-r--r--PKGBUILD57
-rw-r--r--PluginSecurityManager.cs.patch159
-rw-r--r--emby-migrate-database56
-rw-r--r--emby-server3
-rw-r--r--emby-server.conf4
-rw-r--r--emby-server.install18
-rw-r--r--emby-server.service16
8 files changed, 344 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..54b5a7c1a9c
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,31 @@
+pkgbase = emby-server-unlocked
+ pkgdesc = Emby Server compiled with a patch to unlock Emby Premiere features
+ pkgver = 3.2.26.0
+ pkgrel = 1
+ url = http://emby.media
+ install = emby-server.install
+ arch = i686
+ arch = x86_64
+ license = GPL2
+ depends = ffmpeg
+ depends = imagemagick
+ depends = mono
+ depends = referenceassemblies-pcl
+ depends = sqlite
+ provides = emby-server
+ backup = etc/conf.d/emby-server
+ source = emby-server-3.2.26.0.tar.gz::https://github.com/MediaBrowser/Emby/archive/3.2.26.0.tar.gz
+ source = emby-server
+ source = emby-migrate-database
+ source = emby-server.conf
+ source = emby-server.service
+ source = PluginSecurityManager.cs.patch
+ sha256sums = 8d1ee6e5da6589dbdda52df13ffe9ef0a9a5025159e0efcb36334214f3c7246c
+ sha256sums = 7b1974f7bba8ac4b76e51ef7fe1257d165c7c4abbd0915e192391336048a3d74
+ sha256sums = b25bf83a0ab371aff3b13b82f7af71b51bfe6d7e51eb8a8a3dd8f0774ffce6a5
+ sha256sums = c9ad78f3e2f0ffcb4ee66bb3e99249fcd283dc9fee17895b9265dc733288b953
+ sha256sums = 8a91ea49a1699c820c4a180710072cba1d6d5c10e45df97477ff6a898f4e1d70
+ sha256sums = 9df64aaafae5d75e4dbb592d9b35c3f376c221bddf303f147407bc676423b35e
+
+pkgname = emby-server-unlocked
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..3ee496bed27
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,57 @@
+# Contributor: Andrew Rabert <draje@nullsum.net>
+
+pkgname=emby-server-unlocked
+pkgver=3.2.26.0
+pkgrel=1
+pkgdesc='Emby Server compiled with a patch to unlock Emby Premiere features'
+arch=('i686' 'x86_64')
+url='http://emby.media'
+license=('GPL2')
+depends=('ffmpeg' 'imagemagick' 'mono' 'referenceassemblies-pcl' 'sqlite')
+install='emby-server.install'
+provides=('emby-server')
+source=("emby-server-${pkgver}.tar.gz::https://github.com/MediaBrowser/Emby/archive/${pkgver}.tar.gz"
+ 'emby-server'
+ 'emby-migrate-database'
+ 'emby-server.conf'
+ 'emby-server.service'
+ 'PluginSecurityManager.cs.patch')
+backup=('etc/conf.d/emby-server')
+sha256sums=('8d1ee6e5da6589dbdda52df13ffe9ef0a9a5025159e0efcb36334214f3c7246c'
+ '7b1974f7bba8ac4b76e51ef7fe1257d165c7c4abbd0915e192391336048a3d74'
+ 'b25bf83a0ab371aff3b13b82f7af71b51bfe6d7e51eb8a8a3dd8f0774ffce6a5'
+ 'c9ad78f3e2f0ffcb4ee66bb3e99249fcd283dc9fee17895b9265dc733288b953'
+ '8a91ea49a1699c820c4a180710072cba1d6d5c10e45df97477ff6a898f4e1d70'
+ '9df64aaafae5d75e4dbb592d9b35c3f376c221bddf303f147407bc676423b35e')
+
+prepare() {
+ cd Emby-${pkgver}
+
+ sed 's/libMagickWand-6.Q8.so/libMagickWand-6.Q16HDRI.so/' -i MediaBrowser.Server.Mono/ImageMagickSharp.dll.config
+}
+
+build() {
+ cd Emby-${pkgver}
+
+ patch -N -p1 -r - Emby.Server.Implementations/Security/PluginSecurityManager.cs < ../PluginSecurityManager.cs.patch
+
+ xbuild \
+ /p:Configuration='Release Mono' \
+ /p:Platform='Any CPU' \
+ /p:OutputPath="${srcdir}/build" \
+ /t:build MediaBrowser.sln
+ mono --aot='full' -O='all' ../build/MediaBrowser.Server.Mono.exe
+}
+
+package() {
+ install -dm 755 "${pkgdir}"/{etc/conf.d,usr/{bin,lib/systemd/system}}
+ cp -dr --no-preserve='ownership' build "${pkgdir}"/usr/lib/emby-server
+ find "${pkgdir}" -type f -name *.dylib -delete
+ install -m 755 emby-server "${pkgdir}"/usr/bin/
+ install -m 755 emby-migrate-database "${pkgdir}"/usr/bin/
+ install -m 644 emby-server.service "${pkgdir}"/usr/lib/systemd/system/
+ install -m 644 emby-server.conf "${pkgdir}"/etc/conf.d/emby-server
+
+ install -dm 755 "${pkgdir}"/var/lib/emby
+ chown 422:422 -R "${pkgdir}"/var/lib/emby
+}
diff --git a/PluginSecurityManager.cs.patch b/PluginSecurityManager.cs.patch
new file mode 100644
index 00000000000..8044cd7bbe0
--- /dev/null
+++ b/PluginSecurityManager.cs.patch
@@ -0,0 +1,159 @@
+*** PluginSecurityManager.cs_ 2017-07-23 02:13:15.000000000 -0400
+--- PluginSecurityManager.cs 2017-08-05 19:55:29.509988589 -0400
+***************
+*** 117,123 ****
+ /// <returns>Task{MBRegistrationRecord}.</returns>
+ public Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null)
+ {
+! return GetRegistrationStatusInternal(feature, mb2Equivalent);
+ }
+
+ /// <summary>
+--- 117,123 ----
+ /// <returns>Task{MBRegistrationRecord}.</returns>
+ public Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null)
+ {
+! return GetRegistrationStatusInternal();
+ }
+
+ /// <summary>
+***************
+*** 129,140 ****
+ /// <returns>Task{MBRegistrationRecord}.</returns>
+ public Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent, string version)
+ {
+! return GetRegistrationStatusInternal(feature, mb2Equivalent, version);
+ }
+
+ private Task<MBRegistrationRecord> GetSupporterRegistrationStatus()
+ {
+! return GetRegistrationStatusInternal("MBSupporter", null, _appHost.ApplicationVersion.ToString());
+ }
+
+ /// <summary>
+--- 129,140 ----
+ /// <returns>Task{MBRegistrationRecord}.</returns>
+ public Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent, string version)
+ {
+! return GetRegistrationStatusInternal();
+ }
+
+ private Task<MBRegistrationRecord> GetSupporterRegistrationStatus()
+ {
+! return GetRegistrationStatusInternal();
+ }
+
+ /// <summary>
+***************
+*** 241,334 ****
+ }
+ }
+
+! private async Task<MBRegistrationRecord> GetRegistrationStatusInternal(string feature,
+! string mb2Equivalent = null,
+! string version = null)
+ {
+! var regInfo = LicenseFile.GetRegInfo(feature);
+! var lastChecked = regInfo == null ? DateTime.MinValue : regInfo.LastChecked;
+! var expDate = regInfo == null ? DateTime.MinValue : regInfo.ExpirationDate;
+!
+! var maxCacheDays = 14;
+! var nextCheckDate = new [] { expDate, lastChecked.AddDays(maxCacheDays) }.Min();
+!
+! if (nextCheckDate > DateTime.UtcNow.AddDays(maxCacheDays))
+! {
+! nextCheckDate = DateTime.MinValue;
+! }
+!
+! //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho
+! var reg = new RegRecord
+! {
+! // Cache the result for up to a week
+! registered = regInfo != null && nextCheckDate >= DateTime.UtcNow && expDate >= DateTime.UtcNow,
+! expDate = expDate
+! };
+!
+! var success = reg.registered;
+!
+! if (!(lastChecked > DateTime.UtcNow.AddDays(-1)) || !reg.registered)
+! {
+! var data = new Dictionary<string, string>
+! {
+! { "feature", feature },
+! { "key", SupporterKey },
+! { "mac", _appHost.SystemId },
+! { "systemid", _appHost.SystemId },
+! { "mb2equiv", mb2Equivalent },
+! { "ver", version },
+! { "platform", _appHost.OperatingSystemDisplayName }
+! };
+!
+! try
+! {
+! var options = new HttpRequestOptions
+! {
+! Url = MBValidateUrl,
+!
+! // Seeing block length errors
+! EnableHttpCompression = false,
+! BufferContent = false
+! };
+!
+! options.SetPostData(data);
+!
+! using (var json = (await _httpClient.Post(options).ConfigureAwait(false)).Content)
+! {
+! reg = _jsonSerializer.DeserializeFromStream<RegRecord>(json);
+! success = true;
+! }
+!
+! if (reg.registered)
+! {
+! _logger.Info("Registered for feature {0}", feature);
+! LicenseFile.AddRegCheck(feature, reg.expDate);
+! }
+! else
+! {
+! _logger.Info("Not registered for feature {0}", feature);
+! LicenseFile.RemoveRegCheck(feature);
+! }
+!
+! }
+! catch (Exception e)
+! {
+! _logger.ErrorException("Error checking registration status of {0}", e, feature);
+! }
+! }
+!
+! var record = new MBRegistrationRecord
+ {
+! IsRegistered = reg.registered,
+! ExpirationDate = reg.expDate,
+ RegChecked = true,
+! RegError = !success
+ };
+-
+- record.TrialVersion = IsInTrial(reg.expDate, record.RegChecked, record.IsRegistered);
+- record.IsValid = !record.RegChecked || record.IsRegistered || record.TrialVersion;
+-
+- return record;
+ }
+
+ private bool IsInTrial(DateTime expirationDate, bool regChecked, bool isRegistered)
+--- 241,256 ----
+ }
+ }
+
+! private async Task<MBRegistrationRecord> GetRegistrationStatusInternal()
+ {
+! return new MBRegistrationRecord
+ {
+! IsRegistered = true,
+ RegChecked = true,
+! TrialVersion = false,
+! IsValid = true,
+! RegError = false
+ };
+ }
+
+ private bool IsInTrial(DateTime expirationDate, bool regChecked, bool isRegistered)
diff --git a/emby-migrate-database b/emby-migrate-database
new file mode 100644
index 00000000000..3e102124a9c
--- /dev/null
+++ b/emby-migrate-database
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+USER='emby'
+GROUP='emby'
+
+usage() {
+ echo 'Usage: emby-migrate-database {-u user} {-g group} old_path_full new_path_full'
+ echo 'Default user: emby'
+ echo 'Default group: emby'
+}
+
+migrate() {
+ if [[ $1 && $2 ]]; then
+ if [[ -f $1/data/library.db ]]; then
+ if [[ ! -e $2 ]]; then
+ mkdir -p $2
+ fi
+ if [[ -d $2 ]]; then
+ if [[ -z $(ls $2) ]]; then
+ cp -r $1/* $2/
+ sqlite3 $2/data/library.db "UPDATE TypedBaseItems SET data = CAST(REPLACE(CAST(data AS TEXT), '$1', '$2') AS BLOB);"
+ chown $USER:$GROUP -R $2
+ echo "Migration complete. You can now delete $1."
+ else
+ echo "$2 is not empty. Aborting."
+ fi
+ else
+ echo "$2 is not a directory. Aborting."
+ fi
+ else
+ echo "$1 does not contain an emby database. Aborting."
+ fi
+ else
+ usage
+ fi
+}
+
+if [[ $1 == '--help' ]]; then
+ usage
+else
+ while getopts 'u:g:' opt; do
+ case $opt in
+ u)
+ USER=$OPTARG
+ ;;
+ g)
+ GROUP=$OPTARG
+ ;;
+ \?)
+ usage
+ ;;
+ esac
+ done
+ shift $((OPTIND-1))
+ migrate $@
+fi
diff --git a/emby-server b/emby-server
new file mode 100644
index 00000000000..31461d269dc
--- /dev/null
+++ b/emby-server
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec $MONO /usr/lib/emby-server/MediaBrowser.Server.Mono.exe -programdata $PROGRAM_DATA -ffmpeg $FFMPEG -ffprobe $FFPROBE
diff --git a/emby-server.conf b/emby-server.conf
new file mode 100644
index 00000000000..cbf376e727c
--- /dev/null
+++ b/emby-server.conf
@@ -0,0 +1,4 @@
+MONO=/usr/bin/mono
+FFMPEG=/usr/bin/ffmpeg
+FFPROBE=/usr/bin/ffprobe
+PROGRAM_DATA=/var/lib/emby
diff --git a/emby-server.install b/emby-server.install
new file mode 100644
index 00000000000..e443a6f4118
--- /dev/null
+++ b/emby-server.install
@@ -0,0 +1,18 @@
+post_install() {
+ getent group emby > /dev/null 2>&1 || groupadd -g 422 emby
+ getent passwd emby > /dev/null 2>&1 || useradd -c 'Emby Media Server' -u 422 -g emby -d /var/lib/emby -s /usr/bin/nologin emby
+ passwd -l emby > /dev/null
+
+cat <<EOF
+
+Emby is not compatible with the 10-bit versionof libx264. Please stick to the
+8-bit version if you plan on using emby's transcoding features.
+
+EOF
+}
+
+post_upgrade() {
+ post_install
+}
+
+# vim: ts=2 sw=2 et:
diff --git a/emby-server.service b/emby-server.service
new file mode 100644
index 00000000000..aaf35b161a4
--- /dev/null
+++ b/emby-server.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Emby brings together your videos, music, photos, and live television.
+
+[Service]
+EnvironmentFile=/etc/conf.d/emby-server
+WorkingDirectory=/usr/lib/emby-server
+ExecStart=/usr/bin/emby-server
+User=emby
+Group=emby
+Restart=always
+
+[Unit]
+After=network.target
+
+[Install]
+WantedBy=multi-user.target