Install scripts fixes (#275)

* Install scripts fixes
This commit is contained in:
pokamest 2023-08-13 03:10:41 -07:00 committed by GitHub
parent f8b55eb017
commit 4c690dd3c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 19 deletions

View file

@ -238,11 +238,6 @@ ErrorCode ServerController::setupContainer(const ServerCredentials &credentials,
e = isUserInSudo(credentials, container);
if (e) return e;
if (!isUpdate) {
e = isServerPortBusy(credentials, container, config);
if (e) return e;
}
e = isServerDpkgBusy(credentials, container);
if (e) return e;
@ -250,6 +245,11 @@ ErrorCode ServerController::setupContainer(const ServerCredentials &credentials,
if (e) return e;
qDebug().noquote() << "ServerController::setupContainer installDockerWorker finished";
if (!isUpdate) {
e = isServerPortBusy(credentials, container, config);
if (e) return e;
}
e = prepareHostWorker(credentials, container, config);
if (e) return e;
qDebug().noquote() << "ServerController::setupContainer prepareHostWorker finished";
@ -368,6 +368,7 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent
replaceVars(amnezia::scriptData(SharedScriptType::install_docker),
genVarsForScript(credentials)), cbReadStdOut, cbReadStdErr);
qDebug().noquote() << "ServerController::installDockerWorker" << stdOut;
if (stdOut.contains("command not found")) return ErrorCode::ServerDockerFailedError;
return error;
@ -635,7 +636,7 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
QString defaultTransportProto = ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(protocol), protocol);
QString transportProto = containerConfig.value(config_key::transport_proto).toString(defaultTransportProto);
QString script = QString("sudo lsof -i -P -n | grep -E ':%1 ").arg(port);
QString script = QString("which lsof &>/dev/null || true && sudo lsof -i -P -n | grep -E ':%1 ").arg(port);
for (auto &port : fixedPorts) {
script = script.append("|:%1").arg(port);
}