Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Last active October 7, 2021 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/d20c7c319b77dac5acc0bad7e1aa28fc to your computer and use it in GitHub Desktop.
Save tuxmartin/d20c7c319b77dac5acc0bad7e1aa28fc to your computer and use it in GitHub Desktop.
Inno Setup on Linux (Docker)
docker run --rm -i -v "$PWD:/work" \
-e OVPN_VER="2.5.3" \
-e OVPN_BIN32="OpenVPN-2.5.3-I601-x86.msi" \
-e OVPN_BIN64="OpenVPN-2.5.3-I601-amd64.msi" \
-e OVPN_CONF="user.ovpn" \
-e OVPN_SITE="vpn.example.net" \
-e OUT_NAME="vpn_rdp_setup" \
-e PASSWORD="asdf" \
amake/innosetup:64bit openvpn_rdp_docker.iss
; https://newbedev.com/can-one-use-environment-variables-in-inno-setup-scripts
#define OVPN_VER GetEnv('OVPN_VER')
#define OVPN_SITE GetEnv('OVPN_SITE')
#define OVPN_BIN32 GetEnv('OVPN_BIN32')
#define OVPN_BIN64 GetEnv('OVPN_BIN64')
#define OVPN_CONF GetEnv('OVPN_CONF')
#define OUT_NAME GetEnv('OUT_NAME')
#define PASSWORD GetEnv('PASSWORD')
#define MyAppName "OpenVPN RDP installer"
#define MyAppVersion "1.02"
#define MyAppPublisher "TEST"
#define MyAppURL "https://example.net/"
#define MyAppExeName "desktop.RDP"
[Setup]
AppId={{16F35443-4D92-4677-898D-3255BC4B17AD}
AppName={#MyAppName}
AppVersion={#MyAppVersion} - OVPN {#OVPN_VER}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableDirPage=yes
DisableWelcomePage=no
DisableProgramGroupPage=yes
SetupLogging=yes
InfoBeforeFile=before.txt
InfoAfterFile=after.txt
LicenseFile=license.rtf
PrivilegesRequired=admin
OutputBaseFilename={#OUT_NAME}
OutputDir=.
SetupIconFile=logo.ico
Password={#PASSWORD}
Encryption=yes
Compression=lzma2/ultra64
SolidCompression=yes
WizardStyle=modern
ArchitecturesInstallIn64BitMode=x64
ShowLanguageDialog=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
[Files]
Source: "{#OVPN_BIN32}"; DestDir: "{tmp}"; DestName: "OpenVPN.msi"; Check: Is64BitInstallMode; Flags: ignoreversion deleteafterinstall;
Source: "{#OVPN_BIN64}"; DestDir: "{tmp}"; DestName: "OpenVPN.msi"; Check: not Is64BitInstallMode; Flags: ignoreversion deleteafterinstall;
Source: "desktop.RDP"; DestDir: "{app}"; Flags: ignoreversion;
Source: "{#OVPN_CONF}"; DestDir: "{app}"; Flags: ignoreversion; DestName: "user_-_{#OVPN_SITE}.ovpn"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";
[Icons]
Name: "{autoprograms}\Pripojit k RDP"; Filename: "{app}\{#MyAppExeName}";
Name: "{autodesktop}\Pripojit k RDP"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon;
[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\OpenVPN.msi"" /qb"; WorkingDir: {tmp}; Description: "OpenVPN client"; Flags: hidewizard waituntilterminated runascurrentuser; AfterInstall: CopyOpenVPNConfig;
[Code]
function GetOpenVpnConfigDir(): string;
var
x: string;
begin
if Is64BitInstallMode then
begin
RegQueryStringValue(HKLM64, 'SOFTWARE\OpenVPN', 'config_dir', x);
end
else
begin
RegQueryStringValue(HKLM, 'SOFTWARE\OpenVPN', 'config_dir', x);
end;
Log('OpenVPN config_dir = ' + x);
Result := x;
end;
procedure CopyOpenVPNConfig();
begin
if not FileCopy(ExpandConstant('{app}\user_-_{#OVPN_SITE}.ovpn'), AddBackslash(GetOpenVpnConfigDir) + 'user_-_{#OVPN_SITE}.ovpn', False) then
begin
MsgBox('Cannot copy OpenVPN user config file!', mbError, MB_RETRYCANCEL);
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment