jellyfin.nsi 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. ; Shows a lot of debug information while compiling
  2. ; This can be removed once stable.
  3. !verbose 4
  4. SetCompressor lzma
  5. ShowInstDetails show
  6. ShowUninstDetails show
  7. ;--------------------------------
  8. !define SF_USELECTED 0 ; used to check selected options status, rest are inherited from Sections.nsh
  9. !include "MUI2.nsh"
  10. !include "Sections.nsh"
  11. !include "LogicLib.nsh"
  12. !include "helpers\ShowError.nsh"
  13. ; Global variables that we'll use
  14. Var _JELLYFINVERSION_
  15. Var _JELLYFINDATADIR_
  16. Var _SETUPTYPE_
  17. Var _INSTALLSERVICE_
  18. Var _SERVICESTART_
  19. Var _SERVICEACCOUNTTYPE_
  20. Var _EXISTINGINSTALLATION_
  21. Var _EXISTINGSERVICE_
  22. Var _MAKESHORTCUTS_
  23. Var _FOLDEREXISTS_
  24. ;
  25. !ifdef x64
  26. !define ARCH "x64"
  27. !define NAMESUFFIX "(64 bit)"
  28. !define INSTALL_DIRECTORY "$PROGRAMFILES64\Jellyfin\Server"
  29. !endif
  30. !ifdef x84
  31. !define ARCH "x86"
  32. !define NAMESUFFIX "(32 bit)"
  33. !define INSTALL_DIRECTORY "$PROGRAMFILES32\Jellyfin\Server"
  34. !endif
  35. !ifndef ARCH
  36. !error "Set the Arch with /Dx86 or /Dx64"
  37. !endif
  38. ;--------------------------------
  39. !define REG_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\JellyfinServer" ;Registry to show up in Add/Remove Programs
  40. !define REG_CONFIG_KEY "Software\Jellyfin\Server" ;Registry to store all configuration
  41. !getdllversion "$%InstallLocation%\jellyfin.dll" ver_ ;Align installer version with jellyfin.dll version
  42. Name "Jellyfin Server ${ver_1}.${ver_2}.${ver_3} ${NAMESUFFIX}" ; This is referred in various header text labels
  43. OutFile "jellyfin_${ver_1}.${ver_2}.${ver_3}_windows-${ARCH}.exe" ; Naming convention jellyfin_{version}_windows-{arch].exe
  44. BrandingText "Jellyfin Server ${ver_1}.${ver_2}.${ver_3} Installer" ; This shows in just over the buttons
  45. ; installer attributes, these show up in details tab on installer properties
  46. VIProductVersion "${ver_1}.${ver_2}.${ver_3}.0" ; VIProductVersion format, should be X.X.X.X
  47. VIFileVersion "${ver_1}.${ver_2}.${ver_3}.0" ; VIFileVersion format, should be X.X.X.X
  48. VIAddVersionKey "ProductName" "Jellyfin Server"
  49. VIAddVersionKey "FileVersion" "${ver_1}.${ver_2}.${ver_3}.0"
  50. VIAddVersionKey "LegalCopyright" "(c) 2019 Jellyfin Contributors. Code released under the GNU General Public License"
  51. VIAddVersionKey "FileDescription" "Jellyfin Server: The Free Software Media System"
  52. ;TODO, check defaults
  53. InstallDir ${INSTALL_DIRECTORY} ;Default installation folder
  54. InstallDirRegKey HKLM "${REG_CONFIG_KEY}" "InstallFolder" ;Read the registry for install folder,
  55. RequestExecutionLevel admin ; ask it upfront for service control, and installing in priv folders
  56. CRCCheck on ; make sure the installer wasn't corrupted while downloading
  57. !define MUI_ABORTWARNING ;Prompts user in case of aborting install
  58. ; TODO: Replace with nice Jellyfin Icons
  59. !ifdef UXPATH
  60. !define MUI_ICON "${UXPATH}\branding\NSIS\modern-install.ico" ; Installer Icon
  61. !define MUI_UNICON "${UXPATH}\branding\NSIS\modern-uninstall.ico" ; Uninstaller Icon
  62. !define MUI_HEADERIMAGE
  63. !define MUI_HEADERIMAGE_BITMAP "${UXPATH}\branding\NSIS\installer-header.bmp"
  64. !define MUI_WELCOMEFINISHPAGE_BITMAP "${UXPATH}\branding\NSIS\installer-right.bmp"
  65. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${UXPATH}\branding\NSIS\installer-right.bmp"
  66. !endif
  67. ;--------------------------------
  68. ;Pages
  69. ; Welcome Page
  70. !define MUI_WELCOMEPAGE_TEXT "The installer will ask for details to install Jellyfin Server."
  71. !insertmacro MUI_PAGE_WELCOME
  72. ; License Page
  73. !insertmacro MUI_PAGE_LICENSE "$%InstallLocation%\LICENSE" ; picking up generic GPL
  74. ; Setup Type Page
  75. Page custom ShowSetupTypePage SetupTypePage_Config
  76. ; Components Page
  77. !define MUI_PAGE_CUSTOMFUNCTION_PRE HideComponentsPage
  78. !insertmacro MUI_PAGE_COMPONENTS
  79. !define MUI_PAGE_CUSTOMFUNCTION_PRE HideInstallDirectoryPage ; Controls when to hide / show
  80. !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Install folder" ; shows just above the folder selection dialog
  81. !insertmacro MUI_PAGE_DIRECTORY
  82. ; Data folder Page
  83. !define MUI_PAGE_CUSTOMFUNCTION_PRE HideDataDirectoryPage ; Controls when to hide / show
  84. !define MUI_PAGE_HEADER_TEXT "Choose Data Location"
  85. !define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the Jellyfin Server data."
  86. !define MUI_DIRECTORYPAGE_TEXT_TOP "The installer will set the following folder for Jellyfin Server data. To install in a different folder, click Browse and select another folder. Please make sure the folder exists and is accessible. Click Next to continue."
  87. !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Data folder"
  88. !define MUI_DIRECTORYPAGE_VARIABLE $_JELLYFINDATADIR_
  89. !insertmacro MUI_PAGE_DIRECTORY
  90. ; Custom Dialogs
  91. !include "dialogs\setuptype.nsdinc"
  92. !include "dialogs\service-config.nsdinc"
  93. !include "dialogs\confirmation.nsdinc"
  94. ; Select service account type
  95. #!define MUI_PAGE_CUSTOMFUNCTION_PRE HideServiceConfigPage ; Controls when to hide / show (This does not work for Page, might need to go PageEx)
  96. #!define MUI_PAGE_CUSTOMFUNCTION_SHOW fnc_service_config_Show
  97. #!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ServiceConfigPage_Config
  98. #!insertmacro MUI_PAGE_CUSTOM ServiceAccountType
  99. Page custom ShowServiceConfigPage ServiceConfigPage_Config
  100. ; Confirmation Page
  101. Page custom ShowConfirmationPage ; just letting the user know what they chose to install
  102. ; Actual Installion Page
  103. !insertmacro MUI_PAGE_INSTFILES
  104. !insertmacro MUI_UNPAGE_CONFIRM
  105. !insertmacro MUI_UNPAGE_INSTFILES
  106. #!insertmacro MUI_UNPAGE_FINISH
  107. ;--------------------------------
  108. ;Languages; Add more languages later here if needed
  109. !insertmacro MUI_LANGUAGE "English"
  110. ;--------------------------------
  111. ;Installer Sections
  112. Section "!Jellyfin Server (required)" InstallJellyfinServer
  113. SectionIn RO ; Mandatory section, isn't this the whole purpose to run the installer.
  114. StrCmp "$_EXISTINGINSTALLATION_" "Yes" RunUninstaller CarryOn ; Silently uninstall in case of previous installation
  115. RunUninstaller:
  116. DetailPrint "Looking for uninstaller at $INSTDIR"
  117. FindFirst $0 $1 "$INSTDIR\Uninstall.exe"
  118. FindClose $0
  119. StrCmp $1 "" CarryOn ; the registry key was there but uninstaller was not found
  120. DetailPrint "Silently running the uninstaller at $INSTDIR"
  121. ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR' $0
  122. DetailPrint "Uninstall finished, $0"
  123. CarryOn:
  124. ${If} $_EXISTINGSERVICE_ == 'Yes'
  125. ExecWait '"$INSTDIR\nssm.exe" stop JellyfinServer' $0
  126. ${If} $0 <> 0
  127. MessageBox MB_OK|MB_ICONSTOP "Could not stop the Jellyfin Server service."
  128. Abort
  129. ${EndIf}
  130. DetailPrint "Stopped Jellyfin Server service, $0"
  131. ${EndIf}
  132. SetOutPath "$INSTDIR"
  133. CopyFiles /SILENT /FILESONLY "${UXPATH}\branding\NSIS\modern-install.ico" "$%InstallLocation%\icon.ico"
  134. File /r $%InstallLocation%\*
  135. ; Write the InstallFolder, DataFolder, Network Service info into the registry for later use
  136. WriteRegExpandStr HKLM "${REG_CONFIG_KEY}" "InstallFolder" "$INSTDIR"
  137. WriteRegExpandStr HKLM "${REG_CONFIG_KEY}" "DataFolder" "$_JELLYFINDATADIR_"
  138. WriteRegStr HKLM "${REG_CONFIG_KEY}" "ServiceAccountType" "$_SERVICEACCOUNTTYPE_"
  139. !getdllversion "$%InstallLocation%\jellyfin.dll" ver_
  140. StrCpy $_JELLYFINVERSION_ "${ver_1}.${ver_2}.${ver_3}" ;
  141. ; Write the uninstall keys for Windows
  142. WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayName" "Jellyfin Server $_JELLYFINVERSION_ ${NAMESUFFIX}"
  143. WriteRegExpandStr HKLM "${REG_UNINST_KEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
  144. WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayIcon" '"$INSTDIR\Uninstall.exe",0'
  145. WriteRegStr HKLM "${REG_UNINST_KEY}" "Publisher" "The Jellyfin Project"
  146. WriteRegStr HKLM "${REG_UNINST_KEY}" "URLInfoAbout" "https://jellyfin.org/"
  147. WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayVersion" "$_JELLYFINVERSION_"
  148. WriteRegDWORD HKLM "${REG_UNINST_KEY}" "NoModify" 1
  149. WriteRegDWORD HKLM "${REG_UNINST_KEY}" "NoRepair" 1
  150. ;Create uninstaller
  151. WriteUninstaller "$INSTDIR\Uninstall.exe"
  152. SectionEnd
  153. Section "Jellyfin Server Service" InstallService
  154. ${If} $_INSTALLSERVICE_ == "Yes" ; Only run this if we're going to install the service!
  155. ExecWait '"$INSTDIR\nssm.exe" statuscode JellyfinServer' $0
  156. DetailPrint "Jellyfin Server service statuscode, $0"
  157. ${If} $0 == 0
  158. InstallRetry:
  159. ExecWait '"$INSTDIR\nssm.exe" install JellyfinServer "$INSTDIR\jellyfin.exe" --datadir \"$_JELLYFINDATADIR_\"' $0
  160. ${If} $0 <> 0
  161. !insertmacro ShowError "Could not install the Jellyfin Server service." InstallRetry
  162. ${EndIf}
  163. DetailPrint "Jellyfin Server Service install, $0"
  164. ${Else}
  165. DetailPrint "Jellyfin Server Service exists, updating..."
  166. ConfigureApplicationRetry:
  167. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Application "$INSTDIR\jellyfin.exe"' $0
  168. ${If} $0 <> 0
  169. !insertmacro ShowError "Could not configure the Jellyfin Server service." ConfigureApplicationRetry
  170. ${EndIf}
  171. DetailPrint "Jellyfin Server Service setting (Application), $0"
  172. ConfigureAppParametersRetry:
  173. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer AppParameters --datadir \"$_JELLYFINDATADIR_\"' $0
  174. ${If} $0 <> 0
  175. !insertmacro ShowError "Could not configure the Jellyfin Server service." ConfigureAppParametersRetry
  176. ${EndIf}
  177. DetailPrint "Jellyfin Server Service setting (AppParameters), $0"
  178. ${EndIf}
  179. Sleep 3000 ; Give time for Windows to catchup
  180. ConfigureStartRetry:
  181. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Start SERVICE_DELAYED_AUTO_START' $0
  182. ${If} $0 <> 0
  183. !insertmacro ShowError "Could not configure the Jellyfin Server service." ConfigureStartRetry
  184. ${EndIf}
  185. DetailPrint "Jellyfin Server Service setting (Start), $0"
  186. ConfigureDescriptionRetry:
  187. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Description "Jellyfin Server: The Free Software Media System"' $0
  188. ${If} $0 <> 0
  189. !insertmacro ShowError "Could not configure the Jellyfin Server service." ConfigureDescriptionRetry
  190. ${EndIf}
  191. DetailPrint "Jellyfin Server Service setting (Description), $0"
  192. ConfigureDisplayNameRetry:
  193. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer DisplayName "Jellyfin Server"' $0
  194. ${If} $0 <> 0
  195. !insertmacro ShowError "Could not configure the Jellyfin Server service." ConfigureDisplayNameRetry
  196. ${EndIf}
  197. DetailPrint "Jellyfin Server Service setting (DisplayName), $0"
  198. Sleep 3000
  199. ${If} $_SERVICEACCOUNTTYPE_ == "NetworkService" ; the default install using NSSM is Local System
  200. ConfigureNetworkServiceRetry:
  201. ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Objectname "Network Service"' $0
  202. ${If} $0 <> 0
  203. !insertmacro ShowError "Could not configure the Jellyfin Server service account." ConfigureNetworkServiceRetry
  204. ${EndIf}
  205. DetailPrint "Jellyfin Server service account change, $0"
  206. ${EndIf}
  207. ${EndIf}
  208. SectionEnd
  209. Section "-start service" StartService
  210. ${If} $_SERVICESTART_ == "Yes"
  211. ${AndIf} $_INSTALLSERVICE_ == "Yes"
  212. StartRetry:
  213. ExecWait '"$INSTDIR\nssm.exe" start JellyfinServer' $0
  214. ${If} $0 <> 0
  215. !insertmacro ShowError "Could not start the Jellyfin Server service." StartRetry
  216. ${EndIf}
  217. DetailPrint "Jellyfin Server service start, $0"
  218. ${EndIf}
  219. SectionEnd
  220. Section "Create Shortcuts" CreateWinShortcuts
  221. ${If} $_MAKESHORTCUTS_ == "Yes"
  222. CreateDirectory "$SMPROGRAMS\Jellyfin Server"
  223. CreateShortCut "$SMPROGRAMS\Jellyfin Server\Jellyfin (View Console).lnk" "$INSTDIR\jellyfin.exe" "--datadir $\"$_JELLYFINDATADIR_$\"" "$INSTDIR\icon.ico" 0 SW_SHOWMAXIMIZED
  224. ;CreateShortCut "$SMPROGRAMS\Jellyfin Server\Jellyfin Tray App.lnk" "$INSTDIR\jellyfin-tray.exe" "--datadir $\"$_JELLYFINDATADIR_$\"" "$INSTDIR\icon.ico" 0
  225. CreateShortCut "$DESKTOP\Jellyfin Server.lnk" "$INSTDIR\jellyfin.exe" "--datadir $\"$_JELLYFINDATADIR_$\"" "$INSTDIR\icon.ico" 0 SW_SHOWMINIMIZED
  226. ;CreateShortCut "$DESKTOP\Jellyfin Server\Jellyfin Server.lnk" "$INSTDIR\jellyfin-tray.exe" "--datadir $\"$_JELLYFINDATADIR_$\"" "$INSTDIR\icon.ico" 0
  227. ${EndIf}
  228. SectionEnd
  229. ;--------------------------------
  230. ;Descriptions
  231. ;Language strings
  232. LangString DESC_InstallJellyfinServer ${LANG_ENGLISH} "Install Jellyfin Server"
  233. LangString DESC_InstallService ${LANG_ENGLISH} "Install As a Service"
  234. ;Assign language strings to sections
  235. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  236. !insertmacro MUI_DESCRIPTION_TEXT ${InstallJellyfinServer} $(DESC_InstallJellyfinServer)
  237. !insertmacro MUI_DESCRIPTION_TEXT ${InstallService} $(DESC_InstallService)
  238. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  239. ;--------------------------------
  240. ;Uninstaller Section
  241. Section "Uninstall"
  242. ReadRegStr $INSTDIR HKLM "${REG_CONFIG_KEY}" "InstallFolder" ; read the installation folder
  243. ReadRegStr $_JELLYFINDATADIR_ HKLM "${REG_CONFIG_KEY}" "DataFolder" ; read the data folder
  244. ReadRegStr $_SERVICEACCOUNTTYPE_ HKLM "${REG_CONFIG_KEY}" "ServiceAccountType" ; read the account name
  245. DetailPrint "Jellyfin Install location: $INSTDIR"
  246. DetailPrint "Jellyfin Data folder: $_JELLYFINDATADIR_"
  247. MessageBox MB_YESNO|MB_ICONINFORMATION "Do you want to retain the Jellyfin Server data folder? The media will not be touched. $\r$\nIf unsure choose YES." /SD IDYES IDYES PreserveData
  248. RMDir /r /REBOOTOK "$_JELLYFINDATADIR_"
  249. PreserveData:
  250. ExecWait '"$INSTDIR\nssm.exe" statuscode JellyfinServer' $0
  251. DetailPrint "Jellyfin Server service statuscode, $0"
  252. IntCmp $0 0 NoServiceUninstall ; service doesn't exist, may be run from desktop shortcut
  253. Sleep 3000 ; Give time for Windows to catchup
  254. UninstallStopRetry:
  255. ExecWait '"$INSTDIR\nssm.exe" stop JellyfinServer' $0
  256. ${If} $0 <> 0
  257. !insertmacro ShowError "Could not stop the Jellyfin Server service." UninstallStopRetry
  258. ${EndIf}
  259. DetailPrint "Stopped Jellyfin Server service, $0"
  260. UninstallRemoveRetry:
  261. ExecWait '"$INSTDIR\nssm.exe" remove JellyfinServer confirm' $0
  262. ${If} $0 <> 0
  263. !insertmacro ShowError "Could not remove the Jellyfin Server service." UninstallRemoveRetry
  264. ${EndIf}
  265. DetailPrint "Removed Jellyfin Server service, $0"
  266. Sleep 3000 ; Give time for Windows to catchup
  267. NoServiceUninstall: ; existing install was present but no service was detected. Remove shortcuts if account is set to none
  268. ${If} $_SERVICEACCOUNTTYPE_ == "None"
  269. RMDir /r "$SMPROGRAMS\Jellyfin Server"
  270. Delete "$DESKTOP\Jellyfin Server.lnk"
  271. DetailPrint "Removed old shortcuts..."
  272. ${EndIf}
  273. Delete "$INSTDIR\*.*"
  274. RMDir /r /REBOOTOK "$INSTDIR\jellyfin-web"
  275. Delete "$INSTDIR\Uninstall.exe"
  276. RMDir /r /REBOOTOK "$INSTDIR"
  277. DeleteRegKey HKLM "Software\Jellyfin"
  278. DeleteRegKey HKLM "${REG_UNINST_KEY}"
  279. SectionEnd
  280. Function .onInit
  281. ; Setting up defaults
  282. StrCpy $_INSTALLSERVICE_ "Yes"
  283. StrCpy $_SERVICESTART_ "Yes"
  284. StrCpy $_SERVICEACCOUNTTYPE_ "NetworkService"
  285. StrCpy $_EXISTINGINSTALLATION_ "No"
  286. StrCpy $_EXISTINGSERVICE_ "No"
  287. StrCpy $_MAKESHORTCUTS_ "No"
  288. SetShellVarContext current
  289. StrCpy $_JELLYFINDATADIR_ "$%ProgramData%\Jellyfin\Server"
  290. System::Call 'kernel32::CreateMutex(p 0, i 0, t "JellyfinServerMutex") p .r1 ?e'
  291. Pop $R0
  292. StrCmp $R0 0 +3
  293. !insertmacro ShowErrorFinal "The installer is already running."
  294. ;Detect if Jellyfin is already installed.
  295. ; In case it is installed, let the user choose either
  296. ; 1. Exit installer
  297. ; 2. Upgrade without messing with data
  298. ; 2a. Don't ask for any details, uninstall and install afresh with old settings
  299. ; Read Registry for previous installation
  300. ClearErrors
  301. ReadRegStr "$0" HKLM "${REG_CONFIG_KEY}" "InstallFolder"
  302. IfErrors NoExisitingInstall
  303. DetailPrint "Existing Jellyfin Server detected at: $0"
  304. StrCpy "$INSTDIR" "$0" ; set the location fro registry as new default
  305. StrCpy $_EXISTINGINSTALLATION_ "Yes" ; Set our flag to be used later
  306. SectionSetText ${InstallJellyfinServer} "Upgrade Jellyfin Server (required)" ; Change install text to "Upgrade"
  307. ; check if service was run using Network Service account
  308. ClearErrors
  309. ReadRegStr $_SERVICEACCOUNTTYPE_ HKLM "${REG_CONFIG_KEY}" "ServiceAccountType" ; in case of error _SERVICEACCOUNTTYPE_ will be NetworkService as default
  310. ClearErrors
  311. ReadRegStr $_JELLYFINDATADIR_ HKLM "${REG_CONFIG_KEY}" "DataFolder" ; in case of error, the default holds
  312. ; Hide sections which will not be needed in case of previous install
  313. ; SectionSetText ${InstallService} ""
  314. ; check if there is a service called Jellyfin, there should be
  315. ; hack : nssm statuscode Jellyfin will return non zero return code in case it exists
  316. ExecWait '"$INSTDIR\nssm.exe" statuscode JellyfinServer' $0
  317. DetailPrint "Jellyfin Server service statuscode, $0"
  318. IntCmp $0 0 NoService ; service doesn't exist, may be run from desktop shortcut
  319. ; if service was detected, set defaults going forward.
  320. StrCpy $_EXISTINGSERVICE_ "Yes"
  321. StrCpy $_INSTALLSERVICE_ "Yes"
  322. StrCpy $_SERVICESTART_ "Yes"
  323. StrCpy $_MAKESHORTCUTS_ "No"
  324. SectionSetText ${CreateWinShortcuts} ""
  325. NoService: ; existing install was present but no service was detected
  326. ${If} $_SERVICEACCOUNTTYPE_ == "None"
  327. StrCpy $_SETUPTYPE_ "Basic"
  328. StrCpy $_INSTALLSERVICE_ "No"
  329. StrCpy $_SERVICESTART_ "No"
  330. StrCpy $_MAKESHORTCUTS_ "Yes"
  331. ${EndIf}
  332. ; Let the user know that we'll upgrade and provide an option to quit.
  333. MessageBox MB_OKCANCEL|MB_ICONINFORMATION "Existing installation of Jellyfin Server was detected, it'll be upgraded, settings will be retained. \
  334. $\r$\nClick OK to proceed, Cancel to exit installer." /SD IDOK IDOK ProceedWithUpgrade
  335. Quit ; Quit if the user is not sure about upgrade
  336. ProceedWithUpgrade:
  337. NoExisitingInstall: ; by this time, the variables have been correctly set to reflect previous install details
  338. FunctionEnd
  339. Function HideInstallDirectoryPage
  340. ${If} $_EXISTINGINSTALLATION_ == "Yes" ; Existing installation detected, so don't ask for InstallFolder
  341. Abort
  342. ${EndIf}
  343. FunctionEnd
  344. Function HideDataDirectoryPage
  345. ${If} $_EXISTINGINSTALLATION_ == "Yes" ; Existing installation detected, so don't ask for InstallFolder
  346. Abort
  347. ${EndIf}
  348. FunctionEnd
  349. Function HideServiceConfigPage
  350. ${If} $_INSTALLSERVICE_ == "No" ; Not running as a service, don't ask for service type
  351. ${OrIf} $_EXISTINGINSTALLATION_ == "Yes" ; Existing installation detected, so don't ask for InstallFolder
  352. Abort
  353. ${EndIf}
  354. FunctionEnd
  355. Function HideConfirmationPage
  356. ${If} $_EXISTINGINSTALLATION_ == "Yes" ; Existing installation detected, so don't ask for InstallFolder
  357. Abort
  358. ${EndIf}
  359. FunctionEnd
  360. Function HideSetupTypePage
  361. ${If} $_EXISTINGINSTALLATION_ == "Yes" ; Existing installation detected, so don't ask for SetupType
  362. Abort
  363. ${EndIf}
  364. FunctionEnd
  365. Function HideComponentsPage
  366. ${If} $_SETUPTYPE_ == "Basic" ; Basic installation chosen, don't show components choice
  367. Abort
  368. ${EndIf}
  369. FunctionEnd
  370. ; Setup Type dialog show function
  371. Function ShowSetupTypePage
  372. Call HideSetupTypePage
  373. Call fnc_setuptype_Create
  374. nsDialogs::Show
  375. FunctionEnd
  376. ; Service Config dialog show function
  377. Function ShowServiceConfigPage
  378. Call HideServiceConfigPage
  379. Call fnc_service_config_Create
  380. nsDialogs::Show
  381. FunctionEnd
  382. ; Confirmation dialog show function
  383. Function ShowConfirmationPage
  384. Call HideConfirmationPage
  385. Call fnc_confirmation_Create
  386. nsDialogs::Show
  387. FunctionEnd
  388. ; Declare temp variables to read the options from the custom page.
  389. Var StartServiceAfterInstall
  390. Var UseNetworkServiceAccount
  391. Var UseLocalSystemAccount
  392. Var BasicInstall
  393. Function SetupTypePage_Config
  394. ${NSD_GetState} $hCtl_setuptype_BasicInstall $BasicInstall
  395. IfFileExists "$LOCALAPPDATA\Jellyfin" folderfound foldernotfound ; if the folder exists, use this, otherwise, go with new default
  396. folderfound:
  397. StrCpy $_FOLDEREXISTS_ "Yes"
  398. Goto InstallCheck
  399. foldernotfound:
  400. StrCpy $_FOLDEREXISTS_ "No"
  401. Goto InstallCheck
  402. InstallCheck:
  403. ${If} $BasicInstall == 1
  404. StrCpy $_SETUPTYPE_ "Basic"
  405. StrCpy $_INSTALLSERVICE_ "No"
  406. StrCpy $_SERVICESTART_ "No"
  407. StrCpy $_SERVICEACCOUNTTYPE_ "None"
  408. StrCpy $_MAKESHORTCUTS_ "Yes"
  409. ${If} $_FOLDEREXISTS_ == "Yes"
  410. StrCpy $_JELLYFINDATADIR_ "$LOCALAPPDATA\Jellyfin\"
  411. ${EndIf}
  412. ${Else}
  413. StrCpy $_SETUPTYPE_ "Advanced"
  414. StrCpy $_INSTALLSERVICE_ "Yes"
  415. StrCpy $_MAKESHORTCUTS_ "No"
  416. ${If} $_FOLDEREXISTS_ == "Yes"
  417. MessageBox MB_OKCANCEL|MB_ICONINFORMATION "An existing data folder was detected.\
  418. $\r$\nBasic Setup is highly recommended.\
  419. $\r$\nIf you proceed, you will need to set up Jellyfin again." IDOK GoAhead IDCANCEL GoBack
  420. GoBack:
  421. Abort
  422. ${EndIf}
  423. GoAhead:
  424. StrCpy $_JELLYFINDATADIR_ "$%ProgramData%\Jellyfin\Server"
  425. SectionSetText ${CreateWinShortcuts} ""
  426. ${EndIf}
  427. FunctionEnd
  428. Function ServiceConfigPage_Config
  429. ${NSD_GetState} $hCtl_service_config_StartServiceAfterInstall $StartServiceAfterInstall
  430. ${If} $StartServiceAfterInstall == 1
  431. StrCpy $_SERVICESTART_ "Yes"
  432. ${Else}
  433. StrCpy $_SERVICESTART_ "No"
  434. ${EndIf}
  435. ${NSD_GetState} $hCtl_service_config_UseNetworkServiceAccount $UseNetworkServiceAccount
  436. ${NSD_GetState} $hCtl_service_config_UseLocalSystemAccount $UseLocalSystemAccount
  437. ${If} $UseNetworkServiceAccount == 1
  438. StrCpy $_SERVICEACCOUNTTYPE_ "NetworkService"
  439. ${ElseIf} $UseLocalSystemAccount == 1
  440. StrCpy $_SERVICEACCOUNTTYPE_ "LocalSystem"
  441. ${Else}
  442. !insertmacro ShowErrorFinal "Service account type not properly configured."
  443. ${EndIf}
  444. FunctionEnd
  445. ; This function handles the choices during component selection
  446. Function .onSelChange
  447. ; If we are not installing service, we don't need to set the NetworkService account or StartService
  448. SectionGetFlags ${InstallService} $0
  449. ${If} $0 = ${SF_SELECTED}
  450. StrCpy $_INSTALLSERVICE_ "Yes"
  451. ${Else}
  452. StrCpy $_INSTALLSERVICE_ "No"
  453. StrCpy $_SERVICESTART_ "No"
  454. StrCpy $_SERVICEACCOUNTTYPE_ "None"
  455. ${EndIf}
  456. FunctionEnd
  457. Function .onInstSuccess
  458. #ExecShell "open" "http://localhost:8096"
  459. FunctionEnd