upgrade 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. source ./helpers
  12. source ./prerequisites
  13. if dpkg -l firmware-linux-nonfree &> /dev/null; then
  14. firmware_nonfree=yes
  15. else
  16. firmware_nonfree=no
  17. fi
  18. tmpdir=$(mktemp -dp /tmp/ hotspot-upgrade-XXXXX)
  19. sudo cp -a /etc/yunohost/apps/hotspot/settings.yml "${tmpdir}/"
  20. export HOTSPOT_UPGRADE=1
  21. sudo bash /etc/yunohost/apps/hotspot/scripts/remove &> /dev/null
  22. bash ./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}"
  23. sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/hotspot/
  24. sudo rm -r "${tmpdir}/"
  25. # Changes
  26. if [ -z "$(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. ynh_systemctl start ynh-hotspot
  33. exit 0