25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/translate.erl: Search translations directory in priv_dir

instead of lib_dir (thanks to Sergei Golovan)

* src/**/Makefile.in: Updated (thanks to Sergei Golovan)

* src/win32/: Win32 installer stuff (thanks to Sergei Golovan)

* src/**/Makefile.win32: Updated (thanks to Sergei Golovan)
* src/configure.bat: Likewise
* src/configure.erl: Likewise

* doc/guide.tex: Updated (thanks to Sergei Golovan)

SVN Revision: 226
This commit is contained in:
Alexey Shchepin 2004-04-27 20:28:23 +00:00
parent aaccaa5a45
commit 13f650037e
11 changed files with 825 additions and 40 deletions

View File

@ -1,3 +1,18 @@
2004-04-27 Alexey Shchepin <alexey@sevcom.net>
* src/translate.erl: Search translations directory in priv_dir
instead of lib_dir (thanks to Sergei Golovan)
* src/**/Makefile.in: Updated (thanks to Sergei Golovan)
* src/win32/: Win32 installer stuff (thanks to Sergei Golovan)
* src/**/Makefile.win32: Updated (thanks to Sergei Golovan)
* src/configure.bat: Likewise
* src/configure.erl: Likewise
* doc/guide.tex: Updated (thanks to Sergei Golovan)
2004-04-26 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Better design for administration

View File

@ -130,11 +130,10 @@ packages:
\item \footahref{http://www.erlang.org/download/otp_win32_R9C-0.exe}{Erlang emulator version~5.3}
\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_7.exe?download}{Expat~1.95.7}
\item
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-bin.exe?download}{Iconv~1.8
binaries} and
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-lib.exe?download}{Iconv~1.8
development libraries}
\footahref{http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.1.tar.gz}{Iconv~1.9.1}
(optional)
\item \footahref{http://www.slproweb.com/download/Win32OpenSSL-v0.9.7d.exe}{Shining Light OpenSSL}
(to enable SSL connections)
\end{itemize}
@ -169,31 +168,25 @@ TBD
\label{sec:compilationwin}
\begin{enumerate}
\item Install Erlang emulator (for example, into \verb|C:\Program Files\erl5.1.2|).
\item Install Expat library into \verb|C:\Program Files\Expat-1.95.6|
directory. Copy file \verb|C:\Program Files\Expat-1.95.6\Libs\libexpat.dll|
\item Install Erlang emulator (for example, into \verb|C:\Program Files\erl5.3|).
\item Install Expat library into \verb|C:\Program Files\Expat-1.95.7|
directory. Copy file \verb|C:\Program Files\Expat-1.95.7\Libs\libexpat.dll|
to your Windows system directory (for example, \verb|C:\WINNT| or
\verb|C:\WINNT\System32|)
\item Install Iconv library into \verb|C:\Program Files\GnuWin32| directory.
Copy file \verb|C:\Program Files\GnuWin32\bin\libiconv-2.dll| to your
\item Build and install Iconv library into \verb|C:\Program Files\iconv-1.9.1| directory.
Copy file \verb|C:\Program Files\iconv-1.9.1\bin\iconv.dll| to your
Windows system directory.
Note: Instead of copying libexpat.dll and libiconv-2.dll to Windows
Note: Instead of copying libexpat.dll and iconv.dll to Windows
directory, you can add directories
\verb|C:\Program Files\Expat-1.95.6\Libs| and
\verb|C:\Program Files\GnuWin32\bin| to \verb|PATH| environment
\verb|C:\Program Files\Expat-1.95.7\Libs| and
\verb|C:\Program Files\iconv-1.9.1\bin| to \verb|PATH| environment
variable.
\item Being in \verb|ejabberd\src| directory run:
\begin{verbatim}
configure
nmake -f Makefile.win32
\end{verbatim}
\item To build MUC, IRC and pub/sub modules run
\begin{verbatim}
nmake -f Makefile.win32
\end{verbatim}
in \verb|ejabberd\src\mod_muc|, \verb|ejabberd\src\mod_muc| and
\verb|ejabberd\src\mod_pubsub| directories
\item Edit file \verb|ejabberd\src\ejabberd.cfg| and run
\begin{verbatim}
werl -s ejabberd -name ejabberd
@ -201,14 +194,6 @@ werl -s ejabberd -name ejabberd
\item Enjoy!
\end{enumerate}
Some recent versions of Erlang distribution it seems have bug in crypto
application, so ejabberd could be built but users can't use digest
authentication (only plain-text). Also it seems SSL support is broken in
Windows distribution of Erlang emulator.
%\subsection{Initial Configuration}
%\label{sec:initconfig}

View File

@ -1,8 +1,6 @@
include Makefile.inc
EXPAT_DIR="c:\progra~1\expat-1.95.7"
ALL : build
REL=..\release
@ -12,8 +10,20 @@ MSGS_DIR=$(EREL)\msgs
SRC_DIR=$(EREL)\src
PRIV_DIR=$(EREL)\priv
SO_DIR=$(PRIV_DIR)\lib
WIN32_DIR=$(EREL)\win32
DOC_DIR=$(EREL)\doc
NSIS_SCRIPT=win32\ejabberd.nsi
NSIS_HEADER=win32\ejabberd.nsh
installer : $(NSIS_SCRIPT) $(NSIS_HEADER)
makensis $(NSIS_SCRIPT)
$(NSIS_HEADER) : Makefile.inc
echo !define OUTFILEDIR "..\$(REL)" >$(NSIS_HEADER)
echo !define TESTDIR "..\$(REL)\ejabberd-$(EJABBERD_VERSION)" >>$(NSIS_HEADER)
echo !define VERSION "$(EJABBERD_VERSION)" >>$(NSIS_HEADER)
release_clean :
if exist $(REL) rd /s /q $(REL)
@ -29,6 +39,11 @@ release : build release_clean
copy *.dll $(SO_DIR)
mkdir $(MSGS_DIR)
copy msgs\*.msg $(MSGS_DIR)
mkdir $(WIN32_DIR)
copy win32\ejabberd.cfg $(EREL)
copy win32\ejabberd.ico $(WIN32_DIR)
mkdir $(WIN32_DIR)\5.3
copy win32\5.3\*.beam $(WIN32_DIR)\5.3
mkdir $(SRC_DIR)
copy *.app $(SRC_DIR)
copy *.erl $(SRC_DIR)
@ -50,6 +65,9 @@ release : build release_clean
copy stringprep\*.tcl $(SRC_DIR)\stringprep
mkdir $(SRC_DIR)\web
copy web\*.erl $(SRC_DIR)\web
mkdir $(SRC_DIR)\win32
mkdir $(SRC_DIR)\win32\5.3
copy win32\5.3\*.erl $(SRC_DIR)\win32\5.3
mkdir $(DOC_DIR)
copy ..\doc\*.html $(DOC_DIR)
copy ..\doc\*.png $(DOC_DIR)
@ -73,7 +91,9 @@ all-recursive :
nmake -nologo -f Makefile.win32
cd ..\web
nmake -nologo -f Makefile.win32
cd ..
cd ..\win32\5.3
nmake -nologo -f Makefile.win32
cd ..\..
compile-beam :
erl -s make all report -noinput -s erlang halt
@ -100,16 +120,18 @@ clean-recursive :
nmake -nologo -f Makefile.win32 clean
cd ..\web
nmake -nologo -f Makefile.win32 clean
cd ..
cd ..\win32\5.3
nmake -nologo -f Makefile.win32 clean
cd ..\..
distclean : release_clean clean
-@erase Makefile.inc
CC=cl.exe
CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(EXPAT_DIR)\source\lib"
CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT $(EXPAT_FLAG) -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(EXPAT_DIR)\source\lib"
LD=link.exe
LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(EXPAT_DIR)\libs\libexpat.lib" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib
LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(EXPAT_LIB)" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib
$(DLL) : $(OBJECT)
$(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT)

View File

@ -1,4 +1,20 @@
@if "x%1"=="x--help" goto usage
@set arg=dynamic
@if "x%1"=="x--static" set arg=static
@echo Configuring for %arg% build...
erlc configure.erl
erl -s configure -noshell
erl -s configure -env arg %arg% -noshell
@goto end
:usage
@echo Usage: configure.bat
@echo or configure.bat --static
@echo or configure.bat --help
:end

View File

@ -15,11 +15,46 @@
-include("ejabberd.hrl").
start() ->
Static = case os:getenv("arg") of
false ->
false;
"static" ->
true;
_ ->
false
end,
case Static of
true ->
ExpatLib = "EXPAT_LIB = $(EXPAT_DIR)\\StaticLibs\\libexpatMT.lib\n",
ExpatFlag = "EXPAT_FLAG = -DXML_STATIC\n",
IconvDir = "ICONV_DIR = c:\\progra~1\\libiconv-1.9.1-static\n",
IconvLib = "ICONV_LIB = $(ICONV_DIR)\\lib\\iconv.lib\n";
false ->
ExpatLib = "EXPAT_LIB = $(EXPAT_DIR)\\Libs\\libexpat.lib\n",
ExpatFlag = "",
IconvDir = "ICONV_DIR = c:\\progra~1\\libiconv-1.9.1\n",
IconvLib = "ICONV_LIB = $(ICONV_DIR)\\lib\\iconv.lib\n"
end,
EIDirS = "EI_DIR = " ++ code:lib_dir("erl_interface") ++ "\n",
RootDirS = "ERLANG_DIR = " ++ code:root_dir() ++ "\n",
Version = "EJABBERD_VERSION = " ++ ?VERSION ++ "\n",
ExpatDir = "EXPAT_DIR = c:\\progra~1\\expat-1.95.7\n",
SSLDir = "SSLDIR = " ++ code:lib_dir("ssl") ++ "\n",
StdLibDir = "STDLIBDIR = " ++ code:lib_dir("stdlib") ++ "\n",
file:write_file("Makefile.inc",
list_to_binary(EIDirS ++ RootDirS ++ Version)),
list_to_binary(EIDirS ++
RootDirS ++
Version ++
SSLDir ++
StdLibDir ++
ExpatDir ++
ExpatLib ++
ExpatFlag ++
IconvDir ++
IconvLib)),
halt().

View File

@ -1,8 +1,6 @@
include ..\Makefile.inc
GNUWIN_DIR="c:\progra~1\gnuwin32"
OUTDIR = ..
EFLAGS = -I .. -pz ..
@ -34,10 +32,10 @@ $(OUTDIR)\mod_irc_connection.beam : mod_irc_connection.erl
erlc -W $(EFLAGS) -o $(OUTDIR) mod_irc_connection.erl
CC=cl.exe
CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(GNUWIN_DIR)\include"
CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(ICONV_DIR)\include"
LD=link.exe
LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib
LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(ICONV_LIB)" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib
$(DLL) : $(OBJECT)
$(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT)

11
src/win32/CheckReqs.ini Normal file
View File

@ -0,0 +1,11 @@
[Settings]
NumFields=1
[Field 1]
Type=label
Left=0
Right=-1
Top=10
Bottom=-10
Text="Erlang OTP R9C (version 5.3) is required to install Ejabberd.\r\n\r\nIt is not found on your computer.\r\n\r\nPlease install Erlang OTP R9C before installing Ejabberd.\r\n\r\nIt can be downloaded from http://www.erlang.org/download/otp_win32_R9C-0.exe."

11
src/win32/CheckUser.ini Normal file
View File

@ -0,0 +1,11 @@
[Settings]
NumFields=1
[Field 1]
Type=label
Left=0
Right=-1
Top=10
Bottom=-10
Text="Administrator privileges are recommended for Ejabberd install.\r\n\r\nOtherwise installing Ejabberd as a service will be impossible.\r\n\r\nIf you want to continue installation anyway, click Next."

129
src/win32/ejabberd.cfg Normal file
View File

@ -0,0 +1,129 @@
% $Id$
%override_acls.
% Users that have admin access. Add line like one of the following after you
% will be successfully registered on server to get admin access:
%{acl, admin, {user, "aleksey"}}.
%{acl, admin, {user, "ermine"}}.
% Blocked users:
%{acl, blocked, {user, "test"}}.
% Local users:
{acl, local, {user_regexp, ""}}.
% Another examples of ACLs:
%{acl, jabberorg, {server, "jabber.org"}}.
%{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
%{acl, test, {user_regexp, "^test"}}.
%{acl, test, {user_glob, "test*"}}.
% Only admins can use configuration interface:
{access, configure, [{allow, admin}]}.
% Every username can be registered via in-band registration:
{access, register, [{allow, all}]}.
% After successful registration user will get message with following subject
% and body:
{welcome_message,
{"Welcome!",
"Welcome to Jabber Service. "
"For information about Jabber visit http://jabber.org"}}.
% Replace them with 'none' if you don't want to send such message:
%{welcome_message, none}.
% List of people who will get notifications about registered users
%{registration_watchers, ["admin1@localhost",
% "admin2@localhost"]}.
% Only admins can send announcement messages:
{access, announce, [{allow, admin}]}.
% Only non-blocked users can use c2s connections:
{access, c2s, [{deny, blocked},
{allow, all}]}.
% Set shaper with name "normal" to limit traffic speed to 1000B/s
{shaper, normal, {maxrate, 1000}}.
% Set shaper with name "fast" to limit traffic speed to 50000B/s
{shaper, fast, {maxrate, 50000}}.
% For all users except admins used "normal" shaper
{access, c2s_shaper, [{none, admin},
{normal, all}]}.
% For all S2S connections used "fast" shaper
{access, s2s_shaper, [{fast, all}]}.
% Admins of this server are also admins of MUC service:
{access, muc_admin, [{allow, admin}]}.
% This rule allows access only for local users:
{access, local, [{allow, local}]}.
% Authentification method. If you want to use internal user base, then use
% this line:
{auth_method, internal}.
% For LDAP uthentification use these lines instead of above one:
%{auth_method, ldap}.
%{ldap_servers, ["localhost"]}. % List of LDAP servers
%{ldap_uidattr, "uid"}. % LDAP attribute that holds user ID
%{ldap_base, "dc=example,dc=com"}. % Base of LDAP directory
% Host name:
{host, "localhost"}.
% Listened ports:
{listen, [{5222, ejabberd_c2s, [{access, c2s},
{shaper, c2s_shaper}]},
% {5223, ejabberd_c2s, [{access, c2s},
% {ssl, [{certfile, "./cert.pem"}]}]},
{5269, ejabberd_s2s_in, [{shaper, s2s_shaper}]}%,
% {5555, ejabberd_service, [{host, "icq.localhost", [{password, "someSecret"}]}]},
% {8888, ejabberd_service, [%{access, local},
% {hosts,
% ["conference.e.localhost",
% "muc.e.localhost"],
% [{password, "secret"}]}]}
]}.
% If SRV lookup fails, then port 5269 is used to communicate with remote server
{outgoing_s2s_port, 5269}.
% Used modules:
{modules, [
{mod_register, []},
{mod_roster, []},
{mod_privacy, []},
{mod_configure, []},
{mod_disco, []},
{mod_stats, []},
{mod_vcard, []},
{mod_offline, []},
{mod_echo, [{host, "echo.localhost"}]},
{mod_private, []},
{mod_irc, []},
{mod_muc, []},
{mod_pubsub, []},
{mod_time, []},
{mod_last, []},
{mod_version, []}
]}.
% Local Variables:
% mode: erlang
% End:

BIN
src/win32/ejabberd.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

563
src/win32/ejabberd.nsi Normal file
View File

@ -0,0 +1,563 @@
; NSIS Modern User Interface
; Ejabberd installation script
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "ejabberd.nsh" ; All release specific parameters come from this
;--------------------------------
;General
;Name and file
!define PRODUCT "Ejabberd"
Name ${PRODUCT}
OutFile "${OUTFILEDIR}\${PRODUCT}-${VERSION}.exe"
!define MUI_ICON "ejabberd.ico"
!define MUI_UNICON "ejabberd.ico"
;--------------------------------
;Configuration
SetCompressor lzma
;--------------------------------
;Reserve Files
ReserveFile "CheckUser.ini"
ReserveFile "CheckReqs.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;--------------------------------
;Variables
Var MUI_TEMP
Var STARTMENU_FOLDER
Var ADMIN
Var ERLANG_PATH
Var ERLANG_VERSION
Var REQUIRED_ERLANG_VERSION
Var ERLSRV
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
Page custom CheckUser LeaveCheckUser
!insertmacro MUI_PAGE_LICENSE "..\..\COPYING"
Page custom CheckReqs LeaveCheckReqs
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU ${PRODUCT} $STARTMENU_FOLDER
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Language Strings
;Description
LangString DESC_SecEjabberd ${LANG_ENGLISH} "Erlang jabber server."
;--------------------------------
;Installer Sections
Section "Ejabberd" SecEjabberd
SectionIn 1 RO
SetOutPath "$INSTDIR"
File /r "${TESTDIR}\doc"
File /r "${TESTDIR}\ebin"
File /r "${TESTDIR}\msgs"
File /r "${TESTDIR}\priv"
File /r "${TESTDIR}\win32"
SetOverwrite off
File "${TESTDIR}\ejabberd.cfg"
SetOverwrite on
;File /r "${TESTDIR}\src"
CreateDirectory "$INSTDIR\log"
;The startmenu stuff
!insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT}
;Create shortcuts
StrCpy $0 "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateDirectory "$0"
CreateShortCut "$0\Start Ejabberd.lnk" "$ERLANG_PATH\bin\werl.exe" \
'-sname ejabberd -pa ebin -pa win32/$ERLANG_VERSION \
-env EJABBERD_SO_PATH priv/lib -env EJABBERD_MSGS_PATH msgs \
-env EJABBERD_LOG_PATH log/ejabberd.log \
-s ejabberd -ejabberd config \"ejabberd.cfg\" -mnesia dir \"spool\"' \
$INSTDIR\win32\ejabberd.ico
CreateShortCut "$0\Edit Config.lnk" "%SystemRoot%\system32\notepad.exe" \
"$INSTDIR\ejabberd.cfg"
CreateShortCut "$0\Read Docs.lnk" "$INSTDIR\doc\guide.html"
CreateShortCut "$0\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END
;Create Windows service
StrCmp $ADMIN 1 0 skipservice
StrCpy $ERLSRV ""
Push $ERLANG_PATH
Push erlsrv.exe
GetFunctionAddress $0 FFCallback
Push $0
Call FindFiles
StrCmp $ERLSRV "" skipservice
nsExec::ExecToLog '"$ERLSRV" remove ejabberd'
Pop $0
nsExec::ExecToLog '"$ERLSRV" add ejabberd -stopaction "init:stop()." \
-onfail reboot -workdir "$INSTDIR" \
-args "-s ejabberd -pa ebin -pa win32/$ERLANG_VERSION \
-ejabberd config \\\"ejabberd.cfg\\\" \
-env EJABBERD_SO_PATH priv/lib -env EJABBERD_MSGS_PATH msgs \
-env EJABBERD_LOG_PATH log/ejabberd.log \
-sasl sasl_error_logger {file,\\\"log/sasl.log\\\"} \
-mnesia dir \\\"spool\\\"" -d'
Pop $0
nsExec::ExecToLog '"$ERLSRV" disable ejabberd'
skipservice:
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
StrCpy $1 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
StrCmp $ADMIN 1 admin2
WriteRegStr HKCU "Software\${PRODUCT}" "" "$INSTDIR"
WriteRegStr HKCU "$1" "DisplayName" "${PRODUCT} ${VERSION}"
WriteRegStr HKCU "$1" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegDWORD HKCU "$1" "NoModify" 1
WriteRegDWORD HKCU "$1" "NoRepair" 1
Goto done2
admin2:
WriteRegStr HKLM "Software\${PRODUCT}" "" "$INSTDIR"
WriteRegStr HKLM "Software\${PRODUCT}" "Erlsrv" "$ERLSRV"
WriteRegStr HKLM "$1" "DisplayName" "${PRODUCT} ${VERSION}"
WriteRegStr HKLM "$1" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegDWORD HKLM "$1" "NoModify" 1
WriteRegDWORD HKLM "$1" "NoRepair" 1
done2:
SectionEnd ; SecEjabberd
Function FFCallback
Exch $0
StrCpy $ERLSRV $0
Pop $0
Push "stop"
FunctionEnd
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecEjabberd} $(DESC_SecEjabberd)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
ClearErrors
UserInfo::GetName
IfErrors admin
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" admin
StrCpy $ADMIN 0
Goto skipservice
admin:
StrCpy $ADMIN 1
ReadRegStr $ERLSRV HKLM "Software\${PRODUCT}" "Erlsrv"
nsExec::ExecToLog '"$ERLSRV" remove ejabberd'
Pop $0
skipservice:
RMDir /r "$INSTDIR\doc"
RMDir /r "$INSTDIR\ebin"
RMDir /r "$INSTDIR\msgs"
RMDir /r "$INSTDIR\priv"
RMDir /r "$INSTDIR\win32"
;RMDir /r "$INSTDIR\src"
RMDir /r "$INSTDIR\log"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER ${PRODUCT} $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\Start Ejabberd.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Edit Config.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Read Docs.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
;Delete empty start menu parent diretories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
startMenuDeleteLoop:
RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors startMenuDeleteLoopDone
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
StrCpy $1 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
StrCmp $ADMIN 1 admin1
DeleteRegKey HKCU "Software\${PRODUCT}"
DeleteRegKey HKCU $1
Goto done
admin1:
DeleteRegKey HKLM "Software\${PRODUCT}"
DeleteRegKey HKLM $1
done:
SectionEnd
Function .onInit
StrCpy $REQUIRED_ERLANG_VERSION "5.3"
;Default installation folder
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT}"
;Get installation folder from registry if available
ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\${PRODUCT}" ""
IfErrors 0 copydir
ReadRegStr $0 HKCU "SOFTWARE\${PRODUCT}" ""
IfErrors skipdir
copydir:
StrCpy $INSTDIR "$0"
skipdir:
;Extract InstallOptions INI files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckUser.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckReqs.ini"
FunctionEnd
LangString TEXT_CU_TITLE ${LANG_ENGLISH} "Checking User Privileges"
LangString TEXT_CU_SUBTITLE ${LANG_ENGLISH} "Checking user privileged required to install Ejabberd."
Function CheckUser
ClearErrors
UserInfo::GetName
IfErrors Abort
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" Abort User
Abort:
StrCpy $ADMIN 1
Abort
User:
StrCpy $ADMIN 0
!insertmacro MUI_HEADER_TEXT $(TEXT_CU_TITLE) $(TEXT_CU_SUBTITLE)
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckUser.ini"
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
Function LeaveCheckUser
FunctionEnd
LangString TEXT_CR_TITLE ${LANG_ENGLISH} "Unsatisfied Requirements"
LangString TEXT_CR_SUBTITLE ${LANG_ENGLISH} "Unsatisfied Ejabberd requirements found."
Function CheckReqs
Push "HKLM"
Call FindErlang
Pop $ERLANG_PATH
Pop $ERLANG_VERSION
StrCmp $ERLANG_PATH "" 0 abort
Push "HKCU"
Call FindErlang
Pop $ERLANG_PATH
Pop $ERLANG_VERSION
StrCmp $ERLANG_PATH "" 0 abort
!insertmacro MUI_HEADER_TEXT $(TEXT_CR_TITLE) $(TEXT_CR_SUBTITLE)
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs.ini"
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
!insertmacro MUI_INSTALLOPTIONS_SHOW
abort:
Abort
FunctionEnd
Function LeaveCheckReqs
Abort
FunctionEnd
Function FindErlang
Exch $R0
Push $R1
Push $R2
Push $R3
Push $R4
Push $R5
StrCpy $R1 0
StrCpy $R2 "SOFTWARE\Ericsson\Erlang"
loop:
StrCmp $R0 HKLM h1
EnumRegKey $R3 HKCU $R2 $R1
Goto l1
h1:
EnumRegKey $R3 HKLM $R2 $R1
l1:
IntOp $R1 $R1 + 1
StrCmp $R3 "" endloop
ClearErrors
StrCmp $R0 HKLM h2
ReadRegStr $R4 HKCU "$R2\$R3" ""
Goto l2
h2:
ReadRegStr $R4 HKLM "$R2\$R3" ""
l2:
IfFileExists "$R4\bin\erl.exe" 0 loop
Push $REQUIRED_ERLANG_VERSION
Push $R3
Call CompareVersions
Pop $R5
StrCmp $R5 1 get
Goto loop
endloop:
StrCpy $R4 ""
get:
StrCpy $R0 $R4
StrCpy $R1 $R3
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
Exch
Exch $R0
FunctionEnd
;----------------------------------------------------------------------
; CompareVersions
; input:
; top of stack = existing version
; top of stack-1 = needed version
; output:
; top of stack = 1 if current version => neded version, else 0
; version is a string in format "xx.xx.xx.xx" (number of interger sections
; can be different in needed and existing versions)
Function CompareVersions
; stack: existing ver | needed ver
Exch $R0
Exch
Exch $R1
; stack: $R1|$R0
Push $R1
Push $R0
; stack: e|n|$R1|$R0
ClearErrors
loop:
IfErrors VersionNotFound
Strcmp $R0 "" VersionTestEnd
Call ParseVersion
Pop $R0
Exch
Call ParseVersion
Pop $R1
Exch
IntCmp $R1 $R0 +1 VersionOk VersionNotFound
Pop $R0
Push $R0
goto loop
VersionTestEnd:
Pop $R0
Pop $R1
Push $R1
Push $R0
StrCmp $R0 $R1 VersionOk VersionNotFound
VersionNotFound:
StrCpy $R0 "0"
Goto end
VersionOk:
StrCpy $R0 "1"
end:
; stack: e|n|$R1|$R0
Exch $R0
Pop $R0
Exch $R0
; stack: res|$R1|$R0
Exch
; stack: $R1|res|$R0
Pop $R1
; stack: res|$R0
Exch
Pop $R0
; stack: res
FunctionEnd
;-----------------------------------------------------------------------
; ParseVersion
; input:
; top of stack = version string ("xx.xx.xx.xx")
; output:
; top of stack = first number in version ("xx")
; top of stack-1 = rest of the version string ("xx.xx.xx")
Function ParseVersion
Exch $R1 ; version
Push $R2
Push $R3
StrCpy $R2 1
loop:
StrCpy $R3 $R1 1 $R2
StrCmp $R3 "." loopend
StrLen $R3 $R1
IntCmp $R3 $R2 loopend loopend
IntOp $R2 $R2 + 1
Goto loop
loopend:
Push $R1
StrCpy $R1 $R1 $R2
Exch $R1
StrLen $R3 $R1
IntOp $R3 $R3 - $R2
IntOp $R2 $R2 + 1
StrCpy $R1 $R1 $R3 $R2
Push $R1
Exch 2
Pop $R3
Exch 2
Pop $R2
Exch 2
Pop $R1
FunctionEnd
Function FindFiles
Exch $R5 # callback function
Exch
Exch $R4 # file name
Exch 2
Exch $R0 # directory
Push $R1
Push $R2
Push $R3
Push $R6
Push $R0 # first dir to search
StrCpy $R3 1
nextDir:
Pop $R0
IntOp $R3 $R3 - 1
ClearErrors
FindFirst $R1 $R2 "$R0\*.*"
nextFile:
StrCmp $R2 "." gotoNextFile
StrCmp $R2 ".." gotoNextFile
StrCmp $R2 $R4 0 isDir
Push "$R0\$R2"
Call $R5
Pop $R6
StrCmp $R6 "stop" 0 isDir
loop:
StrCmp $R3 0 done
Pop $R0
IntOp $R3 $R3 - 1
Goto loop
isDir:
IfFileExists "$R0\$R2\*.*" 0 gotoNextFile
IntOp $R3 $R3 + 1
Push "$R0\$R2"
gotoNextFile:
FindNext $R1 $R2
IfErrors 0 nextFile
done:
FindClose $R1
StrCmp $R3 0 0 nextDir
Pop $R6
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Pop $R5
Pop $R4
FunctionEnd