Parcourir la source

Fix some bugs on Chromium and IE

Julien VAUBOURG il y a 10 ans
Parent
commit
a1107f960a
7 fichiers modifiés avec 102 ajouts et 44 suppressions
  1. 12 10
      conf/init_ynh-hotspot
  2. 0 8
      manifest.json
  3. 61 0
      manifest.json.options
  4. 24 19
      scripts/install
  5. 1 5
      scripts/remove
  6. 3 1
      sources/public/js/custom.js
  7. 1 1
      sources/views/settings.html.php

+ 12 - 10
conf/init_ynh-hotspot

@@ -241,17 +241,19 @@ fi
 echo "OK"
 
 # Check IPv6 delegated prefix from vpnclient
-if [ "${ynh_ip6_net}" == none ]; then
-  ynh_ip6_net=$(moulinette_vpnclient_get ip6_net)
-  ynh_ip6_addr=$(moulinette_vpnclient_get ip6_addr)
+vpnclient_ip6_net=$(moulinette_vpnclient_get ip6_net)
 
-  moulinette_set ip6_net "${ynh_ip6_net}"
-  moulinette_set ip6_addr "${ynh_ip6_addr}"
-else
-  vpnclient_ip6_net=$(moulinette_vpnclient_get ip6_net)
-
-  if [ "${ynh_ip6_net}" != "${vpnclient_ip6_net}" ]; then
-    echo "[WARN] The IPv6 delegated prefix is different from the vpnclient one"
+if [ ! -z "${vpnclient_ip6_addr}" ]; then
+  if [ "${ynh_ip6_net}" == none ]; then
+    ynh_ip6_net=$vpnclient_ip6_net
+    ynh_ip6_addr=$(moulinette_vpnclient_get ip6_addr)
+  
+    moulinette_set ip6_net "${ynh_ip6_net}"
+    moulinette_set ip6_addr "${ynh_ip6_addr}"
+  else
+    if [ "${ynh_ip6_net}" != "${vpnclient_ip6_net}" ]; then
+      echo "[WARN] The IPv6 delegated prefix is different from the vpnclient one"
+    fi
   fi
 fi
 

+ 0 - 8
manifest.json

@@ -47,14 +47,6 @@
             "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)"
         },
         "example": "VhegT8oev0jZI"
-      },
-      {
-        "name": "ip6_net",
-        "ask": {
-            "en": "Select your IPv6 delegated prefix (leave empty if your Internet Service Provider does not give you a delegated prefix, but you will not have IPv6)",
-            "fr": "Sélectionnez votre préfixe IPv6 délégué (laisser vide si votre Fournisseur d'Accès à Internet ne vous donne pas de préfixe délégué, mais vous n'aurez pas d'IPv6)"
-        },
-        "example": "2001:db8:42::"
       }
     ]
   }

+ 61 - 0
manifest.json.options

@@ -0,0 +1,61 @@
+{
+  "name": "Wifi Hotspot",
+  "id": "hotspot",
+  "description": {
+    "en": "Wifi Hotspot",
+    "fr": "Hotspot Wifi"
+  },
+  "license": "AGPL-3",
+  "developer": {
+    "name": "Julien Vaubourg",
+    "email": "julien@vaubourg.com",
+    "url": "http://julien.vaubourg.com"
+  },
+  "multi_instance": "false",
+  "arguments": {
+    "install" : [
+      {
+        "name": "domain",
+        "ask": {
+            "en": "Choose a domain for the web administration",
+            "fr": "Choisissez un domaine pour l'administration web"
+        },
+        "example": "domain.org"
+      },
+      {
+        "name": "path",
+        "ask": {
+            "en": "Choose a path for the web administration",
+            "fr": "Choissez un chemin pour l'administration web"
+        },
+        "example": "/wifiadmin",
+        "default": "/wifiadmin"
+      },
+      {
+        "name": "wifi_ssid",
+        "ask": {
+            "en": "Choose a wifi name (SSID)",
+            "fr": "Choisissez un nom pour le wifi (SSID)"
+        },
+        "example": "myNeutralNetwork",
+        "default": "myNeutralNetwork"
+      },
+      {
+        "name": "wifi_passphrase",
+        "ask": {
+            "en": "Choose a wifi password (at least 8 characters for WPA2)",
+            "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)"
+        },
+        "example": "VhegT8oev0jZI"
+      },
+      {
+        "name": "ip6_net",
+        "ask": {
+            "en": "Select your IPv6 delegated prefix (leave empty if your Internet Service Provider does not give you a delegated prefix, but you will not have IPv6)",
+            "fr": "Sélectionnez votre préfixe IPv6 délégué (laisser vide si votre Fournisseur d'Accès à Internet ne vous donne pas de préfixe délégué, mais vous n'aurez pas d'IPv6)"
+        },
+        "example": "2001:db8:42::"
+      }
+    ]
+  }
+}

