aboutsummaryrefslogtreecommitdiff
path: root/deployment
diff options
context:
space:
mode:
Diffstat (limited to 'deployment')
l---------deployment/centos-package-x64/pkg-src2
-rwxr-xr-xdeployment/debian-package-arm64/docker-build.sh2
-rwxr-xr-xdeployment/debian-package-armhf/docker-build.sh2
l---------deployment/debian-package-armhf/pkg-src2
-rwxr-xr-xdeployment/debian-package-x64/docker-build.sh2
-rwxr-xr-x[-rw-r--r--]deployment/debian-package-x64/pkg-src/bin/restart.sh48
-rw-r--r--deployment/debian-package-x64/pkg-src/changelog24
-rw-r--r--deployment/debian-package-x64/pkg-src/rules4
-rw-r--r--deployment/fedora-package-x64/pkg-src/jellyfin.spec10
-rwxr-xr-x[-rw-r--r--]deployment/fedora-package-x64/pkg-src/restart.sh40
-rwxr-xr-xdeployment/ubuntu-package-arm64/docker-build.sh2
-rwxr-xr-xdeployment/ubuntu-package-armhf/docker-build.sh2
-rwxr-xr-xdeployment/ubuntu-package-x64/docker-build.sh2
l---------deployment/ubuntu-package-x64/pkg-src2
-rw-r--r--deployment/windows/build-jellyfin.ps124
-rw-r--r--deployment/windows/install-jellyfin.ps12
-rw-r--r--deployment/windows/jellyfin.nsi386
17 files changed, 524 insertions, 32 deletions
diff --git a/deployment/centos-package-x64/pkg-src b/deployment/centos-package-x64/pkg-src
index dfd6497cf..3ff4d3cbf 120000
--- a/deployment/centos-package-x64/pkg-src
+++ b/deployment/centos-package-x64/pkg-src
@@ -1 +1 @@
-../fedora-package-x64/pkg-src \ No newline at end of file
+../fedora-package-x64/pkg-src/ \ No newline at end of file
diff --git a/deployment/debian-package-arm64/docker-build.sh b/deployment/debian-package-arm64/docker-build.sh
index cee96e136..1c75ece8e 100755
--- a/deployment/debian-package-arm64/docker-build.sh
+++ b/deployment/debian-package-arm64/docker-build.sh
@@ -17,5 +17,5 @@ dpkg-buildpackage -us -uc -aarm64
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/debian-package-armhf/docker-build.sh b/deployment/debian-package-armhf/docker-build.sh
index 56227b588..df35345bd 100755
--- a/deployment/debian-package-armhf/docker-build.sh
+++ b/deployment/debian-package-armhf/docker-build.sh
@@ -17,5 +17,5 @@ dpkg-buildpackage -us -uc -aarmhf
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/debian-package-armhf/pkg-src b/deployment/debian-package-armhf/pkg-src
index 4c695fea1..0bb6d5524 120000
--- a/deployment/debian-package-armhf/pkg-src
+++ b/deployment/debian-package-armhf/pkg-src
@@ -1 +1 @@
-../debian-package-x64/pkg-src \ No newline at end of file
+../debian-package-x64/pkg-src/ \ No newline at end of file
diff --git a/deployment/debian-package-x64/docker-build.sh b/deployment/debian-package-x64/docker-build.sh
index 07f726dcc..9781879f6 100755
--- a/deployment/debian-package-x64/docker-build.sh
+++ b/deployment/debian-package-x64/docker-build.sh
@@ -16,5 +16,5 @@ dpkg-buildpackage -us -uc
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/debian-package-x64/pkg-src/bin/restart.sh b/deployment/debian-package-x64/pkg-src/bin/restart.sh
index 738f86727..9b64b6d72 100644..100755
--- a/deployment/debian-package-x64/pkg-src/bin/restart.sh
+++ b/deployment/debian-package-x64/pkg-src/bin/restart.sh
@@ -1,20 +1,36 @@
#!/bin/bash
-NAME=jellyfin
+# restart.sh - Jellyfin server restart script
+# Part of the Jellyfin project (https://github.com/jellyfin)
+#
+# This script restarts the Jellyfin daemon on Linux when using
+# the Restart button on the admin dashboard. It supports the
+# systemctl, service, and traditional /etc/init.d (sysv) restart
+# methods, chosen automatically by which one is found first (in
+# that order).
+#
+# This script is used by the Debian/Ubuntu/Fedora/CentOS packages.
-restart_cmds=(
- "systemctl restart ${NAME}"
- "service ${NAME} restart"
- "/etc/init.d/${NAME} restart"
- "s6-svc -t /var/run/s6/services/${NAME}"
-)
+get_service_command() {
+ for command in systemctl service; do
+ if which $command &>/dev/null; then
+ echo $command && return
+ fi
+ done
+ echo "sysv"
+}
-for restart_cmd in "${restart_cmds[@]}"; do
- cmd=$(echo "$restart_cmd" | awk '{print $1}')
- cmd_loc=$(command -v ${cmd})
- if [[ -n "$cmd_loc" ]]; then
- restart_cmd=$(echo "$restart_cmd" | sed -e "s%${cmd}%${cmd_loc}%")
- echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1
- exit 0
- fi
-done
+cmd="$( get_service_command )"
+echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
+case $cmd in
+ 'systemctl')
+ echo "sleep 2; /usr/bin/sudo $( which systemctl ) restart jellyfin" | at now
+ ;;
+ 'service')
+ echo "sleep 2; /usr/bin/sudo $( which service ) jellyfin restart" | at now
+ ;;
+ 'sysv')
+ echo "sleep 2; /usr/bin/sudo /etc/init.d/jellyfin restart" | at now
+ ;;
+esac
+exit 0
diff --git a/deployment/debian-package-x64/pkg-src/changelog b/deployment/debian-package-x64/pkg-src/changelog
index a47f7e841..aa15827a7 100644
--- a/deployment/debian-package-x64/pkg-src/changelog
+++ b/deployment/debian-package-x64/pkg-src/changelog
@@ -1,3 +1,27 @@
+jellyfin (10.3.7-1) unstable; urgency=medium
+
+ * New upstream version 10.3.7; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.7
+
+ -- Jellyfin Packaging Team <packaging@jellyfin.org> Wed, 24 Jul 2019 10:48:28 -0400
+
+jellyfin (10.3.6-1) unstable; urgency=medium
+
+ * New upstream version 10.3.6; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.6
+
+ -- Jellyfin Packaging Team <packaging@jellyfin.org> Sat, 06 Jul 2019 13:34:19 -0400
+
+jellyfin (10.3.5-1) unstable; urgency=medium
+
+ * New upstream version 10.3.5; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.5
+
+ -- Jellyfin Packaging Team <packaging@jellyfin.org> Sun, 09 Jun 2019 21:47:35 -0400
+
+jellyfin (10.3.4-1) unstable; urgency=medium
+
+ * New upstream version 10.3.4; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.4
+
+ -- Jellyfin Packaging Team <packaging@jellyfin.org> Thu, 06 Jun 2019 22:45:31 -0400
+
jellyfin (10.3.3-1) unstable; urgency=medium
* New upstream version 10.3.3; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.3
diff --git a/deployment/debian-package-x64/pkg-src/rules b/deployment/debian-package-x64/pkg-src/rules
index ee41e0e24..2a5d41a69 100644
--- a/deployment/debian-package-x64/pkg-src/rules
+++ b/deployment/debian-package-x64/pkg-src/rules
@@ -45,3 +45,7 @@ override_dh_auto_build:
override_dh_auto_clean:
dotnet clean -maxcpucount:1 --configuration $(CONFIG) Jellyfin.Server || true
rm -rf '$(CURDIR)/usr'
+
+# Force the service name to jellyfin even if we're building jellyfin-nightly
+override_dh_installinit:
+ dh_installinit --name=jellyfin
diff --git a/deployment/fedora-package-x64/pkg-src/jellyfin.spec b/deployment/fedora-package-x64/pkg-src/jellyfin.spec
index e2e814b96..91b74ffe1 100644
--- a/deployment/fedora-package-x64/pkg-src/jellyfin.spec
+++ b/deployment/fedora-package-x64/pkg-src/jellyfin.spec
@@ -7,7 +7,7 @@
%endif
Name: jellyfin
-Version: 10.3.3
+Version: 10.3.7
Release: 1%{?dist}
Summary: The Free Software Media Browser
License: GPLv2
@@ -140,6 +140,14 @@ fi
%systemd_postun_with_restart jellyfin.service
%changelog
+* Wed Jul 24 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
+- New upstream version 10.3.7; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.7
+* Sat Jul 06 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
+- New upstream version 10.3.6; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.6
+* Sun Jun 09 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
+- New upstream version 10.3.5; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.5
+* Thu Jun 06 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
+- New upstream version 10.3.4; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.4
* Fri May 17 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
- New upstream version 10.3.3; release changelog at https://github.com/jellyfin/jellyfin/releases/tag/v10.3.3
* Tue Apr 30 2019 Jellyfin Packaging Team <packaging@jellyfin.org>
diff --git a/deployment/fedora-package-x64/pkg-src/restart.sh b/deployment/fedora-package-x64/pkg-src/restart.sh
index e84dca587..9b64b6d72 100644..100755
--- a/deployment/fedora-package-x64/pkg-src/restart.sh
+++ b/deployment/fedora-package-x64/pkg-src/restart.sh
@@ -1,6 +1,36 @@
-#!/bin/sh
+#!/bin/bash
-NAME=jellyfin
-restart_cmd="/usr/bin/systemctl restart ${NAME}"
-echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1
-exit 0 \ No newline at end of file
+# restart.sh - Jellyfin server restart script
+# Part of the Jellyfin project (https://github.com/jellyfin)
+#
+# This script restarts the Jellyfin daemon on Linux when using
+# the Restart button on the admin dashboard. It supports the
+# systemctl, service, and traditional /etc/init.d (sysv) restart
+# methods, chosen automatically by which one is found first (in
+# that order).
+#
+# This script is used by the Debian/Ubuntu/Fedora/CentOS packages.
+
+get_service_command() {
+ for command in systemctl service; do
+ if which $command &>/dev/null; then
+ echo $command && return
+ fi
+ done
+ echo "sysv"
+}
+
+cmd="$( get_service_command )"
+echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
+case $cmd in
+ 'systemctl')
+ echo "sleep 2; /usr/bin/sudo $( which systemctl ) restart jellyfin" | at now
+ ;;
+ 'service')
+ echo "sleep 2; /usr/bin/sudo $( which service ) jellyfin restart" | at now
+ ;;
+ 'sysv')
+ echo "sleep 2; /usr/bin/sudo /etc/init.d/jellyfin restart" | at now
+ ;;
+esac
+exit 0
diff --git a/deployment/ubuntu-package-arm64/docker-build.sh b/deployment/ubuntu-package-arm64/docker-build.sh
index cee96e136..1c75ece8e 100755
--- a/deployment/ubuntu-package-arm64/docker-build.sh
+++ b/deployment/ubuntu-package-arm64/docker-build.sh
@@ -17,5 +17,5 @@ dpkg-buildpackage -us -uc -aarm64
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/ubuntu-package-armhf/docker-build.sh b/deployment/ubuntu-package-armhf/docker-build.sh
index 56227b588..df35345bd 100755
--- a/deployment/ubuntu-package-armhf/docker-build.sh
+++ b/deployment/ubuntu-package-armhf/docker-build.sh
@@ -17,5 +17,5 @@ dpkg-buildpackage -us -uc -aarmhf
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/ubuntu-package-x64/docker-build.sh b/deployment/ubuntu-package-x64/docker-build.sh
index 07f726dcc..9781879f6 100755
--- a/deployment/ubuntu-package-x64/docker-build.sh
+++ b/deployment/ubuntu-package-x64/docker-build.sh
@@ -16,5 +16,5 @@ dpkg-buildpackage -us -uc
# Move the artifacts out
mkdir -p ${ARTIFACT_DIR}/deb
-mv /jellyfin_* ${ARTIFACT_DIR}/deb/
+mv /jellyfin[-_]* ${ARTIFACT_DIR}/deb/
chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR}
diff --git a/deployment/ubuntu-package-x64/pkg-src b/deployment/ubuntu-package-x64/pkg-src
index 4c695fea1..0bb6d5524 120000
--- a/deployment/ubuntu-package-x64/pkg-src
+++ b/deployment/ubuntu-package-x64/pkg-src
@@ -1 +1 @@
-../debian-package-x64/pkg-src \ No newline at end of file
+../debian-package-x64/pkg-src/ \ No newline at end of file
diff --git a/deployment/windows/build-jellyfin.ps1 b/deployment/windows/build-jellyfin.ps1
index 2999912b3..aaa4bcf6c 100644
--- a/deployment/windows/build-jellyfin.ps1
+++ b/deployment/windows/build-jellyfin.ps1
@@ -1,5 +1,6 @@
[CmdletBinding()]
param(
+ [switch]$MakeNSIS,
[switch]$InstallFFMPEG,
[switch]$InstallNSSM,
[switch]$GenerateZip,
@@ -96,6 +97,24 @@ function Install-NSSM {
Remove-Item "$tempdir/nssm.zip" -Force -ErrorAction Continue | Write-Verbose
}
+function Make-NSIS {
+ param(
+ [string]$InstallLocation
+ )
+ Write-Verbose "Downloading NSIS"
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+ Invoke-WebRequest -Uri https://nchc.dl.sourceforge.net/project/nsis/NSIS%203/3.04/nsis-3.04.zip -UseBasicParsing -OutFile "$tempdir/nsis.zip" | Write-Verbose
+
+ Expand-Archive "$tempdir/nsis.zip" -DestinationPath "$tempdir/nsis/" -Force | Write-Verbose
+ $env:InstallLocation = $InstallLocation
+ & "$tempdir/nsis/nsis-3.04/makensis.exe" ".\deployment\windows\jellyfin.nsi"
+ Copy-Item .\deployment\windows\jellyfin_*.exe $InstallLocation\..\
+
+ Remove-Item "$tempdir/nsis/" -Recurse -Force -ErrorAction Continue | Write-Verbose
+ Remove-Item "$tempdir/nsis.zip" -Force -ErrorAction Continue | Write-Verbose
+}
+
+
Write-Verbose "Starting Build Process: Selected Environment is $WindowsVersion-$Architecture"
Build-JellyFin
if($InstallFFMPEG.IsPresent -or ($InstallFFMPEG -eq $true)){
@@ -108,6 +127,11 @@ if($InstallNSSM.IsPresent -or ($InstallNSSM -eq $true)){
}
Copy-Item .\deployment\windows\install-jellyfin.ps1 $InstallLocation\install-jellyfin.ps1
Copy-Item .\deployment\windows\install.bat $InstallLocation\install.bat
+Copy-Item .\LICENSE $InstallLocation\LICENSE
+if($MakeNSIS.IsPresent -or ($MakeNSIS -eq $true)){
+ Write-Verbose "Starting NSIS Package creation"
+ Make-NSIS $InstallLocation
+}
if($GenerateZip.IsPresent -or ($GenerateZip -eq $true)){
Compress-Archive -Path $InstallLocation -DestinationPath "$InstallLocation/jellyfin.zip" -Force
}
diff --git a/deployment/windows/install-jellyfin.ps1 b/deployment/windows/install-jellyfin.ps1
index 0cd7f5236..e909a0468 100644
--- a/deployment/windows/install-jellyfin.ps1
+++ b/deployment/windows/install-jellyfin.ps1
@@ -3,7 +3,7 @@
param(
[Switch]$Quiet,
[Switch]$InstallAsService,
- [pscredential]$ServiceUser,
+ [System.Management.Automation.pscredential]$ServiceUser,
[switch]$CreateDesktopShorcut,
[switch]$LaunchJellyfin,
[switch]$MigrateEmbyLibrary,
diff --git a/deployment/windows/jellyfin.nsi b/deployment/windows/jellyfin.nsi
new file mode 100644
index 000000000..a374ebe45
--- /dev/null
+++ b/deployment/windows/jellyfin.nsi
@@ -0,0 +1,386 @@
+; Shows a lot of debug information while compiling
+; This can be removed once stable.
+!verbose 4
+;--------------------------------
+!define SF_USELECTED 0 ; used to check selected options status, rest are inherited from Sections.nsh
+
+ !include "MUI2.nsh"
+ !include "Sections.nsh"
+ !include "LogicLib.nsh"
+
+; Global variables that we'll use
+ Var _JELLYFINVERSION_
+ Var _JELLYFINDATADIR_
+ Var _INSTALLSERVICE_
+ Var _SERVICESTART_
+ Var _LOCALSYSTEMACCOUNT_
+ Var _EXISTINGINSTALLATION_
+ Var _EXISTINGSERVICE_
+ Var _CUSTOMDATAFOLDER_
+
+!if ${NSIS_PTR_SIZE} > 4
+ !define BITS 64
+ !define NAMESUFFIX " (64 bit)"
+!else
+ !define BITS 32
+ !define NAMESUFFIX ""
+!endif
+
+;--------------------------------
+
+ !define REG_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jellyfin" ;Registry to show up in Add/Remove Programs
+
+ !getdllversion "$%InstallLocation%\jellyfin.dll" ver_ ;Align installer version with jellyfin.dll version
+ Name "Jellyfin Server ${ver_1}.${ver_2}.${ver_3}" ; This is referred in various header text labels
+ OutFile "jellyfin_${ver_1}.${ver_2}.${ver_3}_windows.exe" ; Naming convention jellyfin_{version}_windows-{arch].exe
+ BrandingText "Jellyfin Server ${ver_1}.${ver_2}.${ver_3} Installer" ; This shows in just over the buttons
+
+; installer attributes, these show up in details tab on installer properties
+ VIProductVersion "${ver_1}.${ver_2}.${ver_3}.0" ; VIProductVersion format, should be X.X.X.X
+ VIFileVersion "${ver_1}.${ver_2}.${ver_3}.0" ; VIFileVersion format, should be X.X.X.X
+ VIAddVersionKey "ProductName" "Jellyfin Server"
+ VIAddVersionKey "FileVersion" "${ver_1}.${ver_2}.${ver_3}.0"
+ VIAddVersionKey "LegalCopyright" "Jellyfin, Free Software Media System"
+ VIAddVersionKey "FileDescription" "Jellyfin Server"
+
+;TODO, check defaults
+ InstallDir "$PROGRAMFILES\Jellyfin" ;Default installation folder
+ InstallDirRegKey HKLM "Software\Jellyfin" "InstallFolder" ;Read the registry for install folder,
+
+ RequestExecutionLevel admin ; ask it upfront for service control, and installing in priv folders
+
+ CRCCheck on ; make sure the installer wasn't corrupted while downloading
+
+ !define MUI_ABORTWARNING ;Prompts user in case of aborting install
+
+; TODO: Replace with nice Jellyfin Icons
+ !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\nsis3-install.ico" ; Installer Icon
+ !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\nsis3-uninstall.ico" ; Uninstaller Icon
+
+ !define MUI_HEADERIMAGE
+ !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis3-branding.bmp"
+ !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis3-branding.bmp"
+
+;--------------------------------
+;Pages
+
+; Welcome Page
+ !define MUI_WELCOMEPAGE_TEXT "The installer will ask for details to install Jellyfin Server.$\r$\n$\r$\n$\r$\n\
+ ADVANCED:$\r$\n\
+ The default service install uses Network Service account and is sufficient for most users. $\r$\n$\r$\n\
+ You can choose to install using Local System account under Advanced options. This also affects where Jellyfin Server and Jellyfin data can be installed. The installer will NOT check this, you should know what you are doing.$\r$\n$\r$\n\
+ You can choose the folder for Jellyfin Metadata under advanced options based on your needs."
+ !insertmacro MUI_PAGE_WELCOME
+; License Page
+ !insertmacro MUI_PAGE_LICENSE "$%InstallLocation%\LICENSE" ; picking up generic GPL
+; Components Page
+ !define MUI_COMPONENTSPAGE_SMALLDESC
+ !insertmacro MUI_PAGE_COMPONENTS
+ !define MUI_PAGE_CUSTOMFUNCTION_PRE HideInstallDirectoryPage ; Controls when to hide / show
+ !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Install folder" ; shows just above the folder selection dialog
+ !insertmacro MUI_PAGE_DIRECTORY
+
+; Metadata folder Page
+ !define MUI_PAGE_CUSTOMFUNCTION_PRE HideDataDirectoryPage ; Controls when to hide / show
+ !define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the Jellyfin Server metadata."
+ !define MUI_DIRECTORYPAGE_TEXT_TOP "The installer will set the following folder for Jellyfin Server metadata. To install in a differenct folder, click Browse and select another folder. Please make sure the folder exists. Click Next to continue."
+ !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Metadata folder"
+ !define MUI_DIRECTORYPAGE_VARIABLE $_JELLYFINDATADIR_
+ !insertmacro MUI_PAGE_DIRECTORY
+
+; Confirmation Page
+ Page custom ConfirmationPage ; just letting the user know what they chose to install
+
+; Actual Installion Page
+ !insertmacro MUI_PAGE_INSTFILES
+
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+ !insertmacro MUI_UNPAGE_FINISH
+
+;--------------------------------
+;Languages; Add more languages later here if needed
+ !insertmacro MUI_LANGUAGE "English"
+
+;--------------------------------
+;Installer Sections
+Section "Jellyfin Server (required)" InstallJellyfin
+ SectionIn RO ; Mandatory section, isn't this the whole purpose to run the installer.
+
+ StrCmp "$_EXISTINGINSTALLATION_" "YES" RunUninstaller CarryOn ; Silently uninstall in case of previous installation
+
+ RunUninstaller:
+ DetailPrint "Looking for uninstaller at $INSTDIR"
+ FindFirst $0 $1 "$INSTDIR\Uninstall.exe"
+ FindClose $0
+ StrCmp $1 "" CarryOn ; the registry key was there but uninstaller was not found
+
+ DetailPrint "Silently running the uninstaller at $INSTDIR"
+ ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR' $0
+ DetailPrint "Uninstall finished, $0"
+
+ CarryOn:
+
+ SetOutPath "$INSTDIR"
+
+ File /r $%InstallLocation%\*
+
+; Write the InstallFolder, DataFolder, Network Service info into the registry for later use
+ WriteRegExpandStr HKLM "Software\Jellyfin" "InstallFolder" "$INSTDIR"
+ WriteRegExpandStr HKLM "Software\Jellyfin" "DataFolder" "$_JELLYFINDATADIR_"
+ WriteRegStr HKLM "Software\Jellyfin" "LocalSystemAccount" "$_LOCALSYSTEMACCOUNT_"
+
+ !getdllversion "$%InstallLocation%\jellyfin.dll" ver_
+ StrCpy $_JELLYFINVERSION_ "${ver_1}.${ver_2}.${ver_3}" ;
+
+; Write the uninstall keys for Windows
+ WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayName" "Jellyfin $_JELLYFINVERSION_"
+ WriteRegExpandStr HKLM "${REG_UNINST_KEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
+ WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayIcon" '"$INSTDIR\Jellyfin.exe",0'
+ WriteRegStr HKLM "${REG_UNINST_KEY}" "Publisher" "The Jellyfin project"
+ WriteRegStr HKLM "${REG_UNINST_KEY}" "URLInfoAbout" "https://jellyfin.github.io/"
+ WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayVersion" "$_JELLYFINVERSION_"
+ WriteRegDWORD HKLM "${REG_UNINST_KEY}" "NoModify" 1
+ WriteRegDWORD HKLM "${REG_UNINST_KEY}" "NoRepair" 1
+
+;Create uninstaller
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+SectionEnd
+
+Section "Jellyfin Service" InstallService
+
+ ExecWait '"$INSTDIR\nssm.exe" install Jellyfin "$INSTDIR\jellyfin.exe" --datadir "$_JELLYFINDATADIR_"' $0
+ DetailPrint "Jellyfin Service install, $0"
+
+ Sleep 3000 ; Give time for Windows to catchup
+
+ ExecWait '"$INSTDIR\nssm.exe" set Jellyfin Start SERVICE_DELAYED_AUTO_START' $0
+ DetailPrint "Jellyfin Service setting, $0"
+
+ Sleep 3000
+ ${If} $_LOCALSYSTEMACCOUNT_ == "NO" ; the default install using NSSM is Local System
+ DetailPrint "Attempting to change service account to Network Service"
+ ExecWait '"$INSTDIR\nssm.exe" set Jellyfin Objectname "Network Service"' $0
+ DetailPrint "Jellyfin service account change, $0"
+ ${EndIf}
+
+SectionEnd
+
+Section "Start Jellyfin service after install" StartService
+
+ ExecWait '"$INSTDIR\nssm.exe" start Jellyfin' $0
+ DetailPrint "Jellyfin service start, $0"
+
+SectionEnd
+
+SectionGroup "Advanced" Advanced
+Section /o "Use Local System account" LocalSystemAccount
+ ; The section is for user choice, nothing to do here
+SectionEnd
+Section /o "Custom Jellyfin metadata folder" CustomDataFolder
+ ; The section is for user choice, nothing to do here
+SectionEnd
+SectionGroupEnd
+
+
+;--------------------------------
+;Descriptions
+
+;Language strings
+ LangString DESC_InstallJellyfin ${LANG_ENGLISH} "Install Jellyfin Server"
+ LangString DESC_InstallService ${LANG_ENGLISH} "Install As a Service"
+ LangString DESC_StartService ${LANG_ENGLISH} "Start Jellyfin service after Install"
+ LangString DESC_LocalSystemAccount ${LANG_ENGLISH} "Use Local System account to start windows service"
+ LangString DESC_CustomDataFolder ${LANG_ENGLISH} "Choose Jellyfin Server metadata folder in subsequent steps"
+
+;Assign language strings to sections
+ !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+ !insertmacro MUI_DESCRIPTION_TEXT ${InstallJellyfin} $(DESC_InstallJellyfin)
+ !insertmacro MUI_DESCRIPTION_TEXT ${InstallService} $(DESC_InstallService)
+ !insertmacro MUI_DESCRIPTION_TEXT ${StartService} $(DESC_StartService)
+ !insertmacro MUI_DESCRIPTION_TEXT ${LocalSystemAccount} $(DESC_LocalSystemAccount)
+ !insertmacro MUI_DESCRIPTION_TEXT ${CustomDataFolder} $(DESC_CustomDataFolder)
+ !insertmacro MUI_FUNCTION_DESCRIPTION_END
+
+;--------------------------------
+;Uninstaller Section
+
+Section "Uninstall"
+
+ ReadRegStr $INSTDIR HKLM "Software\Jellyfin" "InstallFolder" ; read the installation folder
+ ReadRegStr $_JELLYFINDATADIR_ HKLM "Software\Jellyfin" "DataFolder" ; read the metadata folder
+
+ DetailPrint "Jellyfin Install location : $INSTDIR"
+ DetailPrint "Jellyfin data folder : $_JELLYFINDATADIR_"
+
+ MessageBox MB_YESNO|MB_ICONINFORMATION "Do you want to retain Jellyfin metadata folder? The media will not be touched. $\r$\nIf unsure choose YES." /SD IDYES IDYES PreserveData
+
+ RMDir /r /REBOOTOK "$_JELLYFINDATADIR_"
+
+ PreserveData:
+
+ DetailPrint "Attempting to stop Jellyfin Server"
+ ExecWait '"$INSTDIR\nssm.exe" stop Jellyfin' $0
+ DetailPrint "Jellyfin service stop, $0"
+ DetailPrint "Attempting to remove Jellyfin service"
+ ExecWait '"$INSTDIR\nssm.exe" remove Jellyfin confirm' $0
+ DetailPrint "Jellyfin Service remove, $0"
+
+ Delete "$INSTDIR\Uninstall.exe"
+
+ RMDir /r /REBOOTOK "$INSTDIR"
+
+ DeleteRegKey HKLM "Software\Jellyfin"
+ DeleteRegKey HKLM "${REG_UNINST_KEY}"
+
+SectionEnd
+
+
+
+Function .onInit
+; Setting up defaults
+ StrCpy $_INSTALLSERVICE_ "YES"
+ StrCpy $_SERVICESTART_ "YES"
+ StrCpy $_CUSTOMDATAFOLDER_ "NO"
+ StrCpy $_LOCALSYSTEMACCOUNT_ "NO"
+ StrCpy $_EXISTINGINSTALLATION_ "NO"
+ StrCpy $_EXISTINGSERVICE_ "NO"
+
+ SetShellVarContext current
+ StrCpy $_JELLYFINDATADIR_ "$%ProgramData%\jellyfin\"
+
+;Detect if Jellyfin is already installed.
+; In case it is installed, let the user choose either
+; 1. Exit installer
+; 2. Upgrade without messing with data
+; 2a. Don't ask for any details, uninstall and install afresh with old settings
+
+; Read Registry for previous installation
+ ClearErrors
+ ReadRegStr "$0" HKLM "Software\Jellyfin" "InstallFolder"
+ IfErrors NoExisitingInstall
+
+ DetailPrint "Existing Jellyfin detected at: $0"
+ StrCpy "$INSTDIR" "$0" ; set the location fro registry as new default
+
+ StrCpy $_EXISTINGINSTALLATION_ "YES" ; Set our flag to be used later
+ SectionSetText ${InstallJellyfin} "Upgrade Jellyfin Server(required)" ; Change install text to "Upgrade"
+
+; check if there is a service called Jellyfin, there should be
+; hack : nssm statuscode Jellyfin will return non zero return code in case it exists
+ ExecWait '"$INSTDIR\nssm.exe" statuscode Jellyfin' $0
+ DetailPrint "Jellyfin service statuscode, $0"
+ IntCmp $0 0 NoService ; service doesn't exist, may be run from desktop shortcut
+
+ ; if service was detected, set defaults going forward.
+ StrCpy $_EXISTINGSERVICE_ "YES"
+ StrCpy $_INSTALLSERVICE_ "YES"
+ StrCpy $_SERVICESTART_ "YES"
+
+ ; check if service was run using Network Service account
+ ClearErrors
+ ReadRegStr "$_LOCALSYSTEMACCOUNT_" HKLM "Software\Jellyfin" "LocalSystemAccount" ; in case of error _LOCALSYSTEMACCOUNT_ will be NO as default
+
+ ClearErrors
+ ReadRegStr $_JELLYFINDATADIR_ HKLM "Software\Jellyfin" "DataFolder" ; in case of error, the default holds
+
+ ; Hide sections which will not be needed in case of previous install
+ SectionSetText ${InstallService} ""
+ SectionSetText ${StartService} ""
+ SectionSetText ${LocalSystemAccount} ""
+ SectionSetText ${CustomDataFolder} ""
+ SectionSetText ${Advanced} ""
+
+
+ NoService: ; existing install was present but no service was detected
+
+; Let the user know that we'll upgrade and provide an option to quit.
+ MessageBox MB_OKCANCEL|MB_ICONINFORMATION "Existing installation of Jellyfin was detected, it'll be upgraded, settings will be retained. \
+ $\r$\nClick OK to proceed, Cancel to exit installer." /SD IDOK IDOK ProceedWithUpgrade
+ Quit ; Quit if the user is not sure about upgrade
+
+ ProceedWithUpgrade:
+
+ NoExisitingInstall:
+; by this time, the variables have been correctly set to reflect previous install details
+
+FunctionEnd
+
+Function HideInstallDirectoryPage
+ ${If} $_EXISTINGINSTALLATION_ == "YES" ; Existing installation detected, so don't ask for InstallFolder
+ Abort
+ ${EndIf}
+FunctionEnd
+
+; Don't show custom folder option in case it wasn't chosen
+Function HideDataDirectoryPage
+ ${If} $_CUSTOMDATAFOLDER_ == "NO"
+ Abort
+ ${EndIf}
+FunctionEnd
+
+; This function handles the choices during component selection
+Function .onSelChange
+ SectionGetFlags ${CustomDataFolder} $0
+ ${If} $0 = ${SF_SELECTED}
+ StrCpy $_CUSTOMDATAFOLDER_ "YES"
+ ${Else}
+ StrCpy $_CUSTOMDATAFOLDER_ "NO"
+ ${EndIf}
+
+; If we are not installing service, we don't need to set the NetworkService account or StartService
+ SectionGetFlags ${InstallService} $0
+ ${If} $0 = ${SF_SELECTED}
+ StrCpy $_INSTALLSERVICE_ "YES"
+ SectionGetFlags ${LocalSystemAccount} $0
+ IntOp $0 $0 | ${SF_RO}
+ IntOp $0 $0 ^ ${SF_RO}
+ SectionSetFlags ${LocalSystemAccount} $0
+ SectionGetFlags ${StartService} $0
+ IntOp $0 $0 | ${SF_RO}
+ IntOp $0 $0 ^ ${SF_RO}
+ SectionSetFlags ${StartService} $0
+ ${Else}
+ StrCpy $_INSTALLSERVICE_ "NO"
+ IntOp $0 ${SF_USELECTED} | ${SF_RO}
+ SectionSetFlags ${LocalSystemAccount} $0
+ SectionSetFlags ${StartService} $0
+ ${EndIf}
+
+ SectionGetFlags ${StartService} $0
+ ${If} $0 = ${SF_SELECTED}
+ StrCpy $_SERVICESTART_ "YES"
+ ${Else}
+ StrCpy $_SERVICESTART_ "NO"
+ ${EndIf}
+
+ SectionGetFlags ${LocalSystemAccount} $0
+ ${If} $0 = ${SF_SELECTED}
+ StrCpy $_LOCALSYSTEMACCOUNT_ "YES"
+ ${Else}
+ StrCpy $_LOCALSYSTEMACCOUNT_ "NO"
+ ${EndIf}
+
+
+FunctionEnd
+
+Function ConfirmationPage
+ !insertmacro MUI_HEADER_TEXT "Confirmation Page" "Please confirm your choices for Jellyfin Server installation"
+
+ nsDialogs::Create 1018
+
+ ${NSD_CreateLabel} 0 0 100% 100% "The installer will proceed based on the following inputs gathered on earlier screens.$\r$\n$\r$\n\
+ Installation Folder : $INSTDIR$\r$\n\
+ Service install : $_INSTALLSERVICE_$\r$\n\
+ Service start : $_SERVICESTART_$\r$\n\
+ Local System account for service: $_LOCALSYSTEMACCOUNT_$\r$\n\
+ Custom Metadata folder : $_CUSTOMDATAFOLDER_$\r$\n\
+ Jellyfin Metadata Folder: $_JELLYFINDATADIR_"
+ nsDialogs::Show
+
+FunctionEnd
+
+Function .onInstSuccess
+ ExecShell "open" "http://localhost:8096"
+FunctionEnd