feat(installer): add .lic license file initialization step during installation on Windows and Linux
This commit is contained in:
@@ -3,8 +3,42 @@ set -euo pipefail
|
|||||||
|
|
||||||
INSTALL_DIR="/opt/logar-server"
|
INSTALL_DIR="/opt/logar-server"
|
||||||
CONFIG_DIR="/etc/logar"
|
CONFIG_DIR="/etc/logar"
|
||||||
|
LIC_FILE=""
|
||||||
|
|
||||||
|
# Parse command line options
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--config-dir|--data-dir)
|
||||||
|
CONFIG_DIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--lic|--license|--import-lic)
|
||||||
|
LIC_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "============================================================"
|
||||||
|
echo " LOGAR Server Enterprise Linux Installer"
|
||||||
|
echo "============================================================"
|
||||||
|
|
||||||
|
# Interactive configuration if running in a terminal without CLI arguments
|
||||||
|
if [ -t 0 ] && [ -z "${LIC_FILE}" ]; then
|
||||||
|
read -r -p "Enter Data and Configuration Directory [${CONFIG_DIR}]: " USER_CFG
|
||||||
|
if [ -n "${USER_CFG}" ]; then
|
||||||
|
CONFIG_DIR="${USER_CFG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -p "Enter path to .lic license file (press Enter to skip): " USER_LIC
|
||||||
|
if [ -n "${USER_LIC}" ]; then
|
||||||
|
LIC_FILE="${USER_LIC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[+] Installing LOGAR Server..."
|
|
||||||
mkdir -p "${INSTALL_DIR}" "${CONFIG_DIR}" "/var/log/logar"
|
mkdir -p "${INSTALL_DIR}" "${CONFIG_DIR}" "/var/log/logar"
|
||||||
|
|
||||||
if [ -f "dist/Server.bin" ]; then
|
if [ -f "dist/Server.bin" ]; then
|
||||||
@@ -21,6 +55,12 @@ if [ -f "${INSTALL_DIR}/Server" ]; then
|
|||||||
chmod +x "${INSTALL_DIR}/Server"
|
chmod +x "${INSTALL_DIR}/Server"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If license file provided, import it during setup
|
||||||
|
if [ -n "${LIC_FILE}" ] && [ -f "${LIC_FILE}" ]; then
|
||||||
|
echo "[*] Importing license file: ${LIC_FILE}..."
|
||||||
|
"${INSTALL_DIR}/Server" --config "${CONFIG_DIR}/server_config.json" --import-lic "${LIC_FILE}" || echo "[!] License import returned warning. Continuing."
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF > /etc/systemd/system/logar-server.service
|
cat <<EOF > /etc/systemd/system/logar-server.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=LOGAR Hub and Aggregator Engine
|
Description=LOGAR Hub and Aggregator Engine
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ Type: filesandordirs; Name: "{commonappdata}\LOGAR-Server"
|
|||||||
[Code]
|
[Code]
|
||||||
var
|
var
|
||||||
DataDirPage: TInputDirWizardPage;
|
DataDirPage: TInputDirWizardPage;
|
||||||
|
LicFilePage: TInputFileWizardPage;
|
||||||
|
|
||||||
procedure InitializeWizard;
|
procedure InitializeWizard;
|
||||||
begin
|
begin
|
||||||
@@ -65,6 +66,15 @@ begin
|
|||||||
);
|
);
|
||||||
DataDirPage.Add('Data Directory:');
|
DataDirPage.Add('Data Directory:');
|
||||||
DataDirPage.Values[0] := ExpandConstant('{commonappdata}\LOGAR-Server');
|
DataDirPage.Values[0] := ExpandConstant('{commonappdata}\LOGAR-Server');
|
||||||
|
|
||||||
|
LicFilePage := CreateInputFilePage(
|
||||||
|
DataDirPage.ID,
|
||||||
|
'Enterprise License Activation (Optional)',
|
||||||
|
'Do you have an activated .lic license file to import during installation?',
|
||||||
|
'Select your signed .lic file to activate the server immediately.'#13#10#13#10 +
|
||||||
|
'You can also leave this blank to initialize with a default evaluation license and activate later via the web dashboard.'
|
||||||
|
);
|
||||||
|
LicFilePage.Add('License File (.lic):', 'License Files (*.lic)|*.lic|All Files (*.*)|*.*', '.lic');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetDataDir(Param: String): String;
|
function GetDataDir(Param: String): String;
|
||||||
@@ -74,11 +84,32 @@ begin
|
|||||||
Result := ExpandConstant('{commonappdata}\LOGAR-Server');
|
Result := ExpandConstant('{commonappdata}\LOGAR-Server');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetLicFile(Param: String): String;
|
||||||
|
begin
|
||||||
|
Result := LicFilePage.Values[0];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure CurStepChanged(CurStep: TSetupStep);
|
procedure CurStepChanged(CurStep: TSetupStep);
|
||||||
|
var
|
||||||
|
LicPath: String;
|
||||||
|
ResultCode: Integer;
|
||||||
begin
|
begin
|
||||||
if CurStep = ssPostInstall then
|
if CurStep = ssPostInstall then
|
||||||
begin
|
begin
|
||||||
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Server', 'DataDir', GetDataDir(''));
|
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\LOGAR\LOGAR-Server', 'DataDir', GetDataDir(''));
|
||||||
|
|
||||||
|
LicPath := GetLicFile('');
|
||||||
|
if (LicPath <> '') and FileExists(LicPath) then
|
||||||
|
begin
|
||||||
|
Exec(
|
||||||
|
ExpandConstant('{app}\Server.exe'),
|
||||||
|
'--config "' + GetDataDir('') + '\server_config.json" --import-lic "' + LicPath + '"',
|
||||||
|
ExpandConstant('{app}'),
|
||||||
|
SW_HIDE,
|
||||||
|
ewWaitUntilTerminated,
|
||||||
|
ResultCode
|
||||||
|
);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ VIAddVersionKey "FileVersion" "0.3.1.0"
|
|||||||
VIAddVersionKey "ProductVersion" "0.3.1.0"
|
VIAddVersionKey "ProductVersion" "0.3.1.0"
|
||||||
|
|
||||||
Var DATADIR
|
Var DATADIR
|
||||||
|
Var LICFILE
|
||||||
|
Var LicDialog
|
||||||
|
Var LicFileInput
|
||||||
|
Var LicBrowseBtn
|
||||||
|
|
||||||
# --- UI Pages ---
|
# --- UI Pages ---
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
@@ -40,6 +44,9 @@ Var DATADIR
|
|||||||
!define MUI_DIRECTORYPAGE_VARIABLE $DATADIR
|
!define MUI_DIRECTORYPAGE_VARIABLE $DATADIR
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
|
||||||
|
# Custom Page: License File Selection
|
||||||
|
Page custom LicensePageCreate LicensePageLeave
|
||||||
|
|
||||||
# Instfiles Page
|
# Instfiles Page
|
||||||
!insertmacro MUI_PAGE_INSTFILES
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
@@ -57,8 +64,44 @@ Var DATADIR
|
|||||||
Function .onInit
|
Function .onInit
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
StrCpy $DATADIR "$APPDATA\LOGAR-Server"
|
StrCpy $DATADIR "$APPDATA\LOGAR-Server"
|
||||||
|
StrCpy $LICFILE ""
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
Function LicensePageCreate
|
||||||
|
nsDialogs::Create 1018
|
||||||
|
Pop $LicDialog
|
||||||
|
${If} $LicDialog == error
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!insertmacro MUI_HEADER_TEXT "Enterprise License Activation (Optional)" "Choose a .lic license file to activate your server during installation."
|
||||||
|
|
||||||
|
${NSD_CreateLabel} 0 0 100% 30u "If you have received an activated .lic license file, select it below to activate the server immediately.$\r$\n$\r$\nLeave this field blank to use the default evaluation license."
|
||||||
|
Pop $0
|
||||||
|
|
||||||
|
${NSD_CreateText} 0 38u 75% 12u "$LICFILE"
|
||||||
|
Pop $LicFileInput
|
||||||
|
|
||||||
|
${NSD_CreateButton} 78% 37u 22% 14u "Browse..."
|
||||||
|
Pop $LicBrowseBtn
|
||||||
|
${NSD_OnClick} $LicBrowseBtn OnBrowseLic
|
||||||
|
|
||||||
|
nsDialogs::Show
|
||||||
|
Function
|
||||||
|
|
||||||
|
Function OnBrowseLic
|
||||||
|
nsDialogs::SelectFileDialog open "" "LOGAR License Files (*.lic)|*.lic|All Files (*.*)|*.*"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 != ""
|
||||||
|
StrCpy $LICFILE $0
|
||||||
|
${NSD_SetText} $LicFileInput $LICFILE
|
||||||
|
${EndIf}
|
||||||
|
Function
|
||||||
|
|
||||||
|
Function LicensePageLeave
|
||||||
|
${NSD_GetText} $LicFileInput $LICFILE
|
||||||
|
Function
|
||||||
|
|
||||||
Section "Install"
|
Section "Install"
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
@@ -69,6 +112,12 @@ Section "Install"
|
|||||||
CreateDirectory "$DATADIR"
|
CreateDirectory "$DATADIR"
|
||||||
ExecWait 'icacls "$DATADIR" /grant "*S-1-5-32-545:(OI)(CI)M" /T /Q'
|
ExecWait 'icacls "$DATADIR" /grant "*S-1-5-32-545:(OI)(CI)M" /T /Q'
|
||||||
|
|
||||||
|
# If license file was selected, import before starting service
|
||||||
|
${If} $LICFILE != ""
|
||||||
|
${AndIf} ${FileExists} "$LICFILE"
|
||||||
|
ExecWait '"$INSTDIR\Server.exe" --config "$DATADIR\server_config.json" --import-lic "$LICFILE"'
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
# Install and configure service via NSSM
|
# Install and configure service via NSSM
|
||||||
ExecWait '"$INSTDIR\nssm.exe" install LOGAR_Server "$INSTDIR\Server.exe"'
|
ExecWait '"$INSTDIR\nssm.exe" install LOGAR_Server "$INSTDIR\Server.exe"'
|
||||||
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppDirectory "$INSTDIR"'
|
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppDirectory "$INSTDIR"'
|
||||||
|
|||||||
Reference in New Issue
Block a user