upgrade 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. ynh_setting() {
  3. app=${1}
  4. setting=${2}
  5. sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
  6. }
  7. domain=$(ynh_setting hotspot domain)
  8. path=$(ynh_setting hotspot path)
  9. wifi_ssid=$(ynh_setting hotspot wifi_ssid)
  10. wifi_passphrase=$(ynh_setting hotspot wifi_passphrase)
  11. if dpkg -l firmware-linux-nonfree &> /dev/null; then
  12. firmware_nonfree=yes
  13. else
  14. firmware_nonfree=no
  15. fi
  16. tmpdir=$(mktemp -dp /tmp/ hotspot-upgrade-XXXXX)
  17. sudo cp -a /etc/yunohost/apps/hotspot/settings.yml "${tmpdir}/"
  18. export HOTSPOT_UPGRADE=1
  19. sudo bash /etc/yunohost/apps/hotspot/scripts/remove &> /dev/null
  20. bash ./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}"
  21. gitcommit=$(ynh_setting hotspot gitcommit)
  22. sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/hotspot/
  23. sudo rm -r "${tmpdir}/"
  24. sudo yunohost app setting hotspot gitcommit -v "${gitcommit}"
  25. # Changes
  26. if [ "$(ynh_setting hotspot ip6_firewall)" == '' ]; then
  27. multissid=$(ynh_setting hotspot multissid)
  28. ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
  29. ip6_firewall=$(echo "${ip6_firewall%?}")
  30. sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
  31. fi
  32. sudo systemctl start ynh-hotspot
  33. exit 0