Commit ed03b793 by Belákovics Ádám

added multi user support (thx to szebi)

parent 402cfbde
;NSIS Modern User Interface ;NSIS Modern User Interface
;Multilingual Cloud Installer Script ;Multilingual Cloud Installer Script
;Written by Csk Tams ;Written by Cs�k Tam�s and Bel�kovics �d�m
;--------------------------------
; MultiUser install setup
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
;-------------------------------- ;--------------------------------
;Include Modules ;Include Modules
!include "MultiUser.nsh"
!include "MUI2.nsh" !include "MUI2.nsh"
!include "LogicLib.nsh" !include "LogicLib.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
...@@ -18,15 +26,15 @@ ...@@ -18,15 +26,15 @@
!define AppUninstaller "Uninstall.exe" !define AppUninstaller "Uninstall.exe"
!define IconName "cloud" !define IconName "cloud"
!define Show_output "True" !define Show_output "True"
!define DefaulLocation "$LOCALAPPDATA\CIRCLE" !define DefaulLocation "$PROGRAMFILES\CIRCLE"
!define LowestSupportedPythonVersion "6" !define LowestSupportedPythonVersion "6"
!define HighestSupportedPythonVersion "7" !define HighestSupportedPythonVersion "7"
!define LogInformationTime 2000 !define LogInformationTime 2000
;String manipulations ;String manipulations
!define Explode "!insertmacro Explode" !define Explode "!insertmacro Explode"
!define StrCase "!insertmacro StrCase" !define StrCase2 "!insertmacro StrCase2"
!define StrTrimNewLines "!insertmacro StrTrimNewLines" !define StrTrimNewLines2 "!insertmacro StrTrimNewLines2"
;-------------------------------- ;--------------------------------
;General ;General
!macro Explode Length Separator String !macro Explode Length Separator String
...@@ -35,19 +43,19 @@ ...@@ -35,19 +43,19 @@
Call Explode Call Explode
Pop '${Length}' Pop '${Length}'
!macroend !macroend
!macro StrCase ResultVar String Case !macro StrCase2 ResultVar String Case
Push "${String}" Push "${String}"
Push "${Case}" Push "${Case}"
Call StrCase Call StrCase2
Pop "${ResultVar}" Pop "${ResultVar}"
!macroend !macroend
!macro StrTrimNewLines ResultVar String !macro StrTrimNewLines2 ResultVar String
Push "${String}" Push "${String}"
Call StrTrimNewLines Call StrTrimNewLines2
Pop "${ResultVar}" Pop "${ResultVar}"
!macroend !macroend
;Properly display all languages (Installer will not work on Windows 95, 98 or ME!) ;Properly display all languages (Installer will not work on Windows 95, 98 or ME!)
Unicode true ; Unicode true
;Name and file ;Name and file
Name "${Company} ${AppName}" Name "${Company} ${AppName}"
...@@ -91,6 +99,7 @@ ...@@ -91,6 +99,7 @@
;Pages ;Pages
!insertmacro MUI_PAGE_LICENSE "gpl-3.0.txt" !insertmacro MUI_PAGE_LICENSE "gpl-3.0.txt"
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
;Done fuction to launch install.bat ;Done fuction to launch install.bat
...@@ -116,7 +125,7 @@ ...@@ -116,7 +125,7 @@
LangString NAME_Install ${LANG_HUNGARIAN} "Komponensek" LangString NAME_Install ${LANG_HUNGARIAN} "Komponensek"
LangString NAME_Functions ${LANG_ENGLISH} "Functions" LangString NAME_Functions ${LANG_ENGLISH} "Functions"
LangString NAME_Functions ${LANG_HUNGARIAN} "Funkcik" LangString NAME_Functions ${LANG_HUNGARIAN} "Funkcik"
;CIRCLE Client (SecInstall) ;CIRCLE Client (SecInstall)
;NAME ;NAME
...@@ -127,53 +136,53 @@ ...@@ -127,53 +136,53 @@
LangString DESC_SecInstall ${LANG_ENGLISH} "Install the core of the CIRCLE Client.$\r$\n\ LangString DESC_SecInstall ${LANG_ENGLISH} "Install the core of the CIRCLE Client.$\r$\n\
Used for [RDP / SSH] type of connections.$\r$\n\ Used for [RDP / SSH] type of connections.$\r$\n\
Automates all installed, third party connection tools." Automates all installed, third party connection tools."
LangString DESC_SecInstall ${LANG_HUNGARIAN} "A CIRCLE Kliens alapjnak teleptse.$\r$\n\ LangString DESC_SecInstall ${LANG_HUNGARIAN} "A CIRCLE Kliens alapj�nak telep�t�se.$\r$\n\
[RDP / SSH] fle kapcsolatokhoz hasznlt.$\r$\n\ [RDP / SSH] f�le kapcsolatokhoz haszn�lt.$\r$\n\
Automatizlja az installlt, harmadik fltl szrmaz szoftverek hasznlatt." Automatiz�lja az install�lt, harmadik f�lt�l sz�rmaz� szoftverek haszn�lat�t."
;Python search (PythonLookup) ;Python search (PythonLookup)
;NAME ;NAME
LangString NAME_PythonLookup ${LANG_ENGLISH} "Search Python" LangString NAME_PythonLookup ${LANG_ENGLISH} "Search Python"
LangString NAME_PythonLookup ${LANG_HUNGARIAN} "Python keress" LangString NAME_PythonLookup ${LANG_HUNGARIAN} "Python keress"
;DESC ;DESC
LangString DESC_PythonLookup ${LANG_ENGLISH} "Use ONLY if necessary!$\r$\n\ LangString DESC_PythonLookup ${LANG_ENGLISH} "Use ONLY if necessary!$\r$\n\
Search the filesystem for Python installation. Usefull when Python was installed without accessing registry before.$\r$\n\ Search the filesystem for Python installation. Usefull when Python was installed without accessing registry before.$\r$\n\
Installation will take more time." Installation will take more time."
LangString DESC_PythonLookup ${LANG_HUNGARIAN} "Csak szksg esetn!$\r$\n\ LangString DESC_PythonLookup ${LANG_HUNGARIAN} "Csak sz�ks�g eset�n!$\r$\n\
A fjlrendszer keresse Python utn. Hasznos, ha a Python-t Registry nlkli opcival lett teleptve korbban.$\r$\n\ A f�jlrendszer keres�se Python ut�n. Hasznos, ha a Python-t Registry n�lk�li opci�val lett telep�tve kor�bban.$\r$\n\
A teleptst jelentsen lelasstja." A telep�t�st jelent�sen lelass�tja."
;STATUS ;STATUS
LangString STATUS_PythonSearch ${LANG_ENGLISH} "Searching for Python. This could take some time. Looking at drive:" LangString STATUS_PythonSearch ${LANG_ENGLISH} "Searching for Python. This could take some time. Looking at drive:"
LangString STATUS_PythonSearch ${LANG_HUNGARIAN} "Python keresse a fjlrendszerben. Ez eltarthat egy darabig. Keress alapja:" LangString STATUS_PythonSearch ${LANG_HUNGARIAN} "Python keres�se a f�jlrendszerben. Ez eltarthat egy darabig. Keres�s alapja:"
LangString STATUS_PythonFound ${LANG_ENGLISH} "Python found at " LangString STATUS_PythonFound ${LANG_ENGLISH} "Python found at "
LangString STATUS_PythonFound ${LANG_HUNGARIAN} "Python megtallva az albbi knyvtrban: " LangString STATUS_PythonFound ${LANG_HUNGARIAN} "Python megtal�lva az al�bbi k�nyvt�rban: "
LangString STATUS_PythonVersionSearch ${LANG_ENGLISH} "Determining Python version." LangString STATUS_PythonVersionSearch ${LANG_ENGLISH} "Determining Python version."
LangString STATUS_PythonVersionSearch ${LANG_HUNGARIAN} "Teleptett Python verzi kidertse." LangString STATUS_PythonVersionSearch ${LANG_HUNGARIAN} "Telep�tett Python verzi� kider�t�se."
LangString STATUS_PythonVersionFound ${LANG_ENGLISH} "Installed Python version is:" LangString STATUS_PythonVersionFound ${LANG_ENGLISH} "Installed Python version is:"
LangString STATUS_PythonVersionFound ${LANG_HUNGARIAN} "A teleptett Python verzija:" LangString STATUS_PythonVersionFound ${LANG_HUNGARIAN} "A telep�tett Python verzi�ja:"
LangString STATUS_PythonArchitectSearch ${LANG_ENGLISH} "Deteremining installed Python mode (32bit or 64bit)." LangString STATUS_PythonArchitectSearch ${LANG_ENGLISH} "Deteremining installed Python mode (32bit or 64bit)."
LangString STATUS_PythonArchitectSearch ${LANG_HUNGARIAN} "Installlt Python futtatsi mdjnak kidertse (32bit vagy 64bit)." LangString STATUS_PythonArchitectSearch ${LANG_HUNGARIAN} "Install�lt Python futtat�si m�dj�nak kider�t�se (32bit vagy 64bit)."
LangString STATUS_PythonArchitectFound ${LANG_ENGLISH} "Installed Python mode is:" LangString STATUS_PythonArchitectFound ${LANG_ENGLISH} "Installed Python mode is:"
LangString STATUS_PythonArchitectFound ${LANG_HUNGARIAN} "A teleptett Python mdja:" LangString STATUS_PythonArchitectFound ${LANG_HUNGARIAN} "A telep�tett Python m�dja:"
LangString STATUS_PythonNotSupported ${LANG_ENGLISH} "The installed Python version is not supported!$\r$\n\ LangString STATUS_PythonNotSupported ${LANG_ENGLISH} "The installed Python version is not supported!$\r$\n\
To procede please uninstall Python first." To procede please uninstall Python first."
LangString STATUS_PythonNotSupported ${LANG_HUNGARIAN} "A felteleptett Python verzija nem tmogatott!$\r$\n\ LangString STATUS_PythonNotSupported ${LANG_HUNGARIAN} "A feltelep�tett Python verzi�ja nem t�mogatott!$\r$\n\
A sikeres teleptshez el kell elbb tvoltania a Python-t." A sikeres telep�t�shez el kell el�bb t�vol�tania a Python-t."
LangString STATUS_PythonNotFound ${LANG_ENGLISH} "Python not found in the filesystem!" LangString STATUS_PythonNotFound ${LANG_ENGLISH} "Python not found in the filesystem!"
LangString STATUS_PythonNotFound ${LANG_HUNGARIAN}} "Nem tallhat Python a fjlrendszerben!" LangString STATUS_PythonNotFound ${LANG_HUNGARIAN}} "Nem tal�lhat� Python a f�jlrendszerben!"
LangString STATUS_PythonArchitectNotFound ${LANG_ENGLISH} "Could NOT determine the installed Python mode!$\r$\n\ LangString STATUS_PythonArchitectNotFound ${LANG_ENGLISH} "Could NOT determine the installed Python mode!$\r$\n\
To procede please uninstall Python first." To procede please uninstall Python first."
LangString STATUS_PythonArchitectNotFound ${LANG_HUNGARIAN} "Nem sikerlt kiderteni a felteleptett Python mdjt!$\r$\n\ LangString STATUS_PythonArchitectNotFound ${LANG_HUNGARIAN} "Nem siker�lt kider�teni a feltelep�tett Python m�dj�t!$\r$\n\
A sikeres teleptshez el kell elbb tvoltania a Python-t." A sikeres telep�t�shez el kell el�bb t�vol�tania a Python-t."
;NX Client (NXClient) ;NX Client (NXClient)
;NAME ;NAME
...@@ -183,12 +192,12 @@ ...@@ -183,12 +192,12 @@
;DESC ;DESC
LangString DESC_NXClient ${LANG_ENGLISH} "Check whether you want to install a CIRCLE compatible NX Client by NoMachine.$\r$\n\ LangString DESC_NXClient ${LANG_ENGLISH} "Check whether you want to install a CIRCLE compatible NX Client by NoMachine.$\r$\n\
Used for [NX] type of connections." Used for [NX] type of connections."
LangString DESC_NXClient ${LANG_HUNGARIAN} "Vlassza ki, ha fel szeretn telepteni a NoMachine ltal gyrtott NX Klienst.$\r$\n\ LangString DESC_NXClient ${LANG_HUNGARIAN} "V�lassza ki, ha fel szeretn� telep�teni a NoMachine �ltal gy�rtott NX Klienst.$\r$\n\
[NX] fle kapcsolatokhoz hasznlt." [NX] f�le kapcsolatokhoz haszn�lt."
;Setup ;Setup
LangString STATUS_ExecutingScript ${LANG_ENGLISH} "Executing setup script. Log files can be found at:" LangString STATUS_ExecutingScript ${LANG_ENGLISH} "Executing setup script. Log files can be found at:"
LangString STATUS_ExecutingScript ${LANG_HUNGARIAN} "Installcis script futtatsa. A folyamat naplja:" LangString STATUS_ExecutingScript ${LANG_HUNGARIAN} "Install�ci�s script futtat�sa. A folyamat napl�ja:"
;-------------------------------- ;--------------------------------
;Global variables ;Global variables
Var /GLOBAL python_location Var /GLOBAL python_location
...@@ -227,7 +236,7 @@ SectionGroup /e '!$(NAME_Install)' ...@@ -227,7 +236,7 @@ SectionGroup /e '!$(NAME_Install)'
;Creating ShortCuts ;Creating ShortCuts
CreateDirectory '$SMPROGRAMS\${Company}\${AppName}' CreateDirectory '$SMPROGRAMS\${Company}\${AppName}'
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3 StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3
WriteINIStr "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" "InternetShortcut" "URL" "${AppUrl}" WriteINIStr "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" "InternetShortcut" "URL" "${AppUrl}"
Goto +2 Goto +2
WriteINIStr "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" "InternetShortcut" "URL" "${AppUrl}" WriteINIStr "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" "InternetShortcut" "URL" "${AppUrl}"
CreateShortCut '$SMPROGRAMS\${Company}\${AppName}\Uninstall ${AppName}.lnk' '$INSTDIR\${AppUninstaller}' "" '$INSTDIR\${AppUninstaller}' 0 CreateShortCut '$SMPROGRAMS\${Company}\${AppName}\Uninstall ${AppName}.lnk' '$INSTDIR\${AppUninstaller}' "" '$INSTDIR\${AppUninstaller}' 0
...@@ -265,6 +274,7 @@ Function .onInit ...@@ -265,6 +274,7 @@ Function .onInit
ClearErrors ClearErrors
${EndIf} ${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY !insertmacro MUI_LANGDLL_DISPLAY
!insertmacro MULTIUSER_INIT
FunctionEnd FunctionEnd
Function PythonSearch Function PythonSearch
StrCpy $python_location "" StrCpy $python_location ""
...@@ -285,7 +295,7 @@ Function PythonSearch ...@@ -285,7 +295,7 @@ Function PythonSearch
Pop $0 Pop $0
${If} $0 = 0 ${If} $0 = 0
Pop $0 Pop $0
${StrTrimNewLines} $python_version $0 ${StrTrimNewLines2} $python_version $0
loop: loop:
${Explode} $0 $explodeChar $python_version ${Explode} $0 $explodeChar $python_version
${For} $1 1 $0 ${For} $1 1 $0
...@@ -315,7 +325,7 @@ Function PythonSearch ...@@ -315,7 +325,7 @@ Function PythonSearch
${EndIf} ${EndIf}
Goto loopNext Goto loopNext
CutPython: CutPython:
${StrCase} $3 $2 "U" ${StrCase2} $3 $2 "U"
StrCmp $3 "PYTHON" loopNext StrCmp $3 "PYTHON" loopNext
StrCpy $python_version $2 StrCpy $python_version $2
StrCpy $explodeChar '.' StrCpy $explodeChar '.'
...@@ -335,7 +345,7 @@ Function PythonSearch ...@@ -335,7 +345,7 @@ Function PythonSearch
Pop $0 Pop $0
${If} $0 = 0 ${If} $0 = 0
Pop $0 Pop $0
${StrTrimNewLines} $python_architect $0 ${StrTrimNewLines2} $python_architect $0
DetailPrint '$(STATUS_PythonArchitectFound) $python_architectbit' DetailPrint '$(STATUS_PythonArchitectFound) $python_architectbit'
${Else} ${Else}
StrCpy $found_python "false" StrCpy $found_python "false"
...@@ -633,7 +643,7 @@ Function Explode ...@@ -633,7 +643,7 @@ Function Explode
Push $explArrCount Push $explArrCount
FunctionEnd FunctionEnd
Function StrCase Function StrCase2
/*After this point: /*After this point:
------------------------------------------ ------------------------------------------
$0 = String (input) $0 = String (input)
...@@ -805,7 +815,7 @@ Function StrCase ...@@ -805,7 +815,7 @@ Function StrCase
Pop $1 Pop $1
Exch $0 Exch $0
FunctionEnd FunctionEnd
Function StrTrimNewLines Function StrTrimNewLines2
/*After this point: /*After this point:
------------------------------------------ ------------------------------------------
$R0 = String (input) $R0 = String (input)
...@@ -868,8 +878,8 @@ Section "Uninstall" ...@@ -868,8 +878,8 @@ Section "Uninstall"
${EndIf} ${EndIf}
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +4 StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +4
IfFileExists "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" 0 +2 IfFileExists "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" 0 +2
Delete "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" Delete "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url"
Goto +3 Goto +3
IfFileExists "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" 0 +2 IfFileExists "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" 0 +2
Delete "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" Delete "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url"
...@@ -932,5 +942,6 @@ Function un.onInit ...@@ -932,5 +942,6 @@ Function un.onInit
SetRegView 64 SetRegView 64
${EndIf} ${EndIf}
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
!insertmacro MULTIUSER_UNINIT
FunctionEnd FunctionEnd
\ No newline at end of file
...@@ -9,7 +9,9 @@ The Client job is to help the ease of use of the cloud system. ...@@ -9,7 +9,9 @@ The Client job is to help the ease of use of the cloud system.
import argparse import argparse
import logging import logging
import platform import platform
import tempfile
from time import gmtime, strftime from time import gmtime, strftime
from windowsclasses import ClientRegistry from windowsclasses import ClientRegistry
...@@ -49,8 +51,8 @@ def parse_arguments(): ...@@ -49,8 +51,8 @@ def parse_arguments():
help="Explicit location of the wanted logfile location and name", help="Explicit location of the wanted logfile location and name",
type=unicode, type=unicode,
default=("%(directory)s\\%(file)s" % { default=("%(directory)s\\%(file)s" % {
'directory': ClientRegistry.directory(), 'directory': tempfile.gettempdir(),
'file': 'client.log'})) 'file': 'circle_client.log'}))
args = parser.parse_args() args = parser.parse_args()
return args return args
......
...@@ -11,12 +11,13 @@ import binascii ...@@ -11,12 +11,13 @@ import binascii
import glob import glob
import locale import locale
import logging import logging
import nxkey
import os import os
import subprocess import subprocess
import time import time
import win32crypt import tempfile
import nxkey
import win32crypt
from windowsclasses import ClientRegistry from windowsclasses import ClientRegistry
...@@ -76,36 +77,27 @@ def connect(vm): ...@@ -76,36 +77,27 @@ def connect(vm):
subprocess.Popen((u'"%s"' % config_file).encode( subprocess.Popen((u'"%s"' % config_file).encode(
locale.getpreferredencoding()), shell=True) locale.getpreferredencoding()), shell=True)
elif vm.protocol == "RDP": elif vm.protocol == "RDP":
logger.info('RDP protocol received') logger.debug('RDP protocol received')
listdir = ClientRegistry.directory() + "\\.rdp\\*.rdp"
found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port) full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir): config_file = "%s%s" % (
with open(config_file) as f: tempfile.gettempdir(),
file = f.read() "\\circle_" + vm.user + str(int(time.time() * 1000)) + ".rdp")
if full_address in file and user in file: logger.info('Creating config file %s' % config_file)
found = True password = binascii.hexlify(win32crypt.CryptProtectData(
logger.info('Config file found: %s', config_file) u"%s" % vm.password, u'psw', None, None, None, 0))
break config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
if not found: 'HOST': vm.host, 'PORT': vm.port}
logger.info('No config file found, creating new one') f = open(config_file, 'w')
config_file = "%s%s%s" % (( f.write(config)
ClientRegistry.directory() + "\\.rdp\\"), f.close()
str(int(time.time() * 1000)), ".rdp")
password = binascii.hexlify(win32crypt.CryptProtectData(
u"%s" % vm.password, u'psw', None, None, None, 0))
config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
logger.info('Config file created: %s', config_file)
logger.debug('Popen the config file: %s', config_file) logger.debug('Popen the config file: %s', config_file)
subprocess.Popen((u'"%s"' % config_file).encode( subprocess.Popen((u'"%s"' % config_file).encode(
locale.getpreferredencoding()), shell=True) locale.getpreferredencoding()), shell=True).wait()
os.remove(config_file)
logger.info('Client finished working') logger.info('Client finished working')
NX_template = """<!DOCTYPE NXClientSettings> NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" > <NXClientSettings application="nxclient" version="1.3" >
<group name="General" > <group name="General" >
...@@ -125,4 +117,5 @@ NX_template = """<!DOCTYPE NXClientSettings> ...@@ -125,4 +117,5 @@ NX_template = """<!DOCTYPE NXClientSettings>
RPD_template = """username:s:%(USERNAME)s RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s full address:s:%(HOST)s:%(PORT)s
authentication level:i:0
password 51:b:%(PASSWORD)s""" password 51:b:%(PASSWORD)s"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment