diff --git a/conf/init_ynh-hotspot b/conf/init_ynh-hotspot index 5444f86..a3988dd 100644 --- a/conf/init_ynh-hotspot +++ b/conf/init_ynh-hotspot @@ -181,6 +181,19 @@ moulinette_get() { echo "${value}" } +moulinette_vpnclient_get() { + var=${1} + + value=$(yunohost app setting vpnclient "${var}") + + if [[ "${value}" =~ "An instance is already running" ]]; then + echo "${value}" >&2 + exit 1 + fi + + echo "${value}" +} + moulinette_set() { var=${1} value=${2} @@ -193,6 +206,12 @@ moulinette_set() { fi } +# Restart php5-fpm at the first start (it needs to be restarted after the slapd start) +if [ ! -e /tmp/.ynh-hotspot-boot ]; then + touch /tmp/.ynh-hotspot-boot + service php5-fpm restart +fi + # Variables echo -n "Retrieving Yunohost settings... " @@ -221,6 +240,21 @@ 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) + + 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" + fi +fi + # Script case "$1" in @@ -298,12 +332,6 @@ case "$1" in # Update dynamic settings moulinette_set internet_device "${new_internet_device}" fi - - # Restart php5-fpm at the first start (it needs to be restarted after the slapd start) - if [ ! -e /tmp/.ynh-hotspot-boot ]; then - touch /tmp/.ynh-hotspot-boot - service php5-fpm restart - fi ;; stop) echo "[hotspot] Stopping..." @@ -357,62 +385,64 @@ case "$1" in exitcode=0 if has_ip6delegatedprefix; then + echo "[INFO] IPv6 delegated prefix found" + if is_ndproxy_set; then - echo "NDP proxy is correctly set" + echo "[OK] NDP proxy set" else - echo "NDP proxy is NOT set" + echo "[ERR] No NDP proxy set" exitcode=1 fi if is_ip6addr_set; then - echo "IPv6 address is correctly set" + echo "[OK] IPv6 address set" else - echo "IPv6 address is NOT set" + echo "[ERR] No IPv6 address set" exitcode=1 fi if is_radvd_running; then - echo "Radvd is running" + echo "[OK] Radvd is running" else - echo "Radvd is NOT running" + echo "[ERR] Radvd is not running" exitcode=1 fi else - echo "No IPv6 delegated prefix" + echo "[INFO] No IPv6 delegated prefix found" fi if is_nat_set "${new_internet_device}"; then - echo "NAT is correctly set" + echo "[OK] IPv4 NAT set" else - echo "NAT is NOT set" + echo "[ERR] No IPv4 NAT set" exitcode=1 fi if is_ip4nataddr_set; then - echo "IPv4 NAT address is correctly set" + echo "[OK] IPv4 NAT address set" else - echo "IPv4 NAT address is NOT set" + echo "[ERR] No IPv4 NAT address set" exitcode=1 fi if is_forwarding_set; then - echo "Forwarding is correctly set" + echo "[OK] IPv6/IPv4 forwarding set" else - echo "Forwarding is NOT set" + echo "[ERR] No IPv6/IPv4 forwarding set" exitcode=1 fi if is_hostapd_running; then - echo "Hostapd is running" + echo "[OK] Hostapd is running" else - echo "Hostapd is NOT running" + echo "[ERR] Hostapd is not running" exitcode=1 fi if is_dhcpd_running; then - echo "Dhcpd is running" + echo "[OK] Dhcpd is running" else - echo "Dhcpd is NOT running" + echo "[ERR] Dhcpd is not running" exitcode=1 fi diff --git a/conf/phpfpm_wifiadmin.conf b/conf/phpfpm_wifiadmin.conf index 06d3e21..4ade216 100644 --- a/conf/phpfpm_wifiadmin.conf +++ b/conf/phpfpm_wifiadmin.conf @@ -165,7 +165,7 @@ request_terminate_timeout = 600s ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 -request_slowlog_timeout = 5s +request_slowlog_timeout = 0 ; The log file for slow requests ; Default Value: not set @@ -202,7 +202,7 @@ chdir = ; Note: on highloaded environement, this can cause some delay in the page ; process time (several ms). ; Default Value: no -catch_workers_output = yes +catch_workers_output = no ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. diff --git a/docs/box-project.png b/docs/box-project.png new file mode 100644 index 0000000..637b7eb Binary files /dev/null and b/docs/box-project.png differ diff --git a/screenshot.png b/screenshot.png index 3765f86..331283f 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/scripts/install b/scripts/install index 471ef1b..470d332 100644 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ fi sudo apt-get --assume-yes --force-yes install hostapd radvd isc-dhcp-server iptables php5-fpm # Extra packages -sudo apt-get --assume-yes --force-yes install sipcalc iwconfig +sudo apt-get --assume-yes --force-yes install sipcalc iw # Compute extra arguments if [ -z "${ip6_net}" ]; then @@ -147,8 +147,6 @@ sudo yunohost service disable hostapd sudo yunohost service add php5-fpm sudo yunohost service enable php5-fpm -sudo yunohost service stop php5-fpm -sudo yunohost service start php5-fpm sudo service nginx reload diff --git a/scripts/remove b/scripts/remove index 649e6ea..7c56e06 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,7 +7,7 @@ domain=$(sudo yunohost app setting hotspot domain) sudo service ynh-hotspot stop sudo yunohost service remove ynh-hotspot sudo rm -f /etc/init.d/ynh-hotspot -sudo rm -f /tmp/.ynh-hotspot-boot +sudo rm -f /tmp/.ynh-hotspot-* # Remove confs sudo rm -f /etc/hostapd/hostapd.conf{.tpl,} /etc/radvd.conf{.tpl,} /etc/dhcp/dhcpd.conf{.tpl,} @@ -28,6 +28,6 @@ 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 iwconfig +## sudo apt-get --assume-yes --force-yes remove sipcalc iw exit 0 diff --git a/sources/controller.php b/sources/controller.php index 9ad2fa2..bf1afe7 100644 --- a/sources/controller.php +++ b/sources/controller.php @@ -18,6 +18,18 @@ function start_service() { return $retcode; } +function service_status() { + exec('sudo service ynh-hotspot status', $output); + + return $output; +} + +function service_faststatus() { + exec('sudo service hostapd status', $output, $retcode); + + return $retcode; +} + function ipv6_expanded($ip) { exec('ipv6_expanded '.escapeshellarg($ip), $output); @@ -33,7 +45,7 @@ function ipv6_compressed($ip) { dispatch('/', function() { exec('sudo iwconfig', $devs); $wifi_device = moulinette_get('wifi_device'); - $devs_list = ""; + $devs_list = ''; foreach($devs AS $dev) { if(preg_match('/802.11/', $dev)) { @@ -60,6 +72,7 @@ dispatch('/', function() { set('ip4_nat_prefix', moulinette_get('ip4_nat_prefix')); set('ip4_dns0', moulinette_get('ip4_dns0')); set('ip4_dns1', moulinette_get('ip4_dns1')); + set('faststatus', service_faststatus() == 0); return render('settings.html.php'); }); @@ -165,6 +178,28 @@ dispatch_put('/settings', function() { redirect_to('/'); }); +dispatch('/status', function() { + $status_lines = service_status(); + $status_list = ''; + + foreach($status_lines AS $status_line) { + if(preg_match('/^\[INFO\]/', $status_line)) { + $status_list .= "
  • ${status_line}
  • "; + } + elseif(preg_match('/^\[OK\]/', $status_line)) { + $status_list .= "
  • ${status_line}
  • "; + } + elseif(preg_match('/^\[WARN\]/', $status_line)) { + $status_list .= "
  • ${status_line}
  • "; + } + elseif(preg_match('/^\[ERR\]/', $status_line)) { + $status_list .= "
  • ${status_line}
  • "; + } + } + + echo $status_list; +}); + dispatch('/lang/:locale', function($locale = 'en') { switch ($locale) { case 'fr': diff --git a/sources/public/css/style.css b/sources/public/css/style.css index e69de29..617dd88 100644 --- a/sources/public/css/style.css +++ b/sources/public/css/style.css @@ -0,0 +1,36 @@ +li.status-info { + color: #5BC0DE; +} + +li.status-warning { + color: #D9534F; +} + +li.status-danger { + color: #D9534F; +} + +li.status-success { + color: #5CB85C; +} + +img#status-loading { + display: none; + padding-right: 5px; +} + +img#save-loading { + display: none; + margin-left: 5px; +} + +div#status { + display: none; + margin-top: 10px; +} + +div#status ul { + list-style-type: none; + padding: 0; + margin: 0; +} diff --git a/sources/public/img/loading.gif b/sources/public/img/loading.gif new file mode 100644 index 0000000..5f11860 Binary files /dev/null and b/sources/public/img/loading.gif differ diff --git a/sources/public/js/custom.js b/sources/public/js/custom.js index 8a94328..29242cf 100644 --- a/sources/public/js/custom.js +++ b/sources/public/js/custom.js @@ -28,4 +28,25 @@ $(document).ready(function() { }); $('.switch').bootstrapToggle(); + + $('#save').click(function() { + $(this).prop('disabled', true); + $('#save-loading').show(); + }); + + $('#status .close').click(function() { + $(this).parent().hide(); + }); + + $('#statusbtn').click(function() { + $('#status-loading').show(); + + $.ajax({ + url: '?/status', + }).done(function(data) { + $('#status-loading').hide(); + $('#status-text').html(''); + $('#status').show('slow'); + }); + }); }); diff --git a/sources/views/settings.html.php b/sources/views/settings.html.php index 1c8b1fd..295c6c3 100644 --- a/sources/views/settings.html.php +++ b/sources/views/settings.html.php @@ -1,4 +1,16 @@

    + + + + + + +   Loading... + +
    @@ -142,7 +154,7 @@
    - + Loading...