diff --git a/app/js/custom.js b/app/js/custom.js index d6ed0576..0e842ebf 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -459,19 +459,6 @@ $(document).on("click", ".js-toggle-password", function(e) { } }); -$(document).on("input", ".js-validate-psk", function(e) { - var field = $(e.target); - var colors = field.data("colors").split(","); - var target = $(field.data("target")); - if (field.val().length < 8 || field.val().length > 63) { - field.css("backgroundColor", colors[0]); - target.attr("disabled", true); - } else { - field.css("backgroundColor", colors[1]); - target.attr("disabled", false); - } -}); - $(function() { $('#theme-select').change(function() { var theme = themes[$( "#theme-select" ).val() ]; diff --git a/app/js/custom.min.js b/app/js/custom.min.js index 23a7c9b2..67444fb6 100644 --- a/app/js/custom.min.js +++ b/app/js/custom.min.js @@ -4,4 +4,4 @@ * Licensed under MIT (https://github.com/raspap-webgui/raspap-webgui/blob/master/LICENSE) */ -function msgShow(t,a){if(0==t)var e="success";else if(2==t||1==t)e="danger";return'"}function createNetmaskAddr(t){var a=[];for(i=0;i<4;i++){var e=Math.min(t,8);a.push(256-Math.pow(2,8-e)),t-=e}return a.join(".")}function loadSummary(a){$.post("/ajax/networking/get_ip_summary.php",{interface:a},function(t){jsonData=JSON.parse(t),console.log(jsonData),0==jsonData.return?$("#"+a+"-summary").html(jsonData.output.join("
")):2==jsonData.return&&$("#"+a+"-summary").append('")})}function getAllInterfaces(){$.get("/ajax/networking/get_all_interfaces.php",function(t){jsonData=JSON.parse(t),$.each(jsonData,function(t,a){loadSummary(a)})})}function setupTabs(){$('a[data-toggle="tab"]').on("shown.bs.tab",function(t){var a=$(t.target).attr("href");a.match("summary")||loadCurrentSettings(a.replace("#",""))})}function loadCurrentSettings(t){$.post("/ajax/networking/get_int_config.php",{interface:t},function(t){jsonData=JSON.parse(t),$.each(jsonData.output,function(t,a){var n=a.interface;$.each(a,function(t,a){switch(t){case"static":"true"==a?($("#"+n+"-static").click(),$("#"+n+"-nofailover").click()):$("#"+n+"-dhcp").click();break;case"failover":"true"===a?$("#"+n+"-failover").click():$("#"+n+"-nofailover").click();break;case"ip_address":var e=a.split("/");$("#"+n+"-ipaddress").val(e[0]),$("#"+n+"-netmask").val(createNetmaskAddr(e[1]));break;case"routers":$("#"+n+"-gateway").val(a);break;case"domain_name_server":svrsDNS=a.split(" "),$("#"+n+"-dnssvr").val(svrsDNS[0]),$("#"+n+"-dnssvralt").val(svrsDNS[1])}})})})}function saveNetworkSettings(t){var a=$("#frm-"+t).find(":input"),e={};$.each(a,function(t,a){"radio"==$(a).attr("type")?e[$(a).attr("id")]=$(a).prop("checked"):e[$(a).attr("id")]=$(a).val()}),e.interface=t,$.post("/ajax/networking/save_int_config.php",e,function(t){var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function applyNetworkSettings(){$(this).data("int");arrFormData={generate:""},$.post("/ajax/networking/gen_int_config.php",arrFormData,function(t){console.log(t);var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function setupBtns(){$("#btnSummaryRefresh").click(function(){getAllInterfaces()}),$(".intsave").click(function(){saveNetworkSettings($(this).data("int"))}),$(".intapply").click(function(){applyNetworkSettings()})}function setCSRFTokenHeader(t,a,e){var n=$("meta[name=csrf_token]").attr("content");/^(POST|PATCH|PUT|DELETE)$/i.test(e.type)&&a.setRequestHeader("X-CSRF-Token",n)}function contentLoaded(){switch(pageCurrent=window.location.href.split("?")[1].split("=")[1],pageCurrent=pageCurrent.replace("#",""),$("#side-menu").metisMenu(),pageCurrent){case"network_conf":getAllInterfaces(),setupTabs(),setupBtns()}}function loadWifiStations(a){return function(){var t=!0===a?"?refresh":"";$(".js-wifi-stations").addClass("loading-spinner").empty().load("/ajax/networking/wifi_stations.php"+t,function(){$(this).removeClass("loading-spinner")})}}$(document).on("click",".js-add-dhcp-static-lease",function(t){t.preventDefault();var a=$(".js-new-dhcp-static-lease"),e=$("input[name=mac]",a).val().trim(),n=$("input[name=ip]",a).val().trim();if(""!=e&&""!=n){var i=$("#js-dhcp-static-lease-row").html().replace("{{ mac }}",e).replace("{{ ip }}",n);$(".js-dhcp-static-lease-container").append(i),$("input[name=mac]",a).val(""),$("input[name=ip]",a).val("")}}),$(document).on("click",".js-remove-dhcp-static-lease",function(t){t.preventDefault(),$(this).parents(".js-dhcp-static-lease-row").remove()}),$(document).on("submit",".js-dhcp-settings-form",function(t){$(".js-add-dhcp-static-lease").trigger("click")}),$(".js-reload-wifi-stations").on("click",loadWifiStations(!0)),$(document).on("click",".js-toggle-password",function(t){var a=$(t.target),e=$(a.data("target"));e.is(":input")&&(t.preventDefault(),a.data("__toggle-with-initial")||a.data("__toggle-with-initial",a.text()),"password"===e.attr("type")?(a.text(a.data("toggle-with")),e.attr("type","text")):(a.text(a.data("__toggle-with-initial")),e.attr("type","password")))}),$(document).on("input",".js-validate-psk",function(t){var a=$(t.target),e=a.data("colors").split(","),n=$(a.data("target"));a.val().length<8||63'+a+""}function createNetmaskAddr(t){var a=[];for(i=0;i<4;i++){var e=Math.min(t,8);a.push(256-Math.pow(2,8-e)),t-=e}return a.join(".")}function loadSummary(a){$.post("/ajax/networking/get_ip_summary.php",{interface:a},function(t){jsonData=JSON.parse(t),console.log(jsonData),0==jsonData.return?$("#"+a+"-summary").html(jsonData.output.join("
")):2==jsonData.return&&$("#"+a+"-summary").append('")})}function getAllInterfaces(){$.get("/ajax/networking/get_all_interfaces.php",function(t){jsonData=JSON.parse(t),$.each(jsonData,function(t,a){loadSummary(a)})})}function setupTabs(){$('a[data-toggle="tab"]').on("shown.bs.tab",function(t){var a=$(t.target).attr("href");a.match("summary")||loadCurrentSettings(a.replace("#",""))})}function loadCurrentSettings(t){$.post("/ajax/networking/get_int_config.php",{interface:t},function(t){jsonData=JSON.parse(t),$.each(jsonData.output,function(t,a){var n=a.interface;$.each(a,function(t,a){switch(t){case"static":"true"==a?($("#"+n+"-static").click(),$("#"+n+"-nofailover").click()):$("#"+n+"-dhcp").click();break;case"failover":"true"===a?$("#"+n+"-failover").click():$("#"+n+"-nofailover").click();break;case"ip_address":var e=a.split("/");$("#"+n+"-ipaddress").val(e[0]),$("#"+n+"-netmask").val(createNetmaskAddr(e[1]));break;case"routers":$("#"+n+"-gateway").val(a);break;case"domain_name_server":svrsDNS=a.split(" "),$("#"+n+"-dnssvr").val(svrsDNS[0]),$("#"+n+"-dnssvralt").val(svrsDNS[1])}})})})}function saveNetworkSettings(t){var a=$("#frm-"+t).find(":input"),e={};$.each(a,function(t,a){"radio"==$(a).attr("type")?e[$(a).attr("id")]=$(a).prop("checked"):e[$(a).attr("id")]=$(a).val()}),e.interface=t,$.post("/ajax/networking/save_int_config.php",e,function(t){var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function applyNetworkSettings(){$(this).data("int");arrFormData={generate:""},$.post("/ajax/networking/gen_int_config.php",arrFormData,function(t){console.log(t);var a=JSON.parse(t);$("#msgNetworking").html(msgShow(a.return,a.output))})}function setupBtns(){$("#btnSummaryRefresh").click(function(){getAllInterfaces()}),$(".intsave").click(function(){saveNetworkSettings($(this).data("int"))}),$(".intapply").click(function(){applyNetworkSettings()})}function setCSRFTokenHeader(t,a,e){var n=$("meta[name=csrf_token]").attr("content");/^(POST|PATCH|PUT|DELETE)$/i.test(e.type)&&a.setRequestHeader("X-CSRF-Token",n)}function contentLoaded(){switch(pageCurrent=window.location.href.split("?")[1].split("=")[1],pageCurrent=pageCurrent.replace("#",""),$("#side-menu").metisMenu(),pageCurrent){case"network_conf":getAllInterfaces(),setupTabs(),setupBtns()}}function loadWifiStations(a){return function(){var t=!0===a?"?refresh":"";$(".js-wifi-stations").addClass("loading-spinner").empty().load("/ajax/networking/wifi_stations.php"+t,function(){$(this).removeClass("loading-spinner")})}}$(document).on("click",".js-add-dhcp-static-lease",function(t){t.preventDefault();var a=$(".js-new-dhcp-static-lease"),e=$("input[name=mac]",a).val().trim(),n=$("input[name=ip]",a).val().trim();if(""!=e&&""!=n){var i=$("#js-dhcp-static-lease-row").html().replace("{{ mac }}",e).replace("{{ ip }}",n);$(".js-dhcp-static-lease-container").append(i),$("input[name=mac]",a).val(""),$("input[name=ip]",a).val("")}}),$(document).on("click",".js-remove-dhcp-static-lease",function(t){t.preventDefault(),$(this).parents(".js-dhcp-static-lease-row").remove()}),$(document).on("submit",".js-dhcp-settings-form",function(t){$(".js-add-dhcp-static-lease").trigger("click")}),$(".js-reload-wifi-stations").on("click",loadWifiStations(!0)),$(document).on("click",".js-toggle-password",function(t){var a=$(t.target),e=$(a.data("target"));e.is(":input")&&(t.preventDefault(),a.data("__toggle-with-initial")||a.data("__toggle-with-initial",a.text()),"password"===e.attr("type")?(a.text(a.data("toggle-with")),e.attr("type","text")):(a.text(a.data("__toggle-with-initial")),e.attr("type","password")))}),$(document).on("keyup",".js-validate-psk",function(t){var a=$(t.target),e=a.data("colors").split(","),n=$(a.data("target"));a.val().length<8||63"/index.php/$1$2" ) - server.error-handler-404 = "/index.php" +$HTTP["url"] =~ "^/REPLACE_ME/(?!(dist|app|ajax|config)).*" { + url.rewrite-once = ( "^/REPLACE_ME/(.*?)(\?.+)?$"=>"/REPLACE_ME/index.php/$1$2" ) + server.error-handler-404 = "/REPLACE_ME/index.php" } + diff --git a/config/config.php b/config/config.php index 44670716..d4f9266e 100755 --- a/config/config.php +++ b/config/config.php @@ -1,6 +1,6 @@ /dev/null; then diff --git a/installers/raspapd.service b/installers/raspapd.service index 7ec927f8..c5738465 100644 --- a/installers/raspapd.service +++ b/installers/raspapd.service @@ -12,7 +12,7 @@ [Unit] Description=RaspAP Service Daemon DefaultDependencies=no -After=network.target +After=multi-user.target [Service] Type=oneshot diff --git a/installers/servicestart.sh b/installers/servicestart.sh index 0c3cc557..377678ca 100755 --- a/installers/servicestart.sh +++ b/installers/servicestart.sh @@ -10,58 +10,30 @@ DAEMONPATH="/lib/systemd/system/raspapd.service" OPENVPNENABLED=$(pidof openvpn | wc -l) positional=() -while [[ $# -gt 0 ]]; do - key="$1" +while [[ $# -gt 0 ]] +do +key="$1" - case $key in - -i | --interface) - interface="$2" - shift # past argument - shift # past value - ;; - -s | --seconds) - seconds="$2" - shift - shift - ;; - -a | --action) - action="$2" - shift - shift - ;; - esac +case $key in + -i|--interface) + interface="$2" + shift # past argument + shift # past value + ;; + -s|--seconds) + seconds="$2" + shift + shift + ;; + -a|--action) + action="$2" + shift + shift + ;; +esac done set -- "${positional[@]}" -HOSTAPD_CONF="/etc/hostapd/hostapd.conf" - -new_country_code=$(curl -s -H "Authorization: Bearer 9da1eb466ed052" https://ipinfo.io/json | jq -r ".country // empty") -old_country_code=$(grep ^country_code $HOSTAPD_CONF | cut -d "=" -f 2) - -if [[ ! -z "$new_country_code" ]] && [[ "$old_country_code" != "$new_country_code" ]]; then - sudo sed -i "s/country_code=$old_country_code/country_code=$new_country_code/" /etc/hostapd/hostapd.conf - echo "Updated country code: $new_country_code" -fi - -old_ssid=$(grep ^ssid $HOSTAPD_CONF | cut -d "=" -f 2) -rpi_serial=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2) -new_ssid="isobox-$rpi_serial" - -if [[ "$old_ssid" != "$new_ssid" ]]; then - sed -i "s/ssid=$old_ssid/ssid=$new_ssid/" $HOSTAPD_CONF - echo "Updated ssid: $new_ssid" -fi - -old_hostname=$(hostname) -new_hostname="isobox-$rpi_serial" - -if [[ "$old_hostname" != "$new_hostname" ]]; then - echo $new_hostname >/etc/hostname - sed -i "s/$old_hostname/$new_hostname/" /etc/hosts - hostname $new_hostname - echo "Updated hostname: $new_hostname" -fi - echo "Stopping network services..." if [ $OPENVPNENABLED -eq 1 ]; then systemctl stop openvpn-client@client @@ -85,7 +57,7 @@ if [ -r "$CONFIGFILE" ]; then declare -A config while IFS=" = " read -r key value; do config["$key"]="$value" - done <"$CONFIGFILE" + done < "$CONFIGFILE" if [ "${config[BridgedEnable]}" = 1 ]; then if [ "${interface}" = "br0" ]; then @@ -107,7 +79,7 @@ if [ -r "$CONFIGFILE" ]; then echo "Disabling systemd-networkd" systemctl disable systemd-networkd - ip link ls up | grep -q 'br0' &>/dev/null + ip link ls up | grep -q 'br0' &> /dev/null if [ $? == 0 ]; then echo "Removing br0 interface..." ip link set down br0 @@ -117,7 +89,7 @@ if [ -r "$CONFIGFILE" ]; then if [ "${config[WifiAPEnable]}" = 1 ]; then if [ "${interface}" = "uap0" ]; then - ip link ls up | grep -q 'uap0' &>/dev/null + ip link ls up | grep -q 'uap0' &> /dev/null if [ $? == 0 ]; then echo "Removing uap0 interface..." iw dev uap0 del @@ -155,3 +127,4 @@ if [ "${config[WifiAPEnable]}" = 1 ]; then fi echo "RaspAP service start DONE" + diff --git a/installers/uninstall.sh b/installers/uninstall.sh index 56ca1d87..06173755 100755 --- a/installers/uninstall.sh +++ b/installers/uninstall.sh @@ -158,7 +158,7 @@ function _restore_networking() { echo "Checking iptables rules" rules=( "-A POSTROUTING -j MASQUERADE" - "-A POSTROUTING -s 192.168.200.0/24 ! -d 192.168.200.0/24 -j MASQUERADE" + "-A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE" ) for rule in "${rules[@]}"; do if grep -- "$rule" $rulesv4 > /dev/null; then diff --git a/templates/wifi_stations.php b/templates/wifi_stations.php index cde0bf45..9ccfa779 100755 --- a/templates/wifi_stations.php +++ b/templates/wifi_stations.php @@ -46,32 +46,3 @@ - -

-
-
-
- - - -
-
- -
-
- -
- -
-
-
- -
- " id="update" name="update" data-toggle="modal" data-target="#configureClientModal" /> -
-
-
- - - -