Closed baldoarturo closed 2 years ago
Allright, I have done this to get it on base64
class UFiber < Oxidized::Model
prompt /.+@.+:~\$/
cmd 'cat /tmp/config'
cmd :all do |cfg|
cfg.lines.to_a[1..-2].join
end
cfg :ssh do
post_login "curl -s --output /dev/null --location --insecure --data 'username=#{@node.auth[:username]}&password=#{@node.auth[:password]}' --cookie-jar /tmp/cookies https://localhost"
post_login "curl -s --output /dev/null --location --insecure --cookie /tmp/cookies https://localhost/api/edge/config/save.json"
post_login "curl -s --location --insecure --cookie /tmp/cookies https://localhost/files/config/ | base64 > /tmp/config"
pre_logout 'exit'
end
end
Not sure if we can decode the output to the original binary tar.gz after the cmd block gets the output @ytti if you have any ideas, I would love to send a pull request for this
I sent #2440 for this
Those hosts execute Ubiquiti EdgeOS inside, but they keep part of the config on separate files in the filesystem. Most of the config is done (and pulled) via HTTP. There is an HTTP endpoint which downloads a config backup, in a tar.gz file
So, I know I can do something like this, manually:
To login: curl -s --output /dev/null --location --insecure --data 'username=myusername&password=mypassword' --cookie-jar /tmp/cookies https://hostname I saved cookies in /tmp/cookies
To request the device to generate a config backup curl --location --insecure --cookie /tmp/cookies https://hostname/api/edge/config/save.json
To actually pull that config backup curl -s --location --insecure --cookie /tmp/cookies --output /tmp/hostname.tar.gz https://#{@node.ip}/files/config/
This works manually and I have even automated this in Python... but I don't know anything about Ruby. I tried this:
So.. the cfg parth calls curl locally, but I don't know how to instruct oxidized to pull the backup file I tried encoding it in base64 and maybe decoding later as this is a binary file... without luck ye Any insight? thanks!