Author: Zero3 Date: 2009-01-28 02:20:58 +0000 (Wed, 28 Jan 2009) New Revision: 25346
Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk Log: Removed service status loop from launcher (handled by start and stop scripts already) Added service start/stop status splash to start and stop scripts Increased service start/stop timeout to uninstaller and start and stop scripts Added result infomessages to start and stop scripts Added /?, /silent and /verysilent command line arguments to the start and stop scripts Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk =================================================================== --- trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk 2009-01-28 02:16:10 UTC (rev 25345) +++ trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk 2009-01-28 02:20:58 UTC (rev 25346) @@ -1,11 +1,6 @@ ; ; Windows Freenet Launcher by Zero3 (zero3 that-a-thingy zero3 that-dot-thingy dk) - http://freenetproject.org/ ; -; This launcher does the following: -; - Checks if service is running, and starts it if not (via bin\start.exe) -; - Compiles the fproxy URL by reading fproxy port information from freenet.ini -; - Finds the best browser available and launches fproxy in it (throws error if none found) -; ; Extra credits: ; - Service state function: heresy (http://www.autohotkey.com/forum/topic34984.html) ; @@ -23,73 +18,54 @@ SetWorkingDir, %A_ScriptDir% ; Look for other files relative to our own location ; -; Customizable settings +; Figure out what our service is called ; -_ServiceTimeout := 30 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service - -; -; Check if node is running -; IfNotExist, installid.dat { PopupErrorMessage("Freenet Launcher was unable to find the installid.dat ID file.`n`nMake sure that you are running Freenet Launcher from a Freenet installation directory.`nIf you are already doing so, please report this error message to the developers.") ExitApp, 1 } -IfNotExist, freenet.ini +Else { - PopupErrorMessage("Freenet Launcher was unable to find the freenet.ini configuration file.`n`nMake sure that you are running Freenet Launcher from a Freenet installation directory.`nIf you are already doing so, please report this error message to the developers.") - ExitApp, 1 + FileReadLine, _InstallSuffix, installid.dat, 1 + _ServiceName = freenet%_InstallSuffix% } -IfNotExist, bin\start.exe -{ - PopupErrorMessage("Freenet Launcher was unable to find the bin\start.exe launcher.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") - ExitApp, 1 -} -FileReadLine, _InstallSuffix, installid.dat, 1 - -Loop +; +; Make sure that node is running +; +If (Service_State(_ServiceName) <> 4) { - _ServiceState := Service_State("freenet" . _InstallSuffix) - - If (A_Index > _ServiceTimeout) + IfNotExist, bin\start.exe { - PopupErrorMessage("Freenet Launcher was unable to control the Freenet system service as it appears to be stuck.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") + PopupErrorMessage("Freenet Launcher was unable to find the bin\start.exe launcher.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") ExitApp, 1 } - Else If (_ServiceState == -1 || _ServiceState == -4) - { - PopupErrorMessage("Freenet Launcher was unable to find and control the Freenet system service.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") - ExitApp, 1 - } - Else If (_ServiceState == 2 || _ServiceState == 3 || _ServiceState == 5 || _ServiceState == 6) - { - Sleep, 1000 - Continue - } - Else If (_ServiceState == 1 || _ServiceState == 7) - { - RunWait, bin\start.exe, , UseErrorLevel - Sleep, 1000 - Continue - } Else { - Break ; Service must be running then! + RunWait, bin\start.exe /silent, , UseErrorLevel } } ; ; Compile fproxy URL ; -FileRead, _INI, freenet.ini -If (RegExMatch(_INI, "i)fproxy.port=([0-9]{1,5})", _Port) == 0 || !_Port1) +IfNotExist, freenet.ini { - PopupErrorMessage("Freenet Launcher was unable to read the 'fproxy.port' value from the freenet.ini configuration file.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") + PopupErrorMessage("Freenet Launcher was unable to find the freenet.ini configuration file.`n`nMake sure that you are running Freenet Launcher from a Freenet installation directory.`nIf you are already doing so, please report this error message to the developers.") ExitApp, 1 } +Else +{ + FileRead, _INI, freenet.ini + If (RegExMatch(_INI, "i)fproxy.port=([0-9]{1,5})", _Port) == 0 || !_Port1) + { + PopupErrorMessage("Freenet Launcher was unable to read the 'fproxy.port' value from the freenet.ini configuration file.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") + ExitApp, 1 + } -_URL = http://127.0.0.1:%_Port1%/ + _URL = http://127.0.0.1:%_Port1%/ +} ; ; Try browser: Mozilla FireFox Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk =================================================================== --- trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk 2009-01-28 02:16:10 UTC (rev 25345) +++ trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk 2009-01-28 02:20:58 UTC (rev 25346) @@ -8,22 +8,44 @@ ; ; Don't-touch-unless-you-know-what-you-are-doing settings ; -#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases -#NoTrayIcon ; We won't need this... -#SingleInstance ignore ; Only allow one instance at any given time +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases +#NoTrayIcon ; We won't need this... +#SingleInstance ignore ; Only allow one instance at any given time -SendMode, Input ; Recommended for new scripts due to its superior speed and reliability -StringCaseSense, Off ; Treat A-Z as equal to a-z when comparing strings. Useful when dealing with folders, as Windows treat them as equals. +SendMode, Input ; Recommended for new scripts due to its superior speed and reliability +StringCaseSense, Off ; Treat A-Z as equal to a-z when comparing strings. Useful when dealing with folders, as Windows treat them as equals. -_WorkingDir := RegExReplace(A_ScriptDir, "i)\\bin$", "") ; If we are located in the \bin folder, go back a step -SetWorkingDir, %_WorkingDir% ; Look for other files relative to install root +_WorkingDir := RegExReplace(A_ScriptDir, "i)\\bin$", "") ; If we are located in the \bin folder, go back a step +SetWorkingDir, %_WorkingDir% ; Look for other files relative to install root +_SplashCreated := 0 ; Initial value +_Silent := 0 ; Initial value + ; ; Customizable settings ; -_ServiceTimeout := 30 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service +_ServiceTimeout := 60 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service +_SplashFormat = A B2 T FS8 ; How our splash should look. ; +; Check if we should be silent or not (error messages are always displayed though) +; +_Arg1 = %1% +If (_Arg1 == "/?") +{ + PopupInfoMessage("Command line options (only use one):`n/silent - Hide info messsages`n/verysilent - Hide info and status messages`n`nReturn codes:`n0 - Success (service has been started)`n1 - Error occurred`n2 - Service was already running (no action taken)") + ExitApp, 0 +} +Else If (_Arg1 == "/silent") +{ + _Silent := 1 +} +Else If (_Arg1 == "/verysilent") +{ + _Silent := 2 +} + +; ; Check for administrator privileges. ; If not (A_IsAdmin) @@ -43,7 +65,7 @@ FileReadLine, _InstallSuffix, installid.dat, 1 _ServiceName = freenet%_InstallSuffix% -_ServiceHasBeenStarted := 0 ; Used to make sure that we only start the service once (to avoid UAC spam on Vista, among other things) +_ServiceHasBeenStarted := 0 ; Used to make sure that we only start the service once (to avoid UAC spam on Vista, among other things) Loop { @@ -51,6 +73,7 @@ If (A_Index > _ServiceTimeout) { + SplashImage, OFF PopupErrorMessage("Freenet start script was unable to control the Freenet system service as it appears to be stuck.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") ExitApp, 1 } @@ -61,6 +84,11 @@ } Else If (_ServiceState == 2 || _ServiceState == 3 || _ServiceState == 5 || _ServiceState == 6) { + If ((_Silent < 2) && !_SplashCreated) + { + _SplashCreated := 1 + SplashImage, , %_SplashFormat%, Waiting for the Freenet background service to start..., , Freenet start script + } Sleep, 1000 Continue } @@ -80,13 +108,17 @@ } Else { + SplashImage, OFF + If (_ServiceHasBeenStarted) { - ExitApp, 0 ; 0 = We started it + PopupInfoMessage("The Freenet service has been started!") + ExitApp, 0 ; 0 = We started it } Else { - ExitApp, 2 ; 2 = No action taken (service was already running) + PopupInfoMessage("The Freenet service is already running!") + ExitApp, 2 ; 2 = No action taken (service was already running) } } } @@ -97,9 +129,19 @@ ; PopupErrorMessage(_ErrorMessage) { - MsgBox, 16, Freenet start script error, %_ErrorMessage% ; 16 = Icon Hand (stop/error) + MsgBox, 16, Freenet start script error, %_ErrorMessage% ; 16 = Icon Hand (stop/error) } +PopupInfoMessage(_InfoMessage) +{ + global + + If (_Silent < 1) + { + MsgBox, 64, Freenet start script, %_InfoMessage% ; 64 = Icon Asterisk (info) + } +} + Service_State(ServiceName) { ; Return Values: Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk =================================================================== --- trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk 2009-01-28 02:16:10 UTC (rev 25345) +++ trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk 2009-01-28 02:20:58 UTC (rev 25346) @@ -8,22 +8,44 @@ ; ; Don't-touch-unless-you-know-what-you-are-doing settings ; -#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases -#NoTrayIcon ; We won't need this... -#SingleInstance ignore ; Only allow one instance at any given time +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases +#NoTrayIcon ; We won't need this... +#SingleInstance ignore ; Only allow one instance at any given time -SendMode, Input ; Recommended for new scripts due to its superior speed and reliability -StringCaseSense, Off ; Treat A-Z as equal to a-z when comparing strings. Useful when dealing with folders, as Windows treat them as equals. +SendMode, Input ; Recommended for new scripts due to its superior speed and reliability +StringCaseSense, Off ; Treat A-Z as equal to a-z when comparing strings. Useful when dealing with folders, as Windows treat them as equals. -_WorkingDir := RegExReplace(A_ScriptDir, "i)\\bin$", "") ; If we are located in the \bin folder, go back a step -SetWorkingDir, %_WorkingDir% ; Look for other files relative to install root +_WorkingDir := RegExReplace(A_ScriptDir, "i)\\bin$", "") ; If we are located in the \bin folder, go back a step +SetWorkingDir, %_WorkingDir% ; Look for other files relative to install root +_SplashCreated := 0 ; Initial value +_Silent := 0 ; Initial value + ; ; Customizable settings ; -_ServiceTimeout := 30 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service +_ServiceTimeout := 60 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service +_SplashFormat = A B2 T FS8 ; How our splash should look. ; +; Check if we should be silent or not (error messages are always displayed though) +; +_Arg1 = %1% +If (_Arg1 == "/?") +{ + PopupInfoMessage("Command line options (only use one):`n/silent - Hide info messsages`n/verysilent - Hide info and status messages`n`nReturn codes:`n0 - Success (service has been stopped)`n1 - Error occurred`n2 - Service was not running (no action taken)") + ExitApp, 0 +} +Else If (_Arg1 == "/silent") +{ + _Silent := 1 +} +Else If (_Arg1 == "/verysilent") +{ + _Silent := 2 +} + +; ; Check for administrator privileges. ; If not (A_IsAdmin) @@ -43,7 +65,7 @@ FileReadLine, _InstallSuffix, installid.dat, 1 _ServiceName = freenet%_InstallSuffix% -_ServiceHasBeenStopped := 0 ; Used to make sure that we only stop the service once (to avoid UAC spam on Vista, among other things) +_ServiceHasBeenStopped := 0 ; Used to make sure that we only stop the service once (to avoid UAC spam on Vista, among other things) Loop { @@ -51,6 +73,7 @@ If (A_Index > _ServiceTimeout) { + SplashImage, OFF PopupErrorMessage("Freenet stop script was unable to control the Freenet system service as it appears to be stuck.`n`nPlease reinstall Freenet.`n`nIf the problem keeps occurring, please report this error message to the developers.") ExitApp, 1 } @@ -61,18 +84,27 @@ } Else If (_ServiceState == 2 || _ServiceState == 3 || _ServiceState == 5 || _ServiceState == 6) { + If ((_Silent < 2) && !_SplashCreated) + { + _SplashCreated := 1 + SplashImage, , %_SplashFormat%, Waiting for the Freenet background service to stop..., , Freenet stop script + } Sleep, 1000 Continue } Else If (_ServiceState == 1) { + SplashImage, OFF + If (_ServiceHasBeenStopped) { - ExitApp, 0 ; 0 = We stopped it + PopupInfoMessage("The Freenet service has been stopped!") + ExitApp, 0 ; 0 = We stopped it } Else { - ExitApp, 2 ; 2 = No action taken (service was already stopped) + PopupInfoMessage("The Freenet service is already stopped!") + ExitApp, 2 ; 2 = No action taken (service was already stopped) } } Else @@ -96,9 +128,19 @@ ; PopupErrorMessage(_ErrorMessage) { - MsgBox, 16, Freenet stop script error, %_ErrorMessage% ; 16 = Icon Hand (stop/error) + MsgBox, 16, Freenet stop script error, %_ErrorMessage% ; 16 = Icon Hand (stop/error) } +PopupInfoMessage(_InfoMessage) +{ + global + + If (_Silent < 1) + { + MsgBox, 64, Freenet stop script, %_InfoMessage% ; 64 = Icon Asterisk (info) + } +} + Service_State(ServiceName) { ; Return Values: Modified: trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk =================================================================== --- trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk 2009-01-28 02:16:10 UTC (rev 25345) +++ trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk 2009-01-28 02:20:58 UTC (rev 25346) @@ -365,7 +365,7 @@ ; ; Start the node ; -RunWait, %_InstallDir%\bin\start.exe, , UseErrorLevel +RunWait, %_InstallDir%\bin\start.exe /verysilent, , UseErrorLevel GuiControl, , _cProgressBar, +1 ; Modified: trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk =================================================================== --- trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk 2009-01-28 02:16:10 UTC (rev 25345) +++ trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk 2009-01-28 02:20:58 UTC (rev 25346) @@ -22,7 +22,7 @@ ; ; Customizable settings ; -_ServiceTimeout := 30 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service +_ServiceTimeout := 60 ; Maximum number of seconds we wait before "timing out" and throwing an error when managing the system service _ProgressFormat = A T W300 FS10 ; How our progress bar should look. The 'R' (range) parameter is added later in the script. ; _______________________________________________ cvs mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
