windows installer fixes
This commit is contained in:
@@ -50,6 +50,7 @@ Type: filesandordirs; Name: "{commonappdata}\LOGAR"
|
||||
[Code]
|
||||
var
|
||||
DataDirPage: TInputDirWizardPage;
|
||||
ConfigFilePage: TInputFileWizardPage;
|
||||
|
||||
procedure InitializeWizard;
|
||||
begin
|
||||
@@ -64,6 +65,16 @@ begin
|
||||
);
|
||||
DataDirPage.Add('Data Directory:');
|
||||
DataDirPage.Values[0] := ExpandConstant('{commonappdata}\LOGAR');
|
||||
|
||||
ConfigFilePage := CreateInputFilePage(
|
||||
DataDirPage.ID,
|
||||
'Import Client Configuration (Optional)',
|
||||
'Do you have a pre-exported client_config.json profile to import?',
|
||||
'Select your client_config.json profile exported from the LOGAR Server Hub.'#13#10#13#10 +
|
||||
'If selected, this configuration will be copied into the data directory and used for automated server connection and enrollment.'#13#10#13#10 +
|
||||
'You can also leave this blank to place client_config.json in the data directory manually later.'
|
||||
);
|
||||
ConfigFilePage.Add('Client Configuration (client_config.json):', 'JSON Files (*.json)|*.json|All Files (*.*)|*.*', '.json');
|
||||
end;
|
||||
|
||||
function GetDataDir(Param: String): String;
|
||||
@@ -73,11 +84,25 @@ begin
|
||||
Result := ExpandConstant('{commonappdata}\LOGAR');
|
||||
end;
|
||||
|
||||
function GetConfigFile(Param: String): String;
|
||||
begin
|
||||
Result := ConfigFilePage.Values[0];
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
var
|
||||
CfgPath, DestCfg: String;
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Client', 'DataDir', GetDataDir(''));
|
||||
|
||||
CfgPath := GetConfigFile('');
|
||||
if (CfgPath <> '') and FileExists(CfgPath) then
|
||||
begin
|
||||
DestCfg := GetDataDir('') + '\client_config.json';
|
||||
FileCopy(CfgPath, DestCfg, False);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ VIAddVersionKey "FileVersion" "0.3.2.0"
|
||||
VIAddVersionKey "ProductVersion" "0.3.2.0"
|
||||
|
||||
Var DATADIR
|
||||
Var CFGFILE
|
||||
Var CfgDialog
|
||||
Var CfgFileInput
|
||||
Var CfgBrowseBtn
|
||||
|
||||
# --- UI Pages ---
|
||||
!define MUI_ABORTWARNING
|
||||
@@ -40,6 +44,9 @@ Var DATADIR
|
||||
!define MUI_DIRECTORYPAGE_VARIABLE $DATADIR
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
||||
# Custom Page: Config File Selection
|
||||
Page custom ConfigPageCreate ConfigPageLeave
|
||||
|
||||
# Instfiles Page
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
@@ -57,8 +64,44 @@ Var DATADIR
|
||||
Function .onInit
|
||||
SetShellVarContext all
|
||||
StrCpy $DATADIR "$APPDATA\LOGAR"
|
||||
StrCpy $CFGFILE ""
|
||||
FunctionEnd
|
||||
|
||||
Function ConfigPageCreate
|
||||
nsDialogs::Create 1018
|
||||
Pop $CfgDialog
|
||||
${If} $CfgDialog == error
|
||||
Abort
|
||||
${EndIf}
|
||||
|
||||
!insertmacro MUI_HEADER_TEXT "Import Client Configuration (Optional)" "Choose a client_config.json profile exported from LOGAR Server."
|
||||
|
||||
${NSD_CreateLabel} 0 0 100% 30u "If you have exported a client_config.json profile bundle from your LOGAR Server dashboard, select it below to configure the forwarder immediately.$\r$\n$\r$\nLeave this field blank to configure later."
|
||||
Pop $0
|
||||
|
||||
${NSD_CreateText} 0 38u 75% 12u "$CFGFILE"
|
||||
Pop $CfgFileInput
|
||||
|
||||
${NSD_CreateButton} 78% 37u 22% 14u "Browse..."
|
||||
Pop $CfgBrowseBtn
|
||||
${NSD_OnClick} $CfgBrowseBtn OnBrowseCfg
|
||||
|
||||
nsDialogs::Show
|
||||
Function
|
||||
|
||||
Function OnBrowseCfg
|
||||
nsDialogs::SelectFileDialog open "" "LOGAR Client Profiles (*.json)|*.json|All Files (*.*)|*.*"
|
||||
Pop $0
|
||||
${If} $0 != ""
|
||||
StrCpy $CFGFILE $0
|
||||
${NSD_SetText} $CfgFileInput $CFGFILE
|
||||
${EndIf}
|
||||
Function
|
||||
|
||||
Function ConfigPageLeave
|
||||
${NSD_GetText} $CfgFileInput $CFGFILE
|
||||
Function
|
||||
|
||||
Section "Install"
|
||||
SetShellVarContext all
|
||||
SetOutPath "$INSTDIR"
|
||||
@@ -69,6 +112,12 @@ Section "Install"
|
||||
CreateDirectory "$DATADIR"
|
||||
ExecWait 'icacls "$DATADIR" /grant "*S-1-5-32-545:(OI)(CI)M" /T /Q'
|
||||
|
||||
# If client config file was selected, copy to data directory
|
||||
${If} $CFGFILE != ""
|
||||
${AndIf} ${FileExists} "$CFGFILE"
|
||||
CopyFiles /SILENT "$CFGFILE" "$DATADIR\client_config.json"
|
||||
${EndIf}
|
||||
|
||||
# Install and configure service via NSSM
|
||||
ExecWait '"$INSTDIR\nssm.exe" install LOGAR_Client "$INSTDIR\Win_Client.exe"'
|
||||
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Client AppDirectory "$INSTDIR"'
|
||||
|
||||
@@ -15,10 +15,24 @@ BUILD_TEMP = os.path.join(ROOT_DIR, "build_temp")
|
||||
|
||||
def clean_and_prep():
|
||||
if os.path.exists(DIST_DIR):
|
||||
shutil.rmtree(DIST_DIR)
|
||||
os.makedirs(DIST_DIR, exist_ok=True)
|
||||
for item in os.listdir(DIST_DIR):
|
||||
if item == "runtime":
|
||||
continue
|
||||
item_path = os.path.join(DIST_DIR, item)
|
||||
try:
|
||||
if os.path.isdir(item_path):
|
||||
shutil.rmtree(item_path)
|
||||
else:
|
||||
os.remove(item_path)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
os.makedirs(DIST_DIR, exist_ok=True)
|
||||
if os.path.exists(BUILD_TEMP):
|
||||
shutil.rmtree(BUILD_TEMP)
|
||||
try:
|
||||
shutil.rmtree(BUILD_TEMP)
|
||||
except Exception:
|
||||
pass
|
||||
os.makedirs(BUILD_TEMP, exist_ok=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user