2018-11-30 20:20:43 +00:00
|
|
|
package shell
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"git.linuxrocker.com/mattburchett/go_tab-magic/pkg/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func CreateShellAliases(data []string, username string, config config.Config) {
|
|
|
|
for _, i := range data {
|
|
|
|
splitStrings := strings.Split(i, " ")
|
|
|
|
hostname := splitStrings[0]
|
|
|
|
txt := splitStrings[2]
|
|
|
|
|
|
|
|
jump := config.JumpHost
|
|
|
|
stringSplit := config.SplitString
|
|
|
|
|
|
|
|
remoteUser := username
|
|
|
|
sudo := "sudo su -"
|
|
|
|
rac := "ssh"
|
|
|
|
racOpts := "-AXt -l"
|
|
|
|
hop := "ssh -AXt"
|
|
|
|
prerac := ""
|
|
|
|
|
|
|
|
host := strings.TrimRight(hostname, stringSplit)
|
2018-11-30 20:24:42 +00:00
|
|
|
fqdn := hostname
|
2018-11-30 20:20:43 +00:00
|
|
|
|
|
|
|
greentext := "tput -T xterm setaf 2; "
|
|
|
|
// redtext := "tput -T xterm setaf 1; "
|
|
|
|
resettext := "tput -T xterm sgr0; "
|
|
|
|
message := fmt.Sprintf("%vecho \"Authenticating as: %v\";%v", greentext, remoteUser, resettext)
|
|
|
|
|
|
|
|
if txt == "" {
|
2018-11-30 20:21:31 +00:00
|
|
|
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
2018-11-30 20:20:43 +00:00
|
|
|
} else {
|
2018-11-30 20:21:31 +00:00
|
|
|
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
2018-11-30 20:20:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|