install_all.iss
This commit is contained in:
parent
18b1103c90
commit
d8b12f9c6d
@ -1,7 +1,7 @@
|
||||
;iss
|
||||
|
||||
#define MyAppName "基础环境"
|
||||
#define MyAppVersion "1.0.12"
|
||||
#define MyAppVersion "1.0.14"
|
||||
#define MyAppPublisher "X"
|
||||
#define MyAppURL "~"
|
||||
#define MyAppExeName "command"
|
||||
@ -506,45 +506,9 @@ end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 在安装前检查
|
||||
function InitializeSetup: Boolean;
|
||||
// 删除过程文件
|
||||
procedure RemoveTempFile;
|
||||
begin
|
||||
// 默认允许安装继续
|
||||
Result := True;
|
||||
|
||||
// 如果 VC++ 2019 未安装
|
||||
if not IsVC2019Installed then
|
||||
begin
|
||||
MsgBox('本程序需要 Microsoft Visual C++ 2019 运行时才能继续(1001)', mbError, MB_OK)
|
||||
// 中止安装
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
// 在安装完成后执行
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
var
|
||||
ResultCode: Integer;
|
||||
Cmd: string;
|
||||
MySQLPath: string;
|
||||
UsrPath: string;
|
||||
begin
|
||||
|
||||
|
||||
// 仅在安装完成后执行
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
|
||||
|
||||
// 创建配置文件
|
||||
CreateConfigFromTemplate;
|
||||
|
||||
// DeleteFile
|
||||
// DelTree
|
||||
|
||||
@ -575,8 +539,17 @@ begin
|
||||
if FileExists(ExpandConstant('{app}\nginx\Readme.md')) then
|
||||
DeleteFile(ExpandConstant('{app}\nginx\Readme.md'));
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// 初始化并启动MySQL
|
||||
procedure InitializeAndStartMySQL;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
Cmd: string;
|
||||
begin
|
||||
|
||||
// 通过 mysql 初始化生成的唯一 uuid 判断 mysql 是否已经完成初始化
|
||||
if not FileExists(ExpandConstant('{app}\mysql\data\auto.cnf')) then
|
||||
begin
|
||||
@ -585,61 +558,128 @@ begin
|
||||
begin
|
||||
// 如果没有初始化,则删除 readme
|
||||
DelTree(ExpandConstant('{app}\mysql\data\Readme.md'), False, True, False);
|
||||
// 初始化
|
||||
// 同步 ewWaitUntilTerminated
|
||||
// 异步 ewNoWait
|
||||
|
||||
Cmd := '/C "' + ExpandConstant('{app}') + '\mysql\initialize-and-start-mysql.bat"';
|
||||
if not Exec('cmd.exe', Cmd, '', SW_HIDE, ewNoWait, ResultCode) then
|
||||
begin
|
||||
MsgBox('初始化 MySQL 脚本失败', mbError, MB_OK);
|
||||
end else begin
|
||||
DelayMS(3000);
|
||||
DeleteFile(ExpandConstant('{app}\mysql\initialize-and-start-mysql.bat'));
|
||||
DeleteFile(ExpandConstant('{app}\mysql\register-mysql-with-data.bat'));
|
||||
DelayMS(200);
|
||||
end;
|
||||
|
||||
|
||||
// 存在默认库SQL压缩包
|
||||
if FileExists(ExpandConstant('{app}\mysql\database.rar')) then
|
||||
begin
|
||||
// 解压
|
||||
if not Exec('cmd.exe', '/C " cd ' + ExpandConstant('{app}') + '\mysql && %cd%\..\usr\unrar.exe x database.rar script\demo\"', '', SW_HIDE, ewNoWait, ResultCode) then
|
||||
begin
|
||||
MsgBox('初始化 MySQL 脚本失败', mbError, MB_OK);
|
||||
MsgBox('解压 MySQL 默认库失败', mbError, MB_OK);
|
||||
end;
|
||||
|
||||
// 删除 database.rar 默认库SQL压缩包
|
||||
DelayMS(1000);
|
||||
DelTree(ExpandConstant('{app}\mysql\database.rar'), False, True, False);
|
||||
end;
|
||||
DelayMS(1000);
|
||||
|
||||
// 判断是否安装了 usr 基础环境
|
||||
if FileExists(ExpandConstant('{app}\usr\rar.exe')) then
|
||||
begin
|
||||
// 这个时候 `环境变量` 还没开始注册,所以 bat 导入脚本不生效,因此需要指定临时Path环境变量
|
||||
// 导出默认库和用户
|
||||
if FileExists(ExpandConstant('{app}\mysql\import-data-into-mysql.bat')) then
|
||||
begin
|
||||
|
||||
// 临时设置 PATH 并执行脚本
|
||||
MySQLPath := ExpandConstant('{app}') + '\mysql\bin';
|
||||
UsrPath := ExpandConstant('{app}') + '\usr';
|
||||
Cmd := '/C "set PATH=' + MySQLPath + '; ' + UsrPath + ';%PATH%' +
|
||||
' && cd ' + ExpandConstant('{app}') + '\mysql' +
|
||||
' && import-data-into-mysql.bat"' +
|
||||
' && exit"';
|
||||
// 初始化
|
||||
// 同步 ewWaitUntilTerminated
|
||||
// 异步 ewNoWait
|
||||
|
||||
// 初始化并启动 MySQL
|
||||
// Cmd := '/C "' + ExpandConstant('{app}') + '\mysql\initialize-and-start-mysql.bat"';
|
||||
Cmd := '/C " cd ' + ExpandConstant('{app}') + '\mysql && initialize.bat"';
|
||||
if not Exec('cmd.exe', Cmd, '', SW_HIDE, ewNoWait, ResultCode) then
|
||||
begin
|
||||
MsgBox('初始化 MySQL 脚本失败', mbError, MB_OK);
|
||||
end else begin
|
||||
DelayMS(3000);
|
||||
// DeleteFile(ExpandConstant('{app}\mysql\initialize-and-start-mysql.bat'));
|
||||
DeleteFile(ExpandConstant('{app}\mysql\register-mysql-with-data.bat'));
|
||||
// DeleteFile(ExpandConstant('{app}\mysql\initialize.bat'));
|
||||
end;
|
||||
DelayMS(1000);
|
||||
|
||||
|
||||
end; // mysql auto.conf 初始化判定
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// 导入默认数据库到 MySQL
|
||||
// procedure ImportDefaultDatabase2MySQL;
|
||||
// var
|
||||
// ResultCode: Integer;
|
||||
// Cmd: string;
|
||||
// MySQLPath: string;
|
||||
// UsrPath: string;
|
||||
// begin
|
||||
//
|
||||
// // 判断是否安装了 usr 基础环境
|
||||
// if FileExists(ExpandConstant('{app}\usr\rar.exe')) then
|
||||
// begin
|
||||
//
|
||||
// // 等待 MySQL 服务启动完成
|
||||
// DelayMS(3000);
|
||||
// // 这个时候 `环境变量` 还没开始注册,所以 bat 导入脚本不生效,因此需要指定临时Path环境变量
|
||||
// // 导出默认库和用户
|
||||
// if FileExists(ExpandConstant('{app}\mysql\import-data-into-mysql.bat')) then
|
||||
// begin
|
||||
//
|
||||
// // 临时设置 PATH 并执行脚本
|
||||
// MySQLPath := ExpandConstant('{app}') + '\mysql\bin';
|
||||
// UsrPath := ExpandConstant('{app}') + '\usr';
|
||||
// Cmd := '/C "set PATH=' + MySQLPath + '; ' + UsrPath + ';%PATH%' +
|
||||
// ' && cd ' + ExpandConstant('{app}') + '\mysql' +
|
||||
// ' && import-data-into-mysql.bat"' +
|
||||
// ' && exit"';
|
||||
//
|
||||
// if not Exec('cmd.exe', Cmd, '', SW_HIDE, ewNoWait, ResultCode) then
|
||||
// begin
|
||||
// MsgBox('初始化默认库脚本失败', mbError, MB_OK);
|
||||
// end;
|
||||
// DelayMS(1000);
|
||||
// end;
|
||||
// end; // 是否安装了 usr 环境
|
||||
//
|
||||
// end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 在安装前检查
|
||||
function InitializeSetup: Boolean;
|
||||
begin
|
||||
// 默认允许安装继续
|
||||
Result := True;
|
||||
|
||||
// 如果 VC++ 2019 未安装
|
||||
if not IsVC2019Installed then
|
||||
begin
|
||||
MsgBox('本程序需要 Microsoft Visual C++ 2019 运行时才能继续(1001)', mbError, MB_OK)
|
||||
// 中止安装
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// 在安装完成后执行
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
|
||||
// 仅在安装完成后执行
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
// 创建配置文件
|
||||
CreateConfigFromTemplate;
|
||||
|
||||
// 删除过程文件
|
||||
RemoveTempFile;
|
||||
|
||||
// 初始化并启动 MySQL
|
||||
InitializeAndStartMySQL;
|
||||
|
||||
// 导入默认数据库到 MySQL
|
||||
// ImportDefaultDatabase2MySQL;
|
||||
end; // 安装完成后的执行
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user