+ 24 - 19
scripts/install

@@ -5,7 +5,13 @@ domain=${1}
 url_path=${2}
 wifi_ssid=${3}
 wifi_passphrase=${4}
-ip6_net=${5}
+
+##
+## These arguments are optional but YunoHost is not yet able to handle them with the web installer
+## See manifest.json.options
+##
+#
+#ip6_net=${5}
 
 # Check arguments
 if [ -z "${wifi_ssid}" -o -z "${wifi_passphrase}" ]; then
@@ -34,27 +40,29 @@ fi
 # Install packages
 # TODO: Replace isc-dhcp-server by dnsmasq (currently negotiating with the YunoHost team to
 # also replace bind9 by dnsmasq)
-#sudo apt-get update
-sudo apt-get --assume-yes --force-yes install hostapd radvd isc-dhcp-server iptables php5-fpm wireless-tools
+packages='php5-fpm sipcalc hostapd radvd isc-dhcp-server iptables wireless-tools wireless-tools'
+sudo apt-get --assume-yes --force-yes install ${packages}
 
-# Extra packages
-sudo apt-get --assume-yes --force-yes install sipcalc wireless-tools
+if [ $? -ne 0 ]; then
+  sudo apt-get update
+  sudo apt-get --assume-yes --force-yes install ${packages}
+fi
 
 # Compute extra arguments
 if [ -z "${ip6_net}" ]; then
   ip6_net=none
   ip6_addr=none
-else
-  ip6_net=$(bash ../conf/ipv6_expanded "${ip6_net}")
-
-  if [ -z "${ip6_net}" ]; then
-    echo "ERROR: The IPv6 Delegated Prefix format looks bad" >&2
-    exit 1
-  fi
-
-  ip6_addr="$(echo "${ip6_net}" | cut -d: -f1-7):42"
-  ip6_net=$(bash ../conf/ipv6_compressed "${ip6_net}")
-  ip6_addr=$(bash ../conf/ipv6_compressed "${ip6_addr}")
+#else
+#  ip6_net=$(bash ../conf/ipv6_expanded "${ip6_net}")
+#
+#  if [ -z "${ip6_net}" ]; then
+#    echo "ERROR: The IPv6 Delegated Prefix format looks bad" >&2
+#    exit 1
+#  fi
+#
+#  ip6_addr="$(echo "${ip6_net}" | cut -d: -f1-7):42"
+#  ip6_net=$(bash ../conf/ipv6_compressed "${ip6_net}")
+#  ip6_addr=$(bash ../conf/ipv6_compressed "${ip6_addr}")
 fi
 
 wifi_device=$(sudo iwconfig 2>&1 | grep 802.11 | head -n1 | awk '{ print $1 }')
@@ -104,9 +112,6 @@ sudo chown -R root: /var/www/wifiadmin/
 sudo chmod -R 0644 /var/www/wifiadmin/*
 sudo find /var/www/wifiadmin/ -type d -exec chmod +x {} \;
 
-# Create user for the web admin
-sudo useradd -MUr wifiadmin
-
 # Fix confs
 ## hostapd
 sudo sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd

+ 1 - 5
scripts/remove

@@ -22,12 +22,8 @@ sudo service nginx reload
 # Remove sources
 sudo rm -rf /var/www/wifiadmin/
 
-# Remove user
-sudo userdel -f wifiadmin
-
 # Remove packets
 # The yunohost policy is currently to not uninstall packets (dependency problems)
-## sudo apt-get --assume-yes --force-yes remove hostapd radvd isc-dhcp-server iptables
-## sudo apt-get --assume-yes --force-yes remove sipcalc wireless-tools
+## sudo apt-get --assume-yes --force-yes remove hostapd radvd isc-dhcp-server iptables sipcalc wireless-tools
 
 exit 0

+ 3 - 1
sources/public/js/custom.js

@@ -9,7 +9,8 @@ $(document).ready(function() {
 
   $('input[type="file"]').change(function() {
     var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
-    $(choosertxtid).val($(this).val());
+
+    $(choosertxtid).val($(this).val().replace(/^.*[\/\\]/, ''));
   });
 
   $('.dropdown-menu li').click(function() {
@@ -32,6 +33,7 @@ $(document).ready(function() {
   $('#save').click(function() {
     $(this).prop('disabled', true);
     $('#save-loading').show();
+    $('#form').submit();
   });
 
   $('#status .close').click(function() {

+ 1 - 1
sources/views/settings.html.php

@@ -16,7 +16,7 @@
 
 <div class="row">
   <div class="col-sm-offset-2 col-sm-8">
-    <form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form">
+    <form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form" id="form">
       <input type="hidden" name="_method" value="put" />
 
       <div class="panel panel-default">