Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AD-Control-Golang
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
AD-Control-Golang
Commits
96fa9d14
Commit
96fa9d14
authored
Aug 10, 2020
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v1.6.0 域用户备份升级
parent
8d7b13f1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
53 deletions
+30
-53
adct/adct.go
+1
-7
daemon/daemon.go
+2
-0
public/env.go
+2
-2
public/msg_deal.go
+14
-37
public/msg_init.go
+5
-4
public/public.go
+2
-1
users/menu.go
+1
-1
wxwork/wxwork.go
+3
-1
No files found.
adct/adct.go
View file @
96fa9d14
...
...
@@ -15,10 +15,10 @@ func main(){
}
else
{
logpath
=
pub
.
Dir_userprofile
+
`\`
}
//pub.AutoFillInWeDriveDir()
}
pub
.
Loger
=
pub
.
NewLoger
(
logpath
+
`adct.log`
)
//pub.AutoFillInWeDriveDir()
//pub.PrintLog("start adct")
var
backupText
=
flag
.
String
(
pub
.
Msg_Backup
,
""
,
"backup status to AD"
)
...
...
@@ -66,12 +66,6 @@ func flag_exec(s * string){
func
flag_hour
(){
nh
:=
pub
.
GetHour
()
switch
nh
{
case
0
:
if
pub
.
RunAsUser
(
pub
.
User_name
)
&&
pub
.
IsPrimaryUser
(
pub
.
User_name
){
pub
.
SendServerReport
(
pub
.
Msg_Report_StartBak
)
}
break
default
:
pub
.
Execcmd_nowait
(
`即将关机,如需取消,点击小工具-电源管理-取消自动关机 或运行Z:\tools\【工具】取消关机.bat`
)
pub
.
Execcmd_nowait
(
`shutdown -s -t 300`
)
...
...
daemon/daemon.go
View file @
96fa9d14
...
...
@@ -29,6 +29,8 @@ func deamonRun(){
// 新建 读取流
bmsg
,
_
:=
bufio
.
NewReader
(
conn
)
.
ReadBytes
(
pub
.
EndSign
)
if
len
(
bmsg
)
==
0
{
continue
}
//pub.PrintLog(string(bmsg))
// 获取ip
ip
:=
pub
.
GetConnIP
(
conn
.
RemoteAddr
())
...
...
public/env.go
View file @
96fa9d14
...
...
@@ -8,7 +8,7 @@ const DaemonListen string = ":" + DaemonPort
const
ADServerDaemon
string
=
Host_adserver
+
DaemonListen
const
WxwrokDaemon
string
=
":16823"
const
RandMax
int
=
60
const
Version
string
=
"1.
5.2
"
const
Version
string
=
"1.
6.0
"
// user //
...
...
@@ -72,7 +72,7 @@ const App_Sync_dir string = `C:\Progra~1\zhiwei\AllWay_Sync\Bin\syncappw.exe
// backup //
var
Bak_Version
string
=
"0
7
10"
var
Bak_Version
string
=
"0
8
10"
// reg info //
...
...
public/msg_deal.go
View file @
96fa9d14
...
...
@@ -58,18 +58,19 @@ func (rep *MJreport)Msg_Deal() interface{} {
switch
rep
.
Instruction
{
case
Msg_Report_StartBak
:
case
Msg_Report_InitBak
:
if
!
IsPrimaryUser
(
rep
.
Username
)
||
RunAsPC
(
rep
.
Username
){
return
nil
}
return
GJbackup
()
case
Msg_Report_ReadyBak
:
PrintLog
(
rep
.
Computername
,
"开始备份"
)
return
rep
case
Msg_Report_OverBak
:
rep
.
Reg_Write_ADDC
(
Reg_Name_BackupOverTime
,
UnixTimeParse
(
&
rep
.
Timestamp
))
rep
.
Pskill
(
App_Sync
)
SysMsgBox
(
rep
.
Computername
,
`备份完成,即将关机,如需取消关机,运行Z:\tools\【工具】取消关机.bat或在小工具-电源管理-取消自动关机`
)
return
GJexec
(
Msg_Exec_TurnOffPC
)
PrintLog
(
rep
.
Computername
,
"结束备份"
)
return
rep
case
Msg_Report_WillTurnOffPC
:
rep
.
Reg_Write_ADDC
(
...
...
@@ -212,56 +213,32 @@ func (bak * MJbackup)Msg_Deal() interface{}{
switch
bak
.
Instruction
{
case
Msg_Backup_Status_
Star
t
:
case
Msg_Backup_Status_
Ini
t
:
bak
.
Timestamp
=
NowTimestamp
()
bak
.
Username
=
User_name
bak
.
Computername
=
User_computername
bak
.
Explain
=
"Backup
Star
t"
bak
.
Explain
=
"Backup
Ini
t"
bak
.
Instruction
=
Msg_Backup_Status_Continue
wetype
,
weid
,
err
:=
GetWeDriveVersion
()
homefolder
:=
TrimPrefix
(
Dir_userprofile
,
`C:\Users\`
)
if
err
!=
nil
{
SendServerError
(
err
)
wetype
=
1
weid
=
"1"
}
// 确定备份版本
var
filename
string
switch
wetype
{
case
1
:
filename
=
"profile_vdocu.xml"
case
2
:
filename
=
"profile_vappdata.xml"
default
:
return
GJerror
(
Error_Null_Folder_WeDrive
)
}
// 如果版本不是最新
currentVersion
:=
Reg_Query_DC
(
Reg_Name_BackupVersion
)
if
(
bak
.
Version
!=
currentVersion
)
||
NotExist
(
File_Sync_profile
)
||
NotExist
(
File_Sync_settings
)
{
NotExist
(
File_Sync_profile
){
// 1 复制 最新文件
if
_
,
err
:=
CopyFile
(
Dir_Sync_Config
+
filename
,
SMB_ADSoftPlusSync
+
filename
);
err
!=
nil
{
return
GJerror
(
err
)
}
if
_
,
err
:=
CopyFile
(
File_Sync_settings_full
,
SMB_ADSoftPlusSync
+
File_Sync_settings
);
err
!=
nil
{
return
GJerror
(
err
)
}
// 2 生成 个性 文件
if
err
:=
CreateSelfXML
(
homefolder
,
Dir_Sync_Config
+
filename
,
wetype
,
weid
);
err
!=
nil
{
if
_
,
err
:=
CopyFile
(
File_Sync_profile_full
,
SMB_ADSoftPlusSync
+
File_Sync_profile
);
err
!=
nil
{
return
GJerror
(
err
)
}
// 3 更新 新版本
Reg_Write_DC
(
Reg_Name_BackupVersion
,
bak
.
Version
)
bak
.
Explain
=
"Backup update config"
}
ExistFolder
(
Dir_DCSave
+
`\`
+
homefolder
)
PntInfo
(
bak
.
Explain
)
SendServer
(
bak
)
return
nil
...
...
public/msg_init.go
View file @
96fa9d14
...
...
@@ -44,15 +44,16 @@ const Msg_Report_WillTurnOnPC string = WillTurnOnPC
const
Msg_Report_WillTurnOffPC
string
=
WillTurnOffPC
const
Msg_Report_OverCopyToWeDrive
string
=
"overcopytowedrive"
const
Msg_Report_OverCopyToDeptShare
string
=
"OverCopyToDeptShare"
const
Msg_Report_StartBak
string
=
"startbak"
const
Msg_Report_OverBak
string
=
"stopbak"
const
Msg_Report_ReadyBak
string
=
"readybak"
const
Msg_Report_InitBak
string
=
"initbak"
const
Msg_Report_OverBak
string
=
"overbak"
const
Msg_Report_DCInfo
string
=
"DCInfo"
// msg backup type //////////////////////////////////////////////////////////////
const
Msg_Backup_Status_
Start
string
=
"star
t"
const
Msg_Backup_Status_
Init
string
=
"ini
t"
const
Msg_Backup_Status_Continue
string
=
"Continue"
const
Msg_Backup_Status_Run
string
=
"run"
...
...
@@ -246,7 +247,7 @@ func (bak * MJbackup)init() {
bak
.
Timestamp
=
NowTimestamp
()
bak
.
MsgType
=
Msg_Backup
bak
.
Version
=
Bak_Version
bak
.
Instruction
=
Msg_Backup_Status_
Star
t
bak
.
Instruction
=
Msg_Backup_Status_
Ini
t
}
...
...
public/public.go
View file @
96fa9d14
...
...
@@ -16,6 +16,7 @@ func GetMsgType(b []byte)string{
//{"msgtype":"report","...":"..."}
// 提取第一个冒号后的第二位和第一个逗号的前一位
// 也就是msgtype的内容
PrintLog
(
string
(
b
))
return
string
(
b
[
bytes
.
IndexByte
(
b
,
':'
)
+
2
:
bytes
.
IndexByte
(
b
,
','
)
-
1
])
}
...
...
@@ -146,7 +147,7 @@ func AutoGetWeDriveDir() (string,error) {
}
func
AutoFillInWeDriveDir
()
{
if
RunAs
User
(
User_name
){
Exit
()
}
if
RunAs
PC
(
User_name
){
Exit
()
}
d
:=
Reg_Query_DC
(
Reg_Name_WeDriveDir
)
if
d
==
""
||
NotExist
(
d
){
...
...
users/menu.go
View file @
96fa9d14
...
...
@@ -363,7 +363,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){
}
// 为子按钮 添加事件
na
.
Triggered
()
.
Attach
(
func
(){
pub
.
OpenWindow
(
pub
.
SMB_ADMain
+
`\`
+
deptshare
+
`\`
+
wokrer
);
return
})
na
.
Triggered
()
.
Attach
(
func
(){
pub
.
OpenWindow
(
pub
.
SMB_ADMain
+
deptshare
+
`\`
+
wokrer
);
return
})
// 将 子按钮 添加到 菜单
nm
.
Actions
()
.
Add
(
na
)
...
...
wxwork/wxwork.go
View file @
96fa9d14
...
...
@@ -172,12 +172,14 @@ func wxMsgDealEvent(name, userid,eventkey * string) string {
case
pub
.
WXEK_zwDevopsPowerStatus
:
pub
.
SendWxworkTextToAUserWithName
(
*
name
,
*
userid
,
"收到查询指令,正在处理"
)
result
,
err
=
pub
.
SendServer
(
pub
.
GJwxworkText
(
name
,
userid
,
pub
.
Msg_Wxwork_Status
))
default
:
return
""
}
if
err
!=
nil
{
return
fmt
.
Sprintf
(
"%s"
,
err
)
pub
.
PrintLog
(
fmt
.
Sprintf
(
"%s"
,
err
))
return
Error_WXWork_Down_STR
}
pub
.
ParseJsonBody
(
result
,
&
wxwork
)
...
...
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