jellyfin.nsi 22 KB

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