upgrade 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 ./prerequisites
  12. if dpkg -l firmware-linux-nonfree &> /dev/null; then
  13. firmware_nonfree=yes
  14. else
  15. firmware_nonfree=no
  16. fi
  17. tmpdir=$(mktemp -dp /tmp/ hotspot-upgrade-XXXXX)
  18. sudo cp -a /etc/yunohost/apps/hotspot/settings.yml "${tmpdir}/"
  19. export HOTSPOT_UPGRADE=1
  20. sudo bash /etc/yunohost/apps/hotspot/scripts/remove &> /dev/null
  21. bash ./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}"
  22. gitcommit=$(ynh_setting hotspot gitcommit)
  23. sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/hotspot/
  24. sudo rm -r "${tmpdir}/"
  25. sudo yunohost app setting hotspot gitcommit -v "${gitcommit}"
  26. # Changes
  27. if [ "$(ynh_setting hotspot ip6_firewall)" == '' ]; then
  28. multissid=$(ynh_setting hotspot multissid)
  29. ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
  30. ip6_firewall=$(echo "${ip6_firewall%?}")
  31. sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
  32. fi
  33. sudo systemctl start ynh-hotspot
  34. exit 0