__DATA__
-rule dot_ssh_on { A D } {
- home_dir_on A H
- directory_in H '.ssh' D
- mode D '0700'
+rule dot_ssh_on { Account DotSshDir } {
+ home_dir_on Account HomeDir
+ directory_in HomeDir '.ssh' DotSshDir
+ mode DotSshDir '0700'
}
-rule authorized_keys_on { A F } {
- dot_ssh_on A D
- file_in D 'authorized_keys' F
- mode F '0600'
+rule authorized_keys_on { Account AuthorizedKeysFile } {
+ dot_ssh_on Account DotSshDir
+ file_in DotSshDir 'authorized_keys' AuthorizedKeysFile
+ mode AuthorizedKeysFile '0600'
}
-rule key_installed_on { A K } {
- authorized_keys_on A F
- contains_line F K
+rule key_installed_on { Account PubKeyLine } {
+ authorized_keys_on Account AuthorizedKeysFile
+ contains_line AuthorizedKeysFile PubKeyLine
}
-rule key_not_installed_on { A K } {
- authorized_keys_on A F
- not_contains_line F K
+rule key_not_installed_on { Account PubKeyLine } {
+ authorized_keys_on Account AuthorizedKeysFile
+ not_contains_line AuthorizedKeysFile PubKeyLine
}
-rule my_config_dir D {
- home_dir_on '' H
- directory_in H '.keymangler' D
+rule my_config_dir ConfigDir {
+ home_dir_on '' HomeDir
+ directory_in HomeDir '.keymangler' ConfigDir
}
-rule my_config_file { C F } {
- my_config_dir D
- file_in D C F
+rule my_config_file { ConfigType ConfigFile } {
+ my_config_dir ConfigDir
+ file_in ConfigDir ConfigType ConfigFile
}
-rule config_contains_line { C L } {
- my_config_file C F
- contains_line F L
+rule config_contains_line { ConfigType Line } {
+ my_config_file ConfigType ConfigFile
+ contains_line ConfigFile Line
}
-rule config_not_contains_line { C L } {
- my_config_file C F
- not_contains_line F L
+rule config_not_contains_line { ConfigType Line } {
+ my_config_file ConfigType ConfigFile
+ not_contains_line ConfigFile Line
}
-rule known_account A { config_contains_line 'accounts' A }
-rule known_key K { config_contains_line 'keys' K }
-rule known_dead D { config_contains_line 'keys.dead' D }
+rule known_account Account {
+ config_contains_line 'accounts' Account
+}
+
+rule known_key Key {
+ config_contains_line 'keys' Key
+}
+rule known_dead DeadKey {
+ config_contains_line 'keys.dead' DeadKey
+}
-rule not_known_account A { config_not_contains_line 'accounts' A }
-rule not_known_key K { config_not_contains_line 'keys' K }
-rule not_known_dead D { config_not_contains_line 'keys.dead' D }
+rule not_known_account Account {
+ config_not_contains_line 'accounts' Account
+}
+rule not_known_key Key {
+ config_not_contains_line 'keys' Key
+}
+rule not_known_dead DeadKey {
+ config_not_contains_line 'keys.dead' DeadKey
+}
-rule all_known_installed_on A {
- foreach K { known_key K } { key_installed_on A K }
+rule all_known_installed_on Account {
+ foreach Key { known_key Key } {
+ key_installed_on Account Key
+ }
}
-rule all_dead_not_installed_on A {
- foreach K { known_dead K } { key_not_installed_on A K }
+rule all_dead_not_installed_on Account {
+ foreach Key { known_dead Key } {
+ key_not_installed_on Account Key
+ }
}
-rule account_synchronized A {
- all_known_installed_on A
- all_dead_not_installed_on A
+rule account_synchronized Account {
+ all_known_installed_on Account
+ all_dead_not_installed_on Account
}
rule all_synchronized {} {
- foreach A { known_account A } { account_synchronized A }
+ foreach Account { known_account Account } {
+ account_synchronized Account
+ }
}
-rule unknown_installed_on { A K } {
- key_installed_on A K
- not { known_key K }
- not { known_dead K }
+rule unknown_installed_on { Account Key } {
+ key_installed_on Account Key
+ not { known_key Key }
+ not { known_dead Key }
}
-rule known_installed_on { A K } {
- key_installed_on A K
- known_key K
+rule known_installed_on { Account Key } {
+ key_installed_on Account Key
+ known_key Key
}
-rule dead_installed_on { A K } {
- key_installed_on A K
- known_dead K
+rule dead_installed_on { Account Key } {
+ key_installed_on Account Key
+ known_dead Key
}
oo::class create ConfigSet {
namespace import ::DX::*
variable type $mytype
}
- method learn V {
+ method add Value {
variable type
- ensure "known_$type {'$V'}"
+ ensure "known_$type {'$Value'}"
}
- method forget V {
+ method rm Value {
variable type
- ensure "not_known_$type {'$V'}"
+ ensure "not_known_$type {'$Value'}"
}
method list {} {
variable type
- query* "known_$type V" {puts $V}
+ query* "known_$type Value" {puts $Value}
}
}
method status {} {
query* {
- known_account A
- findall Known K { known_installed_on A K }
- findall Unknown U { unknown_installed_on A U }
- findall Dead D { dead_installed_on A D }
+ known_account Account
+ findall KnownKeys Key {
+ known_installed_on Account Key
+ }
+ findall UnknownKeys Unknown {
+ unknown_installed_on Account Unknown
+ }
+ findall DeadKeys Dead {
+ dead_installed_on Account Dead
+ }
} {
puts "Host: $A"
- foreach k $Known { puts " Known: [lindex $k 2]" }
- foreach u $Unknown { puts " Unknown: [lindex $u 2]" }
- foreach d $Dead { puts " Dead: [lindex $d 2]" }
+ foreach key $KnownKeys {
+ puts " Known: [lindex $key 2]"
+ }
+ foreach unknown $UnknownKeys {
+ puts " Unknown: [lindex $unknown 2]"
+ }
+ foreach dead $DeadKeys {
+ puts " Dead: [lindex $dead 2]"
+ }
puts ""
}
}
export -n
- method sync {{account -}} {
+ method push {{account -}} {
variable mode
if {"$account" eq "-"} {
$mode { all_synchronized }
$mode "account_synchronized {'$account'}"
}
}
+
+ method help {} {
+ puts {Usage:}
+ puts {}
+ puts { # Config commands}
+ puts { $ km {key,dead,account} add 'new value'}
+ puts { $ km {key,dead,account} rm 'old value'}
+ puts { $ km {key,dead,account} list}
+ puts {}
+ puts { # What keys are installed where?}
+ puts { $ km status}
+ puts {}
+ puts { # Update remote authorized_keys files (-n is dry-run)}
+ puts { $ km [-n] sync user@host}
+ puts { $ km [-n] sync}
+ puts {}
+ }
}
KeyMangler create km