diff --git a/conf/init_ynh-hotspot b/conf/init_ynh-hotspot index b4debba..65577f0 100644 --- a/conf/init_ynh-hotspot +++ b/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 diff --git a/manifest.json b/manifest.json index 576cb45..4b9c6be 100644 --- a/manifest.json +++ b/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::" } ] } diff --git a/manifest.json.options b/manifest.json.options new file mode 100644 index 0000000..576cb45 --- /dev/null +++ b/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::" + } + ] + } +} diff --git a/scripts/install b/scripts/install index 0540641..26e0f2d 100644 --- a/scripts/install +++ b/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 diff --git a/scripts/remove b/scripts/remove index 86aad02..657c834 100644 --- a/scripts/remove +++ b/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 diff --git a/sources/public/js/custom.js b/sources/public/js/custom.js index 6b220eb..d925426 100644 --- a/sources/public/js/custom.js +++ b/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() { diff --git a/sources/views/settings.html.php b/sources/views/settings.html.php index 295c6c3..4843b65 100644 --- a/sources/views/settings.html.php +++ b/sources/views/settings.html.php @@ -16,7 +16,7 @@