Name "Achievo" OutFile "Install Achievo.exe" ; Some default compiler settings (uncomment and change at will): SetCompress force ; (can be off or force) ; SetDatablockOptimize on ; (can be off) ; CRCCheck on ; (can be off) AutoCloseWindow false ; (can be true for the window go away automatically at end) ShowInstDetails hide ; (can be show to have them shown, or nevershow to disable) ; SetDateSave on ; (can be on to have files restored to their orginal date) LicenseText "You must agree to this license before installing." LicenseData "C:\Program Files\Achievo\License.txt" InstallDir "$PROGRAMFILES\Achievo" InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Achievo" "" DirShow show ; make this show to let the user change it) DirText "Select the directory you wish to install Achievo in" Section "" ; (default section) SetShellVarContext all CreateDirectory "$TEMP\Achievo" SetOutPath "$INSTDIR" ; add files / whatever that need to be installed here. WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Achievo" "" "$INSTDIR" WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Achievo" "DisplayName" "Achievo (remove only)" WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Achievo" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKEY_LOCAL_MACHINE "Software\Achievo" "Apache2" '"$INSTDIR\Apache2\bin\Apache.exe" -k runservice' ReadRegStr $0 HKLM SOFTWAREMicrosoftWindowsCurrentVersion VersionNumber StrCmp $0 "" windowsnt 0 WriteRegStr HKEY_LOCAL_MACHINE "Software\Achievo" "Mysql" '$INSTDIR\Apache2\mysql\bin\mysqld.exe' Goto last windowsnt: WriteRegStr HKEY_LOCAL_MACHINE "Software\Achievo" "Mysql" '$INSTDIR\Apache2\mysql\bin\mysqld-nt.exe' Goto last last: File /r "C:\Program Files\Achievo\*.*" SetOutPath "$WINDIR" File /r "C:\Program Files\Achievo\Apache2\php\php.ini" WriteINIStr "$WINDIR/php.ini" "php" "register_globals" "On" WriteINIStr "$WINDIR/php.ini" "php" "extension_dir" '"$INSTDIR\Apache2\php\extensions./"' WriteINIStr "$WINDIR/php.ini" "Session" "session.save_path" '"$TEMP\Achievo"' File "C:\WINDOWS\my.ini" File "C:\Program Files\Achievo\Apache2\ip.dll" CallInstDll "$INSTDIR\ip.dll" "get_ip" Pop $0 begin: Push $0 Call GetNextIp Call CheckIp Pop $2 ; Type of current IP-address Pop $1 ; Current IP-address Pop $0 ; Remaining addresses StrCmp $2 '1' '' NoLoopBackIp StrCpy $7 $1 Goto Continue NoLoopBackIp: StrCmp $2 '2' '' NoAPA StrCpy $7 $1 Goto Continue NoAPA: StrCmp $2 '3' '' NoLanIp StrCpy $7 $1 Goto Continue NoLanIp: StrCpy $7 $1 Continue: StrCmp $0 '' ExitLoop begin ExitLoop: Delete $TEMP\ip.dll StrCpy $4 "$INSTDIR" StrCmp $4 "$INSTDIR" 0 +7 Push $4 Push "\" Push "/" Call StrReplace Pop $0 StrCpy $5 $0 WriteINIStr "$WINDIR\my.ini" "mysqld" "basedir" "$5/Apache2/mysql" WriteINIStr "$WINDIR\my.ini" "mysqld" "#bind-address" "$7" WriteINIStr "$WINDIR\my.ini" "mysqld" "datadir" "$5/Apache2/mysql/data" WriteINIStr "$WINDIR\my.ini" "mysqld" "#language" "$5/Apache2/mysql/share/your language directory" ReadRegStr $0 HKLM SOFTWAREMicrosoftWindowsCurrentVersion VersionNumber StrCmp $0 "" win 0 WriteINIStr "$WINDIR/my.ini" "WinMySQLadmin" "Server" "$5/Apache2/mysql/bin/mysqld.exe" Exec '"$INSTDIR\Apache2\mysql\bin\mysqld.exe" --install' Goto end win: WriteINIStr "$WINDIR\my.ini" "WinMySQLadmin" "Server" "$5/Apache2/mysql/bin/mysqld-nt.exe" Exec '"$INSTDIR\Apache2\mysql\bin\mysqld-nt.exe" --install' Goto end end: WriteINIStr "$WINDIR/my.ini" "WinMySQLadmin" "user" "root" WriteINIStr "$WINDIR/my.ini" "WinMySQLadmin" "password" "demo" SetOutPath "$SYSDIR" File /r "C:\Program Files\Achievo\Apache2\php\php4ts.dll" SetOutPath "$SMPROGRAMS\Achievo\" CreateDirectory "$SMPROGRAMS\Achievo\Apache\" CreateDirectory "$SMPROGRAMS\Achievo\Mysql\" CreateShortCut "$SMPROGRAMS\Achievo\Achievo_0_8_4.lnk" "$INSTDIR\Achievo 0.8.4.url" CreateShortCut "$SMPROGRAMS\Achievo\phpMyAdmin.lnk" "$INSTDIR\phpMyAdmin.url" CreateShortCut "$SMPROGRAMS\Achievo\Uninstall Achievo.lnk" "$INSTDIR\uninstall.exe" SetOutPath "$SMPROGRAMS\Achievo\Apache\" CreateShortCut "$SMPROGRAMS\Achievo\Apache\Apache Servers Monitor.lnk" "$INSTDIR\Apache2\bin\ApacheMonitor.exe" CreateShortCut "$SMPROGRAMS\Achievo\Apache\Apache - Restart.lnk" "$INSTDIR\Apache2\bin\Apache.exe" "-k restart" CreateShortCut "$SMPROGRAMS\Achievo\Apache\Apache - Start.lnk" "$INSTDIR\Apache2\bin\Apache.exe" "-k start" CreateShortCut "$SMPROGRAMS\Achievo\Apache\Apache - Stop.lnk" "$INSTDIR\Apache2\bin\Apache.exe" "-k stop" SetOutPath "$SMPROGRAMS\Achievo\Mysql\" CreateShortCut "$SMPROGRAMS\Achievo\Mysql\Mysql - Restart.lnk" "$INSTDIR\Apache2\mysql\bin\mysql-restart.bat" CreateShortCut "$SMPROGRAMS\Achievo\Mysql\Mysql - Start.lnk" "$INSTDIR\Apache2\mysql\bin\mysql-start.bat" CreateShortCut "$SMPROGRAMS\Achievo\Mysql\Mysql - Stop.lnk" "$INSTDIR\Apache2\mysql\bin\mysql-stop.bat" CreateShortCut "$SMPROGRAMS\Achievo\Mysql\WinMySqlAdmin.lnk" "$INSTDIR\Apache2\mysql\bin\winmysqladmin.exe" Exec '"$INSTDIR\Apache2\bin\Apache.exe" -k install -n Apache2' FileOpen $9 "$INSTDIR\Apache2\conf\httpd.conf" r GetTempFileName $R0 FileOpen $8 $R1 w loop: FileRead $9 $7 IfErrors done StrCmp $7 'LoadModule php4_module "c:\Program Files\Achievo\Apache2\php\sapi\php4apache2.dll "$\r$\n' 0 +3 FileWrite $8 'LoadModule php4_module "$INSTDIR\Apache2\php\sapi\php4apache2.dll "$\r$\n' Goto loop StrCpy $6 "$INSTDIR" StrCmp $6 "$INSTDIR" 0 +7 Push $6 Push "\" Push "/" Call StrReplace Pop $0 StrCpy $5 $0 Push $7 Push "C:/Program Files/Achievo" Push $5 Call StrReplace Pop $0 FileWrite $8 $0 Goto loop FileWrite $8 $7 Goto loop done: FileClose $9 FileClose $8 Delete "$INSTDIR\Apache2\conf\httpd.conf" Rename $R1 "$INSTDIR\Apache2\conf\httpd.conf" ; write out uninstaller WriteUninstaller "$INSTDIR\uninstall.exe" SectionEnd ; end of default section ; begin uninstall settings/section UninstallText "This will uninstall Achievo from your system" AutoCloseWindow true ShowInstDetails hide Section Uninstall ; add delete commands to delete whatever files/registry keys/etc you installed here. SetShellVarContext all Exec '"$INSTDIR\Apache2\bin\Apache.exe" -k stop' Exec '"$INSTDIR\Apache2\bin\Apache.exe" -k uninstall -n Apache2' Exec '"$INSTDIR\Apache2\mysql\bin\mysqladmin.exe" shutdown' ReadRegStr $0 HKLM SOFTWAREMicrosoftWindowsCurrentVersion VersionNumber StrCmp $0 "" nt windows nt: Exec '"$INSTDIR\Apache2\mysql\bin\mysqld-nt.exe" --remove' Goto next windows: Exec '"$INSTDIR\Apache2\mysql\bin\mysqld.exe" --remove' Goto next next: DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Achievo" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Achievo" Delete "$INSTDIR\uninstall.exe" RMDir /r "$SMPROGRAMS\Achievo" RMDir /r "$INSTDIR" Delete "$SYSDIR\php4ts.dll" Delete "$WINDIR\php.ini" Delete "$WINDIR\my.ini" RMDir /r "$TEMP\Achievo" SectionEnd ; end of uninstall section function StrReplace Exch $0 ;this will replace wrong characters Exch Exch $1 ;needs to be replaced Exch Exch 2 Exch $2 ;the orginal string Push $3 ;counter Push $4 ;temp character Push $5 ;temp string Push $6 ;length of string that need to be replaced Push $7 ;length of string that will replace Push $R0 ;tempstring Push $R1 ;tempstring Push $R2 ;tempstring StrCpy $3 "-1" StrCpy $5 "" StrLen $6 $1 StrLen $7 $0 Loop: IntOp $3 $3 + 1 StrCpy $4 $2 $6 $3 StrCmp $4 "" ExitLoop StrCmp $4 $1 Replace Goto Loop Replace: StrCpy $R0 $2 $3 IntOp $R2 $3 + $6 StrCpy $R1 $2 "" $R2 StrCpy $2 $R0$0$R1 IntOp $3 $3 + $7 Goto Loop ExitLoop: StrCpy $0 $2 Pop $R2 Pop $R1 Pop $R0 Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd Function .onInit StrCpy $9 0 ReadRegStr $9 HKLM "SOFTWARE\Achievo" "" StrCmp $9 "" NoAbort MessageBox MB_ICONEXCLAMATION|MB_YESNO "Achievo has already been installed.$\r$\n$\r$\nWould you like to Uninstall Achievo?" IDYES wait Abort wait: Exec "$INSTDIR\uninstall.exe" Abort NoAbort: FunctionEnd ;Function .onNextPage ; StrCmp $9 1 "" NoAbort ; MessageBox MB_ICONQUESTION|MB_YESNO "This will install Achievo.$\r$\n$\r$\nDo you wish to continue?" IDYES NoAbort ; Abort ; NoAbort: ; IntOp $9 $9 + 1 ;FunctionEnd Function .onInstSuccess ;MessageBox MB_ICONINFORMATION|MB_OK "Thanks for installing Achievo." Exec "$INSTDIR\Apache2\bin\apache-start.bat" Exec "$INSTDIR\Apache2\mysql\bin\mysql-start.bat" FunctionEnd Function un.onInit StrCpy $8 0 FunctionEnd Function un.onNextPage StrCmp $8 1 "" NoAbort MessageBox MB_ICONEXCLAMATION|MB_YESNO "This will uninstall Achievo. Do you wish to continue?" IDYES NoAbort Abort NoAbort: FunctionEnd Function un.onUninstSuccess RMDIR "$INSTDIR\" MessageBox MB_ICONINFORMATION|MB_OK "Thanks for using Achievo.$\r$\n http://www.achievo.org" FunctionEnd ; Script supplies two funcions: ; GetNextIp : get any IP (network and internet) ; CheckIP : determine IP type (see function header for available types) ; Script uses the VersionCheck ; function to test IP's. ; Code to use actual ExtensionDLL ; Current script provides an example ; Function GetNextIp ; input: head of stack ; format: 'ip1;ip2;ip3;ip4;' ; output: 'ip1' head of stack ; 'ip2;ip3;ip4;' second entry of stack Function GetNextIp Exch $0 Push $1 Push $2 Strcpy $2 0 ; Counter Loop: IntOp $2 $2 + 1 StrCpy $1 $0 1 $2 StrCmp $1 '' ExitLoop StrCmp $1 ';' '' Loop StrCpy $1 $0 $2 ; IP-address IntOp $2 $2 + 1 StrCpy $0 $0 '' $2 ; Remaining string ExitLoop: Pop $2 Push $0 Exch 2 Pop $0 Exch $1 FunctionEnd ; Function CheckIP ; input: IP-address on stack ; output: additional entry on stack ; 1 - LoopBack IP (localhost, indicates no connection to a LAN or to the internet). ; 2 - Automatic Private IP Address (no DHCP server). ; 3 - Network IP. ; 4 - Internet IP. ; Eg: ; Push '192.168.0.100' ; Call CheckIP ; Pop $0 ; Contains '3' ; Pop $1 ; Contains '192.168.0.100' Function CheckIP Exch $0 Push $1 ; Check 127.x.x.x Push '127.0.0.0' Push $0 Call VersionCheck Pop $1 StrCmp $1 2 '' Range1 ; IP cannot be in range of LoopBack addresses Push '127.255.255.255' Push $0 Call VersionCheck Pop $1 StrCmp $1 1 LoopBack ; We found a LoopBack IP ; Check 10.x.x.x Range1: Push '10.0.0.0' Push $0 Call VersionCheck Pop $1 StrCmp $1 2 '' Range2 ; IP cannot be in range 1 Push '10.255.255.255' Push $0 Call VersionCheck Pop $1 StrCmp $1 1 LanIp ; We found a LanIp ; Check 172.16.x.x to 172.31.x.x Range2: Push '172.16.0.0' Push $0 Call VersionCheck Pop $1 StrCmp $1 2 '' Range3 ; IP cannot be in range 2 Push '172.31.255.255' Push $0 Call VersionCheck Pop $1 StrCmp $1 1 LanIp ; We found a LanIp ; Check 192.168.x.x Range3: Push '192.168.0.0' Push $0 Call VersionCheck Pop $1 StrCmp $1 2 '' Range4 ; IP cannot be in range 3 Push '192.168.255.255' Push $0 Call VersionCheck Pop $1 StrCmp $1 1 LanIp ; We found a LanIp ; Check 169.254.x.x Range4: Push '169.254.0.0' Push $0 Call VersionCheck Pop $1 StrCmp $1 2 '' InternetIp ; It should be an internet IP Push '169.254.255.255' Push $0 Call VersionCheck Pop $1 StrCmp $1 1 APA ; We found an Automatic Private IP Address LoopBack: StrCpy $1 1 Goto Exit APA: StrCpy $1 2 Goto Exit LanIp: StrCpy $1 3 Goto Exit InternetIp: StrCpy $1 4 Exit: Exch $1 Exch 1 Exch $0 Exch 1 FunctionEnd ; Function VersionCheck ; input: 'v1', 'v2' on stack ; output 1 - if number 1 is newer ; 2 - if number 2 is newer ; 0 - if it is the same verion ; Eg: ; Push '3.5.1.4' ; Push '3.5' ; Call VersionCheck ; Pop $0 ; now contains 1 Function VersionCheck Exch $0 ;second versionnumber Exch Exch $1 ;first versionnumber Push $R0 ;counter for $0 Push $R1 ;counter for $1 Push $3 ;temp char Push $4 ;temp string for $0 Push $5 ;temp string for $1 StrCpy $R0 "-1" StrCpy $R1 "-1" Start: StrCpy $4 "" DotLoop0: IntOp $R0 $R0 + 1 StrCpy $3 $0 1 $R0 StrCmp $3 "" DotFound0 StrCmp $3 "." DotFound0 StrCpy $4 $4$3 Goto DotLoop0 DotFound0: StrCpy $5 "" DotLoop1: IntOp $R1 $R1 + 1 StrCpy $3 $1 1 $R1 StrCmp $3 "" DotFound1 StrCmp $3 "." DotFound1 StrCpy $5 $5$3 Goto DotLoop1 DotFound1: Strcmp $4 "" 0 Not4 StrCmp $5 "" Equal Goto Ver2Less Not4: StrCmp $5 "" Ver2More IntCmp $4 $5 Start Ver2Less Ver2More Equal: StrCpy $0 "0" Goto Finish Ver2Less: StrCpy $0 "1" Goto Finish Ver2More: StrCpy $0 "2" Finish: Pop $5 Pop $4 Pop $3 Pop $R1 Pop $R0 Pop $1 Exch $0 FunctionEnd ; eof