2018-05-16 14:17:27 +03:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Tcl ignores the next line -*- tcl -*- \
|
|
|
|
|
exec wish "$0" -- "$@"
|
|
|
|
|
|
|
|
|
|
######################################################
|
|
|
|
|
# Rac GUI
|
2019-09-30 11:02:57 +03:00
|
|
|
|
# 1C RAC (tm) grafical user interface
|
2019-07-24 09:48:07 +03:00
|
|
|
|
# Distributed under GNU Public License
|
2018-05-16 14:17:27 +03:00
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
2019-09-30 11:02:57 +03:00
|
|
|
|
# Home page: https://nuk-svk.ru
|
|
|
|
|
# Git repos: https://bitbucket.org/svk28/rac-gui
|
2019-07-24 09:48:07 +03:00
|
|
|
|
#
|
2019-09-30 11:52:25 +03:00
|
|
|
|
# Version: 1.1.0
|
2019-11-27 16:29:29 +03:00
|
|
|
|
# Release: 2
|
2019-07-24 09:48:07 +03:00
|
|
|
|
#
|
2018-05-16 14:17:27 +03:00
|
|
|
|
######################################################
|
2019-09-30 11:02:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# определим текущую версию и релиз
|
|
|
|
|
set f [open $argv0 "RDONLY"]
|
|
|
|
|
while {[gets $f line] >=0} {
|
|
|
|
|
if [regexp -nocase -all -- {version: ([0-9]+?.[0-9]+?.[0-9]+?)} $line match v1] {
|
|
|
|
|
set racgui_version $v1
|
|
|
|
|
}
|
|
|
|
|
if [regexp -nocase -all -- {release: ([0-9]+?)} $line match v1] {
|
|
|
|
|
set racgui_release $v1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
close $f
|
|
|
|
|
|
|
|
|
|
package require msgcat
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Устанавливаем текущий каталог
|
2022-07-21 10:19:55 +03:00
|
|
|
|
set dir(root) /usr/share/rac-gui
|
2019-07-23 16:25:28 +03:00
|
|
|
|
|
2019-09-30 11:02:57 +03:00
|
|
|
|
set dir(doc) [file join $dir(root) doc]
|
|
|
|
|
|
|
|
|
|
# Устанавливаем рабочий каталог, если его нет то создаём.
|
|
|
|
|
# Согласно спецификации XDG проверяем наличие переменных и каталогов
|
|
|
|
|
if [info exists env(XDG_CONFIG_HOME)] {
|
|
|
|
|
set dir(work) [file join $env(XDG_CONFIG_HOME) rac_gui]
|
|
|
|
|
} elseif [file exists [file join $env(HOME) .config]] {
|
|
|
|
|
set dir(work) [file join $env(HOME) .config rac_gui]
|
|
|
|
|
} else {
|
|
|
|
|
set dir(work) [file join $env(HOME) .rac_gui]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {[file exists $dir(work)] == 0} {
|
2018-05-20 18:03:02 +03:00
|
|
|
|
file mkdir $dir(work)
|
|
|
|
|
}
|
2019-09-30 11:02:57 +03:00
|
|
|
|
# Проверяем старые конфиги и при наличии переносим
|
|
|
|
|
if {[file exists [file join $env(HOME) .rac_gui]] ==1 && $dir(work) ne [file join $env(HOME) .rac_gui]} {
|
|
|
|
|
cd [file join $env(HOME) .rac_gui]
|
|
|
|
|
foreach f [glob -type f *] {
|
|
|
|
|
if {![file exists [file join $dir(work) $f]]} {
|
|
|
|
|
puts "File copy - [file copy $f $dir(work)]"
|
|
|
|
|
file rename $f [list $f old]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cd $env(HOME)
|
|
|
|
|
#file rename -force [file join $env(HOME) .rac_gui] [file join $env(HOME) .rac_gui.old]
|
|
|
|
|
file delete -force [file join $env(HOME) .rac_gui]
|
|
|
|
|
tk_messageBox -message "[::msgcat::mc "All files from old working dir will be moved into new location:"]\n$dir(work)" -icon info -type ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
puts "Work dir is $dir(work)"
|
|
|
|
|
|
2018-07-24 09:56:02 +03:00
|
|
|
|
# каталог с модулями
|
2022-07-21 12:53:44 +03:00
|
|
|
|
set dir(lib) "[file join $dir(root) lib]"
|
2018-05-20 18:03:02 +03:00
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный
|
2018-05-20 18:03:02 +03:00
|
|
|
|
if {[file exists [file join $dir(work) rac_gui.cfg]] ==0} {
|
2019-09-30 11:02:57 +03:00
|
|
|
|
file copy [file join $dir(root) rac_gui.cfg] [file join $dir(work) rac_gui.cfg]
|
2018-05-20 18:03:02 +03:00
|
|
|
|
}
|
|
|
|
|
source [file join $dir(work) rac_gui.cfg]
|
2018-08-06 08:44:13 +03:00
|
|
|
|
|
|
|
|
|
::msgcat::mclocale $default(locale)
|
|
|
|
|
::msgcat::mcload [file join $dir(lib) msg]
|
|
|
|
|
|
2018-06-15 13:11:09 +03:00
|
|
|
|
|
2018-06-22 14:13:19 +03:00
|
|
|
|
set cluster_user ""
|
|
|
|
|
set cluster_pwd ""
|
|
|
|
|
set agent_user ""
|
|
|
|
|
set agent_pwd ""
|
2018-05-16 14:17:27 +03:00
|
|
|
|
## LOAD FILE ##
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Загружаем модули кроме gui.tcl так как его надо загрузить последним
|
2018-05-16 14:17:27 +03:00
|
|
|
|
foreach modFile [lsort [glob -nocomplain [file join $dir(lib) *.tcl]]] {
|
|
|
|
|
if {[file tail $modFile] ne "gui.tcl"} {
|
|
|
|
|
source $modFile
|
|
|
|
|
puts "Loaded module $modFile"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
source [file join $dir(lib) gui.tcl]
|
2018-05-20 18:03:02 +03:00
|
|
|
|
source [file join $dir(work) rac_gui.cfg]
|
|
|
|
|
|
2019-09-30 11:02:57 +03:00
|
|
|
|
CheckVariablesSet
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Читаем файл со списком серверов 1С
|
2019-09-30 11:02:57 +03:00
|
|
|
|
#set serversList [dict create servers]
|
|
|
|
|
if [file exists [file join $dir(work) 1c_srv_new.cfg]] {
|
|
|
|
|
set f_new [open [file join $dir(work) 1c_srv_new.cfg] "RDONLY"]
|
|
|
|
|
set str ""
|
|
|
|
|
while {[gets $f_new line] >=0} {
|
|
|
|
|
append str " [string trim $line]"
|
|
|
|
|
}
|
|
|
|
|
if {$str ne ""} {
|
|
|
|
|
set str [string map {"\{ " "\{" " \}" "\}"} $str]
|
|
|
|
|
dict set servers_list servers $str
|
|
|
|
|
close $f_new
|
|
|
|
|
puts $servers_list
|
|
|
|
|
puts [dict get $servers_list servers]
|
|
|
|
|
dict for {host host_data} [dict get $servers_list servers] {
|
|
|
|
|
.frm_tree.tree insert {} end -id "server::$host" \
|
|
|
|
|
-text [dict get $host_data name] -values "$host"
|
|
|
|
|
puts "$host > $host_data"
|
|
|
|
|
puts [dict get $host_data name]
|
|
|
|
|
set rac_cmd_for_host($host) [dict get $host_data rac_cmd]
|
2018-09-12 12:46:20 +03:00
|
|
|
|
}
|
2019-09-30 11:02:57 +03:00
|
|
|
|
} else {
|
|
|
|
|
set servers_list ""
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
set servers_list ""
|
2018-05-20 18:03:02 +03:00
|
|
|
|
}
|