upgrade 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/hotspot/
  23. sudo rm -r "${tmpdir}/"
  24. # Changes
  25. if [ -z "$(ynh_setting hotspot ip6_firewall)" ]; then
  26. multissid=$(ynh_setting hotspot multissid)
  27. ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
  28. ip6_firewall=$(echo "${ip6_firewall%?}")
  29. sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
  30. fi
  31. sudo systemctl start ynh-hotspot
  32. exit 0