Developing lightweight computation at the DSG edge

Commit 06896585 authored by p4u's avatar p4u
Browse files

Minor cosmetic changes in qmp_control

Improve safe_apply and save_state
parent e9d056d1
......@@ -109,25 +109,29 @@ configure_all() {
apply_netserver
}
safe_test() {
[ -e "/tmp/qmp.save.tar.gz" ] && echo "Found saved state! Make sure you want to use it" \
safe_apply() {
[ -e "/tmp/qmp.save.tar.gz" ] && echo "Found saved state at /tmp/qmp.save.tar.gz. Make sure you want to use it!" \
|| {
echo "Cannot found saved state, saving it..."
save_state
}
touch /tmp/qmp.safe.test
echo "------------------------------------------------------------------------------------"
echo "File /tmp/qmp.safe.test has been created, after configuring the system you will have
240 seconds to remove it or the previous state will be recovered"
180 seconds to remove it or the previous state will be recovered"
echo "------------------------------------------------------------------------------------"
read -p'Do you agree?[y,N] ' a
[ "$a" != "y" ] && return
configure_all
( sleep 240
( sleep 180
[ -e "/tmp/qmp.safe.test" ] && {
cp -f /etc/config/qmp /tmp/qmp.wrong
recover_state
cp -f /tmp/qmp.wrong /etc/config/qmp.wrong
hard_reboot
} || rm -f "/tmp/qmp.safe.test"
) &
......@@ -135,14 +139,15 @@ safe_test() {
save_state() {
echo "Saving state at $(date) in file /tmp/qmp.save.tar.gz"
tar czf /tmp/qmp.save.tar.gz /overlay/
rm -f /tmp/qmp.save.tar.gz 2>/dev/null
(cd /overlay/etc && tar czf /tmp/qmp.save.tar.gz .)
[ ! -e /tmp/qmp.save.tar.gz ] && echo "ERROR: cannot save state, exiting..." && exit 1
}
recover_state() {
echo "Recovering state at $(date) from /tmp/qmp.save.tar.gz"
cp -f /etc/config/qmp /etc/config/qmp.wrong
[ -e "/tmp/qmp.save.tar.gz" ] && tar xzf /tmp/qmp.save.tar.gz -C / || \
echo "Cannot recover state because it has not been saved before"
[ -e "/tmp/qmp.save.tar.gz" ] && tar xvzf /tmp/qmp.save.tar.gz -C /overlay/etc/ \
|| echo "Cannot recover state because it has not been saved before"
}
help() {
......@@ -150,32 +155,32 @@ help() {
echo ""
echo "Configuration:"
echo " configure_all : Configure and apply all settings"
echo " configure_network : Configure and apply network settings"
echo " configure_system : Configure and apply system settings (qmp.node section and so on)"
echo " configure_wifi : Configure all WiFi devices"
echo " reset_wifi : Reset, rescan and configure all the WiFi devices"
echo " configure_all : Configure and apply all settings"
echo " configure_network : Configure and apply network settings"
echo " configure_system : Configure and apply system settings (qmp.node section and so on)"
echo " configure_wifi : Configure all WiFi devices"
echo " reset_wifi : Reset, rescan and configure all the WiFi devices"
echo ""
echo "Safe configuration apply:"
echo " save_state : Saves current state of configuration files"
echo " recover_state : Recovers previous saved state"
echo " safe_test : Performs a safe configure_all. If something wrong it comes back to old state"
echo "Safe configuration:"
echo " save_state : Saves current state of configuration files"
echo " recover_state : Recovers previous saved state"
echo " safe_apply : Performs a safe configure_all. If something wrong it comes back to old state"
echo ""
echo "Gateways:"
echo " offer_default_gw [ipv4|ipv6] : Offers default gw to the network IPv4 or IPv6, both versions if no value"
echo " search_default_gw [ipv4|ipv6] : Search for a default gw in the network IPv4 or IPv6, both versions if no value"
echo " disable_default_gw [ipv4|ipv6] : Disables the search/offer of default GW IPv4 and/or IPv6"
echo " publish_hna : Publish an IP range (v4 or v6): publish_hna <IP/NETMASK> [ID]"
echo " unpublish_hna : Unpublish a current HNA: unpublish_hna <ID>"
echo " offer_default_gw [ipv4|ipv6] : Offers default gw to the network IPv4 or IPv6, both versions if no value"
echo " search_default_gw [ipv4|ipv6] : Search for a default gw in the network IPv4 or IPv6, both versions if no value"
echo " disable_default_gw [ipv4|ipv6] : Disables the search/offer of default GW IPv4 and/or IPv6"
echo " publish_hna : Publish an IP range (v4 or v6): publish_hna <IP/NETMASK> [ID]"
echo " unpublish_hna : Unpublish a current HNA: unpublish_hna <ID>"
echo ""
echo "Other:"
echo " apply_netserver : Start/stop nerserver depending on qmp configuration"
echo " enable_ns_ppt : Enable POE passtrought from NanoStation M2/5 devices. Be careful with this"
echo " upgrade [URL] : Upgrade system. By default to the last version, but image url can be provided to force"
echo " hard_reboot : Performs a hard reboot (using kernel sysrq)"
echo " apply_netserver : Start/stop nerserver depending on qmp configuration"
echo " enable_ns_ppt : Enable POE passtrought from NanoStation M2/5 devices. Be careful with this option!"
echo " upgrade [URL] : Upgrade system. By default to the last version, but image url can be provided to force"
echo " hard_reboot : Performs a hard reboot (using kernel sysrq)"
echo ""
exit 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment