138 lines
4.6 KiB
Tcl
Executable File
138 lines
4.6 KiB
Tcl
Executable File
#!/opt/tarantella/bin/bin/ttatcl
|
|
# ttaRestoreDS.tcl
|
|
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo --- license GNU GPL
|
|
# stta: (@#) 1.31051043346- [2004_01_29_102036]
|
|
|
|
set file $argv
|
|
set attribute ""
|
|
set tfn ""
|
|
set object ""
|
|
set ouFile tta.orgUnits
|
|
set cnFile tta.containers
|
|
set personFile tta.persons
|
|
set serverFile tta.server
|
|
set applFile tta.applications
|
|
set groupFile tta.group
|
|
set linkFile tta.link
|
|
|
|
# We are opening all neccessery files
|
|
set ouFileFp [open $ouFile w]
|
|
set cnFileFp [open $cnFile w]
|
|
set personFileFp [open $personFile w]
|
|
set serverFileFp [open $serverFile w]
|
|
set appFileFp [open $applFile w]
|
|
set groupFileFp [open $groupFile w]
|
|
set linkFileFp [open $linkFile w]
|
|
|
|
for_file line $file {
|
|
|
|
regsub -all {""} $line {"} line
|
|
|
|
if [regexp {Attributes for .*/_ens/(.*):} $line all newtfn ] {
|
|
|
|
if [clength $tfn] {
|
|
set fp $appFileFp
|
|
if [cequal $object new_group] { set fp $groupFileFp }
|
|
if [cequal $object new_host] { set fp $serverFileFp }
|
|
if [cequal $object new_orgunit] { set fp $ouFileFp }
|
|
if [cequal $object new_person] { set fp $personFileFp }
|
|
|
|
if [cequal $object new_container] {
|
|
set fp $cnFileFp
|
|
puts $fp "$object --name \"$tfn\" "
|
|
} else {
|
|
puts $fp "$object --name \"$tfn\" $attribute"
|
|
}
|
|
}
|
|
set tfn $newtfn
|
|
set attribute ""
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
if [regexp {scottaWebtopContents: (.*)} $line all linkList ] {
|
|
# add_links
|
|
regsub -all {,} $linkList { } linkList
|
|
puts $linkFileFp "add_link --name \"$tfn\" --link $linkList"
|
|
continue
|
|
}
|
|
if [regexp {links: (.*)} $line all linkList ] {
|
|
# add_links
|
|
regsub -all {,} $linkList { } linkList
|
|
puts $linkFileFp "add_link --name \"$tfn\" --link $linkList"
|
|
continue
|
|
}
|
|
if [regexp -nocase {objectclass: (.*)} $line all class ] {
|
|
# if split is need for some reason ...
|
|
# set class0 [lindex [split $class ,] 0]
|
|
# set class1 [lindex [split $class ,] 1]
|
|
# set class2 [lindex [split $class ,] 2]
|
|
# set class3 [lindex [split $class ,] 3]
|
|
# echo "$class ( $class0 - $class1 - $class2 -- $class3 )"dd
|
|
switch $class {
|
|
organizationalunit,scottaauxorganizationalunit,top { set object new_orgunit }
|
|
container,top { set object new_container }
|
|
inetorgperson,scottaauxperson,organizationalperson,person,top { set object new_person}
|
|
scottahtmldocument,top { set object new_doc}
|
|
scottaxapplication,scottaapplication,top { set object new_xapp}
|
|
scottagroupofnames,top { set object new_group}
|
|
scottacharacterapplication,scottaapplication,top { set object new_charapp}
|
|
scottawindowsapplication,scottaapplication,top { set object new_windowsapp }
|
|
scottawindowsapplication,scottaxapplication,scottaapplication,top { set object new_windowsapp }
|
|
device,scottaauxhost,top { set object new_host }
|
|
default { set object undef ; echo UNDEF \"$class\" in $line; exit}
|
|
}
|
|
|
|
|
|
continue
|
|
}
|
|
if [regexp {(.*): (.*)} $line all attr value ] {
|
|
# Ignore
|
|
if [regexp {^windowclose$} $attr ] { continue }
|
|
if [regexp {^share$} $attr ] { continue }
|
|
if [regexp {^passtype$} $attr ] { continue }
|
|
if [regexp {^Organizational Unit$} $attr ] { continue }
|
|
|
|
# Modify
|
|
|
|
if [regexp {^quality$} $attr ] {
|
|
if [cequal $object new_windowsapp ] { continue }
|
|
}
|
|
if [regexp {^member$} $attr ] { regsub -all {,} $value { } value }
|
|
if [regexp {^appserv$} $attr ] { regsub -all {,} $value { } value }
|
|
if [regexp {^Name$} $attr ] { set attr description }
|
|
if [regexp {^scottaInheritWebtop$} $attr ] { set attr inherit }
|
|
|
|
if [regexp {^env$} $attr ] {
|
|
append attribute "--$attr \"$value\" "
|
|
} else {
|
|
append attribute "--$attr $value "
|
|
}
|
|
} else {
|
|
if [regexp {>} $line ] { continue }
|
|
append attribute "$line "
|
|
}
|
|
}
|
|
if [clength $tfn] {
|
|
set fp $appFileFp
|
|
if [cequal $object new_group] { set fp $groupFileFp }
|
|
if [cequal $object new_host] { set fp $serverFileFp }
|
|
if [cequal $object new_orgunit] { set fp $ouFileFp }
|
|
if [cequal $object new_person] { set fp $personFileFp }
|
|
|
|
if [cequal $object new_container] {
|
|
set fp $cnFileFp
|
|
puts $fp "$object --name \"$tfn\" "
|
|
} else {
|
|
puts $fp "$object --name \"$tfn\" $attribute"
|
|
}
|
|
}
|
|
close $ouFileFp
|
|
close $cnFileFp
|
|
close $personFileFp
|
|
close $serverFileFp
|
|
close $appFileFp
|
|
close $groupFileFp
|
|
close $linkFileFp
|