Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmupdate
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李定达
fmupdate
Commits
27a24851
Commit
27a24851
authored
May 09, 2019
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配linux环境,验证更新机制正常,守护适配TODO
parent
5b0d2f6f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
95 additions
and
26 deletions
+95
-26
fmporter/main.cpp
+12
-2
fmscupd/dump.h
+3
-0
fmscupd/fmcontrol.cpp
+16
-0
fmscupd/fmscupd.pro
+14
-10
fmscupd/fmservice.h
+2
-0
fmscupd/fmtools.cpp
+29
-7
fmscupd/fmtools.h
+1
-0
fmscupd/main.cpp
+18
-7
lib/libquazip5.a
+0
-0
lib/libz.a
+0
-0
No files found.
fmporter/main.cpp
View file @
27a24851
...
@@ -29,7 +29,11 @@ int main(int argc, char *argv[])
...
@@ -29,7 +29,11 @@ int main(int argc, char *argv[])
qDebug
()
<<
"
\r\n\r\n\r\n
"
;
qDebug
()
<<
"
\r\n\r\n\r\n
"
;
QString
appDir
=
QCoreApplication
::
applicationDirPath
();
QString
appDir
=
QCoreApplication
::
applicationDirPath
();
#ifdef WIN32
QString
fmscupdPath
=
QString
(
"%1/fmscupd.exe"
).
arg
(
appDir
);
QString
fmscupdPath
=
QString
(
"%1/fmscupd.exe"
).
arg
(
appDir
);
#else
QString
fmscupdPath
=
QString
(
"%1/fmscupd"
).
arg
(
appDir
);
#endif
QFile
dInfoFile
(
QString
(
"%1/download/dfilesInfo.txt"
).
arg
(
appDir
));
QFile
dInfoFile
(
QString
(
"%1/download/dfilesInfo.txt"
).
arg
(
appDir
));
QFile
resultFile
(
QString
(
"%1/download/updateresult.txt"
).
arg
(
appDir
));
QFile
resultFile
(
QString
(
"%1/download/updateresult.txt"
).
arg
(
appDir
));
QStringList
dFilesInfo
,
bUpdFiles
;
QStringList
dFilesInfo
,
bUpdFiles
;
...
@@ -37,7 +41,7 @@ int main(int argc, char *argv[])
...
@@ -37,7 +41,7 @@ int main(int argc, char *argv[])
bool
updateReault
=
true
;
bool
updateReault
=
true
;
// 关闭服务
// 关闭服务
QProcess
::
execute
(
fmscupdPath
,
QStringList
(
"-t"
));
//
QProcess::execute(fmscupdPath, QStringList("-t"));
// 开始替换文件
// 开始替换文件
if
(
dInfoFile
.
open
(
QIODevice
::
ReadOnly
))
if
(
dInfoFile
.
open
(
QIODevice
::
ReadOnly
))
...
@@ -85,6 +89,12 @@ int main(int argc, char *argv[])
...
@@ -85,6 +89,12 @@ int main(int argc, char *argv[])
if
(
QFile
().
copy
(
downloadFile
,
oldFile
))
if
(
QFile
().
copy
(
downloadFile
,
oldFile
))
{
{
#ifdef WIN32
#else
char
szCmd
[
256
];
sprintf
(
szCmd
,
"chmod a+x %s"
,
oldFile
.
toStdString
().
c_str
());
system
(
szCmd
);
//添加文件执行权限
#endif
qDebug
()
<<
"copy file successful"
;
qDebug
()
<<
"copy file successful"
;
}
else
}
else
{
{
...
@@ -119,6 +129,6 @@ end:
...
@@ -119,6 +129,6 @@ end:
resultFile
.
close
();
resultFile
.
close
();
}
}
// 启动服务
// 启动服务
QProcess
::
startDetached
(
fmscupdPath
,
QStringList
(
fmscupdPath
));
//
QProcess::startDetached(fmscupdPath, QStringList(fmscupdPath));
return
0
;
return
0
;
}
}
fmscupd/dump.h
View file @
27a24851
#ifndef FM_DUMP_H
#ifndef FM_DUMP_H
#define FM_DUMP_H
#define FM_DUMP_H
#ifdef WIN32
#include <windows.h>
#include <windows.h>
#include <DbgHelp.h>
#include <DbgHelp.h>
#include <schannel.h>
#include <schannel.h>
...
@@ -52,5 +54,6 @@ long __stdcall FMExcpHandler(PEXCEPTION_POINTERS excp)
...
@@ -52,5 +54,6 @@ long __stdcall FMExcpHandler(PEXCEPTION_POINTERS excp)
return
EXCEPTION_EXECUTE_HANDLER
;
return
EXCEPTION_EXECUTE_HANDLER
;
}
}
#endif
#endif // DUMP
#endif // DUMP
fmscupd/fmcontrol.cpp
View file @
27a24851
...
@@ -11,9 +11,11 @@
...
@@ -11,9 +11,11 @@
#include <QCryptographicHash>
#include <QCryptographicHash>
#include <QFile>
#include <QFile>
#include <QDir>
#include <QDir>
#ifdef WIN32
#include <windows.h>
#include <windows.h>
#include <tlhelp32.h>
#include <tlhelp32.h>
#include <Userenv.h>
#include <Userenv.h>
#endif
#include <QProcess>
#include <QProcess>
#include "JlCompress.h"
#include "JlCompress.h"
...
@@ -65,6 +67,7 @@ void FmControl::onKeepProcess()
...
@@ -65,6 +67,7 @@ void FmControl::onKeepProcess()
bool
FmControl
::
_GetDiedProcess
(
const
QStringList
&
exeList
,
QStringList
&
diedProcList
,
QString
&
error
)
bool
FmControl
::
_GetDiedProcess
(
const
QStringList
&
exeList
,
QStringList
&
diedProcList
,
QString
&
error
)
{
{
#ifdef WIN32
PROCESSENTRY32
pe32
;
PROCESSENTRY32
pe32
;
pe32
.
dwSize
=
sizeof
(
PROCESSENTRY32
);
pe32
.
dwSize
=
sizeof
(
PROCESSENTRY32
);
HANDLE
hProcessSnap
=
::
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
0
);
HANDLE
hProcessSnap
=
::
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
0
);
...
@@ -92,11 +95,13 @@ bool FmControl::_GetDiedProcess(const QStringList &exeList, QStringList &diedPro
...
@@ -92,11 +95,13 @@ bool FmControl::_GetDiedProcess(const QStringList &exeList, QStringList &diedPro
}
}
}
}
::
CloseHandle
(
hProcessSnap
);
::
CloseHandle
(
hProcessSnap
);
#endif
return
true
;
return
true
;
}
}
bool
FmControl
::
_LaunchProcess
(
const
QString
&
exePath
,
QString
&
error
)
bool
FmControl
::
_LaunchProcess
(
const
QString
&
exePath
,
QString
&
error
)
{
{
#ifdef WIN32
// 在XP下用户环境可能没有wtsapi32.dll,XP下可直接调用程序
// 在XP下用户环境可能没有wtsapi32.dll,XP下可直接调用程序
typedef
BOOL
(
WINAPI
*
_pfnWTSQueryUserToken
)(
ULONG
SessionId
,
PHANDLE
phToken
);
typedef
BOOL
(
WINAPI
*
_pfnWTSQueryUserToken
)(
ULONG
SessionId
,
PHANDLE
phToken
);
_pfnWTSQueryUserToken
pfnWTSQueryUserToken
=
NULL
;
_pfnWTSQueryUserToken
pfnWTSQueryUserToken
=
NULL
;
...
@@ -162,6 +167,8 @@ bool FmControl::_LaunchProcess(const QString &exePath, QString& error)
...
@@ -162,6 +167,8 @@ bool FmControl::_LaunchProcess(const QString &exePath, QString& error)
CloseHandle
(
pi
.
hProcess
);
CloseHandle
(
pi
.
hProcess
);
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hThread
);
return
true
;
return
true
;
#else
#endif
}
}
void
FmControl
::
onCheckUpdate
()
void
FmControl
::
onCheckUpdate
()
...
@@ -294,10 +301,15 @@ void FmControl::onCheckUpdate()
...
@@ -294,10 +301,15 @@ void FmControl::onCheckUpdate()
file
.
close
();
file
.
close
();
// 调用文件替换程序
// 调用文件替换程序
#ifdef WIN32
QString
porterPath
=
QString
(
"%1/fmporter.exe"
).
arg
(
m_appDir
);
QString
porterPath
=
QString
(
"%1/fmporter.exe"
).
arg
(
m_appDir
);
#else
QString
porterPath
=
QString
(
"%1/fmporter"
).
arg
(
m_appDir
);
#endif
QLOG_INFO
()
<<
QString
(
"process be killed launch [%1]"
).
arg
(
porterPath
);
QLOG_INFO
()
<<
QString
(
"process be killed launch [%1]"
).
arg
(
porterPath
);
if
(
QProcess
::
startDetached
(
porterPath
,
QStringList
(
porterPath
)))
if
(
QProcess
::
startDetached
(
porterPath
,
QStringList
(
porterPath
)))
{
{
QTimer
::
singleShot
(
30000
,
this
,
&
FmControl
::
onCheckUpdate
);
return
;
return
;
}
else
}
else
{
{
...
@@ -449,6 +461,7 @@ bool FmControl::_UnzipFile(const QString &zipFile)
...
@@ -449,6 +461,7 @@ bool FmControl::_UnzipFile(const QString &zipFile)
bool
FmControl
::
_KillProcess
(
const
QStringList
&
exeList
,
QString
&
error
)
bool
FmControl
::
_KillProcess
(
const
QStringList
&
exeList
,
QString
&
error
)
{
{
#ifdef WIN32
PROCESSENTRY32
pe32
;
PROCESSENTRY32
pe32
;
pe32
.
dwSize
=
sizeof
(
PROCESSENTRY32
);
pe32
.
dwSize
=
sizeof
(
PROCESSENTRY32
);
HANDLE
hProcessSnap
=
::
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
0
);
HANDLE
hProcessSnap
=
::
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
0
);
...
@@ -482,5 +495,8 @@ bool FmControl::_KillProcess(const QStringList &exeList, QString &error)
...
@@ -482,5 +495,8 @@ bool FmControl::_KillProcess(const QStringList &exeList, QString &error)
}
}
::
CloseHandle
(
hProcessSnap
);
::
CloseHandle
(
hProcessSnap
);
return
true
;
return
true
;
#else
return
true
;
#endif
}
}
fmscupd/fmscupd.pro
View file @
27a24851
include
(
"
QsL
og/QsLog.pri"
)
include
(
"
qsl
og/QsLog.pri"
)
include
(
"
QtS
ervice/src/qtservice.pri"
)
include
(
"
qts
ervice/src/qtservice.pri"
)
include
(
"
Q
uazip/quazip.pri"
)
include
(
"
q
uazip/quazip.pri"
)
QT
+=
core
network
sql
xml
QT
+=
core
network
sql
xml
QT
-=
gui
QT
-=
gui
...
@@ -45,15 +45,19 @@ OTHER_FILES += \
...
@@ -45,15 +45,19 @@ OTHER_FILES += \
INCLUDEPATH
+=
$$
PWD
/../
include
/
zlib
INCLUDEPATH
+=
$$
PWD
/../
include
/
zlib
LIBS
+=
-
lUserenv
-
ldbghelp
win32
{
CONFIG
(
debug
,
debug
|
release
)
{
LIBS
+=
-
lUserenv
-
ldbghelp
LIBS
+=
-
L
$$
PWD
/../
lib
-
lzlibstaticd
CONFIG
(
debug
,
debug
|
release
)
{
LIBS
+=
-
L
$$
PWD
/../
lib
-
lzlibstaticd
}
else
{
LIBS
+=
-
L
$$
PWD
/../
lib
-
lzlibstatic
QMAKE_LFLAGS
+=
/
DEBUG
}
}
}
else
{
else
{
LIBS
+=
-
L
$$
PWD
/../
lib
-
lzlibstatic
LIBS
+=
-
lz
QMAKE_LFLAGS
+=
/
DEBUG
}
}
#LIBS += -lz
win32
{
win32
{
...
...
fmscupd/fmservice.h
View file @
27a24851
...
@@ -19,7 +19,9 @@ public:
...
@@ -19,7 +19,9 @@ public:
setServiceDescription
(
QString
::
fromLocal8Bit
(
SERVICE_DESC
));
setServiceDescription
(
QString
::
fromLocal8Bit
(
SERVICE_DESC
));
setStartupType
(
QtServiceController
::
AutoStartup
);
setStartupType
(
QtServiceController
::
AutoStartup
);
#ifdef WIN32
SetUnhandledExceptionFilter
(
FMExcpHandler
);
SetUnhandledExceptionFilter
(
FMExcpHandler
);
#endif
}
}
protected
:
protected
:
...
...
fmscupd/fmtools.cpp
View file @
27a24851
...
@@ -18,6 +18,7 @@ FmTools &FmTools::GetInstance()
...
@@ -18,6 +18,7 @@ FmTools &FmTools::GetInstance()
FmTools
::
FmTools
()
FmTools
::
FmTools
()
{
{
QString
iniPath
=
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
(),
INIFILE_NAME
);
QString
iniPath
=
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
(),
INIFILE_NAME
);
m_updateIniPath
=
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
(),
INIFILE_NAME
);
m_config
=
new
QSettings
(
iniPath
,
QSettings
::
IniFormat
);
m_config
=
new
QSettings
(
iniPath
,
QSettings
::
IniFormat
);
#ifdef BALIBEITIAN
#ifdef BALIBEITIAN
...
@@ -192,37 +193,58 @@ FmTools::~FmTools()
...
@@ -192,37 +193,58 @@ FmTools::~FmTools()
QStringList
FmTools
::
GetKeepExes
()
QStringList
FmTools
::
GetKeepExes
()
{
{
return
m_config
->
value
(
INIPATH_EXELIST
).
toStringList
();
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
QStringList
damonList
=
updateSettings
->
value
(
INIPATH_EXELIST
).
toStringList
();
delete
updateSettings
;
return
damonList
;
}
}
QString
FmTools
::
GetVersion
()
QString
FmTools
::
GetVersion
()
{
{
return
m_config
->
value
(
INIPATH_VERSION
).
toString
();
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
QString
version
=
updateSettings
->
value
(
INIPATH_VERSION
).
toString
();
delete
updateSettings
;
return
version
;
}
}
QString
FmTools
::
GetPartnerId
()
QString
FmTools
::
GetPartnerId
()
{
{
return
m_config
->
value
(
INIPATH_PARTNERID
).
toString
();
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
QString
partnerId
=
updateSettings
->
value
(
INIPATH_PARTNERID
).
toString
();
delete
updateSettings
;
return
partnerId
;
}
}
int
FmTools
::
GetDownloadTimeout
()
int
FmTools
::
GetDownloadTimeout
()
{
{
return
m_config
->
value
(
INIPATH_TIMEOUT0
,
300
).
toInt
()
*
1000
;
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
int
downloadTimeout
=
updateSettings
->
value
(
INIPATH_TIMEOUT0
,
300
).
toInt
()
*
1000
;
delete
updateSettings
;
return
downloadTimeout
;
}
}
int
FmTools
::
GetRequestTimeout
()
int
FmTools
::
GetRequestTimeout
()
{
{
return
m_config
->
value
(
INIPATH_TIMEOUT1
,
20
).
toInt
()
*
1000
;
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
int
requestTimeout
=
updateSettings
->
value
(
INIPATH_TIMEOUT1
,
20
).
toInt
()
*
1000
;
delete
updateSettings
;
return
requestTimeout
;
}
}
QString
FmTools
::
GetUpdateUrl
()
QString
FmTools
::
GetUpdateUrl
()
{
{
return
m_config
->
value
(
INIPATH_UPDATE_URL
).
toString
();
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
QString
updateUrl
=
updateSettings
->
value
(
INIPATH_UPDATE_URL
).
toString
();
delete
updateSettings
;
return
updateUrl
;
}
}
QString
FmTools
::
GetReportUrl
()
QString
FmTools
::
GetReportUrl
()
{
{
return
m_config
->
value
(
INIPATH_REPORT_URL
).
toString
();
QSettings
*
updateSettings
=
new
QSettings
(
m_updateIniPath
,
QSettings
::
IniFormat
);
QString
reportUrl
=
updateSettings
->
value
(
INIPATH_REPORT_URL
).
toString
();
delete
updateSettings
;
return
reportUrl
;
}
}
QByteArray
FmTools
::
GetUpdateData
()
QByteArray
FmTools
::
GetUpdateData
()
...
...
fmscupd/fmtools.h
View file @
27a24851
...
@@ -65,6 +65,7 @@ private:
...
@@ -65,6 +65,7 @@ private:
private
:
private
:
QSettings
*
m_config
;
QSettings
*
m_config
;
QString
m_updateIniPath
;
QString
m_partnerId
;
// 商户编号
QString
m_partnerId
;
// 商户编号
QString
m_siIniPath
;
// 门店信息配置文件路径
QString
m_siIniPath
;
// 门店信息配置文件路径
...
...
fmscupd/main.cpp
View file @
27a24851
...
@@ -5,13 +5,24 @@
...
@@ -5,13 +5,24 @@
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
FmService
service
(
argc
,
argv
);
//
FmService service(argc, argv);
service
.
exec
();
//
service.exec();
// QCoreApplication a(argc, argv);
QCoreApplication
a
(
argc
,
argv
);
// FmControl m_control;
// m_control.Start();
// 初始化日志
// return a.exec();
QString
logDir
=
QString
(
"%1/log"
).
arg
(
QCoreApplication
::
applicationDirPath
());
// FmTools::GetInstance();
QDir
().
mkdir
(
logDir
);
Logger
&
logger
=
Logger
::
instance
();
logger
.
setLoggingLevel
(
TraceLevel
);
QString
logPath
=
QString
(
"%1/%2"
).
arg
(
logDir
,
"log.txt"
);
DestinationPtr
fileDst
(
DestinationFactory
::
MakeFileDestination
(
logPath
,
EnableLogRotation
,
MaxSizeBytes
(
2
*
1024
*
1024
),
MaxOldLogCount
(
50
)));
logger
.
addDestination
(
fileDst
);
FmControl
m_control
;
m_control
.
Start
();
return
a
.
exec
();
// FmTools::GetInstance();
}
}
lib/libquazip5.a
0 → 100644
View file @
27a24851
File added
lib/libz.a
0 → 100644
View file @
27a24851
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment