Skip to content

Instantly share code, notes, and snippets.

@highgain86j
Last active January 28, 2019 01:00
Show Gist options
  • Save highgain86j/58b399413c6f9eaac7738d47190e4f56 to your computer and use it in GitHub Desktop.
Save highgain86j/58b399413c6f9eaac7738d47190e4f56 to your computer and use it in GitHub Desktop.
edgeos_curl_update.sh
#!/bin/bash
wrapper_op=/opt/vyatta/bin/vyatta-op-cmd-wrapper
wrapper_cfg=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper_cfg
function write_update_main(){
local temp_upgrade_scr=/config/update.sh
echo '#!/bin/bash' | sudo tee ${temp_upgrade_scr}
echo 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' | sudo tee -a ${temp_upgrade_scr}
cat << EOF | while read line; do echo "${wrapper_cfg} ${line}" | sudo tee -a ${temp_upgrade_scr}; done
begin
delete interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth4 poe output off
delete service gui
delete service ssh
delete system syslog
delete system time-zone
commit
EOF
cat << EOF | sudo tee -a ${temp_upgrade_scr}
${wrapper_op} add system image https://dl.ubnt.com/firmwares/edgemax/v1.10.x/ER-e50.v1.10.8.5142457.tar
find /config/ -maxdepth 1 -type f -name config.boot\* -delete -print
mv /config/config.bak /config/config.boot
crontab -r
rm ${temp_upgrade_scr}
${wrapper_op} reboot now
EOF
echo "@reboot ${temp_upgrade_scr}" | sudo crontab -
${wrapper_op} reboot now
}
mv /config/config.boot /config/config.bak
${wrapper_op} reboot now
write_update_main
#mv /config/config.bak /config/config.boot
#${wrapper_op} reboot now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment