From ba45daad19f4f464f24ed4fa3637137ce4940b08 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Nov 2023 14:45:55 +0000 Subject: [PATCH 01/26] Patch applied + modified from RaspAP/raspap-insiders#242 --- ajax/system/sys_chk_update.php | 26 +++++++++++++ ajax/system/sys_perform_update.php | 18 +++++++++ app/css/all.css | 4 ++ app/js/custom.js | 57 ++++++++++++++++++++++++++++ config/config.php | 3 ++ includes/defaults.php | 2 +- includes/functions.php | 25 ++++++++++++ locale/en_US/LC_MESSAGES/messages.po | 33 ++++++++++++++++ templates/about.php | 40 +++++++++++++++++++ templates/about/general.php | 16 ++++++-- 10 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 ajax/system/sys_chk_update.php create mode 100644 ajax/system/sys_perform_update.php diff --git a/ajax/system/sys_chk_update.php b/ajax/system/sys_chk_update.php new file mode 100644 index 00000000..2a177148 --- /dev/null +++ b/ajax/system/sys_chk_update.php @@ -0,0 +1,26 @@ + i.fas { border-bottom-right-radius: 0.35rem; } +.cmd-copy { + width: 95%; + height: 6rem; +} diff --git a/app/js/custom.js b/app/js/custom.js index 6c929c26..d6d4103d 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -276,6 +276,63 @@ $('#debugModal').on('shown.bs.modal', function (e) { }); }); +$('#chkupdateModal').on('shown.bs.modal', function (e) { + var csrfToken = $('meta[name=csrf_token]').attr('content'); + $.post('ajax/system/sys_chk_update.php',{'csrf_token': csrfToken},function(data){ + var response = JSON.parse(data); + var tag = response.tag; + var update = response.update; + var msg; + var msgUpdate = $('#msgUpdate').data('message'); + var msgLatest = $('#msgLatest').data('message'); + var msgInstall = $('#msgInstall').data('message'); + var msgDismiss = $('#js-check-dismiss').data('message'); + var faCheck = '
'; + $(".fas.fa-sync-alt").removeClass("fa-spin"); + if (update === true) { + msg = msgUpdate +' '+tag; + $("#msg-check-update").html(msg); + $("#msg-check-update").append(faCheck); + $("#msg-check-update").append("

"+msgInstall+"

"); + $("#js-sys-check-update").removeClass("collapse"); + } else { + msg = msgLatest; + dismiss = $("#js-check-dismiss"); + $("#msg-check-update").html(msg); + $("#msg-check-update").append(faCheck); + $("#js-sys-check-update").remove(); + dismiss.text(msgDismiss); + dismiss.removeClass("btn-outline-secondary"); + dismiss.addClass("btn-primary"); + } + }); +}); + +$('#js-sys-check-update').click(function() { + $('#chkupdateModal').modal('hide'); + $('#cmdupdateModal').modal('show'); +}); + +$('#cmdupdateModal').on('shown.bs.modal', function (e) { + var csrfToken = $('meta[name=csrf_token]').attr('content'); + $.post('ajax/system/sys_perform_update.php',{ + 'csrf_token': csrfToken + },function(data){ + var response = JSON.parse(data); + $('#shellCmd').val(response); + }); +}); + +$('#js-cmd-copy').click(function() { + $('#shellCmd').select(); + document.execCommand('copy'); + var btnCancel = $('#cmdupdateCancel'); + var btnText = btnCancel.data('message'); + btnCancel.text(btnText); + btnCancel.removeClass("btn-outline-secondary"); + btnCancel.addClass("btn-primary"); +}); + $('#hostapdModal').on('shown.bs.modal', function (e) { var seconds = 3; var pct = 0; diff --git a/config/config.php b/config/config.php index 20debf6a..1aff2412 100755 --- a/config/config.php +++ b/config/config.php @@ -31,6 +31,9 @@ define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf'); define('RASPI_ACCESS_CHECK_IP', '1.1.1.1'); define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one'); +// Constant for the GitHub API latest release endpoint +define('RASPI_API_ENDPOINT', 'https://api.github.com/repos/RaspAP/raspap-webgui/releases/latest'); + // Constant for the 5GHz wireless regulatory domain define("RASPI_5GHZ_CHANNEL_MIN", 100); define("RASPI_5GHZ_CHANNEL_MAX", 192); diff --git a/includes/defaults.php b/includes/defaults.php index 0b46f90f..ce0936b5 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -6,7 +6,7 @@ if (!defined('RASPI_CONFIG')) { $defaults = [ 'RASPI_BRAND_TEXT' => 'RaspAP', - 'RASPI_VERSION' => '3.0.1', + 'RASPI_VERSION' => '2.9.9', 'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json', 'RASPI_CONFIG_PROVIDERS' => 'config/vpn-providers.json', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', diff --git a/includes/functions.php b/includes/functions.php index 78d12bae..f909311d 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -899,3 +899,28 @@ function getCountryCodes($locale = 'en', $flag = true) { return $countryData; } +/** + * Compares the current release with the latest available release + * + * @param string $installed + * @param string $latest + * @return boolean + */ +function checkReleaseVersion($installed, $latest) { + $installedArray = explode('.', $installed); + $latestArray = explode('.', $latest); + + // compare segments of the version number + for ($i = 0; $i < max(count($installedArray), count($latestArray)); $i++) { + $installedSegment = (int)($installedArray[$i] ?? 0); + $latestSegment = (int)($latestArray[$i] ?? 0); + + if ($installedSegment < $latestSegment) { + return true; + } elseif ($installedSegment > $latestSegment) { + return false; + } + } + return false; +} + diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index 1eb061bf..8ed58b76 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -1457,3 +1457,36 @@ msgstr "Insiders" msgid "Contributing" msgstr "Contributing" +msgid "Check for update" +msgstr "Check for update" + +msgid "New release check in progress..." +msgstr "New release check in progress..." + +msgid "A new release is available: Version" +msgstr "A new release is available: Version" + +msgid "GitHub authentication" +msgstr "GitHub authentication" + +msgid "Updating Insiders requires GitHub authentication." +msgstr "Updating Insiders requires GitHub authentication." + +msgid "Your credentials will be sent to GitHub securely with SSL. However, use caution if your RaspAP install is on a WLAN shared by untrusted users." +msgstr "Your credentials will be sent to GitHub securely with SSL. However, use caution if your RaspAP install is on a WLAN shared by untrusted users." + +msgid "Personal Access Token" +msgstr "Personal Access Token" + +msgid "Please provide a valid token." +msgstr "Please provide a valid token." + +msgid "Get update command" +msgstr "Get update command" + +msgid "Copy the following and execute it in the terminal:" +msgstr "Copy the following and execute it in the terminal:" + +msgid "Copy" +msgstr "Copy" + diff --git a/templates/about.php b/templates/about.php index 6a5e6ed7..4aa95e4b 100755 --- a/templates/about.php +++ b/templates/about.php @@ -36,3 +36,43 @@ require_once 'app/lib/Parsedown.php'; + + + + + + diff --git a/templates/about/general.php b/templates/about/general.php index 2a6da8f3..9e9781e5 100644 --- a/templates/about/general.php +++ b/templates/about/general.php @@ -1,9 +1,19 @@
-
-

-
+
+
+
+
+

+ +
+
+
+
+
RaspAP is a co-creation of billz and SirLagz with the contributions of our developer community and language translators. From 51e05dd270ebeb113c683774a7d46bf4007de2de Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Nov 2023 14:48:59 +0000 Subject: [PATCH 02/26] Update en_US local messages --- locale/en_US/LC_MESSAGES/messages.po | 3 +++ 1 file changed, 3 insertions(+) diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index 8ed58b76..79be0bbd 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -1466,6 +1466,9 @@ msgstr "New release check in progress..." msgid "A new release is available: Version" msgstr "A new release is available: Version" +msgid "Installed version is the latest release." +msgstr "Installed version is the latest release." + msgid "GitHub authentication" msgstr "GitHub authentication" From ba67d327af18fa033c91da2de7638c459f18b4fa Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Nov 2023 14:56:50 +0000 Subject: [PATCH 03/26] Revert change to RASPI_VERSION --- includes/defaults.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/defaults.php b/includes/defaults.php index ce0936b5..0b46f90f 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -6,7 +6,7 @@ if (!defined('RASPI_CONFIG')) { $defaults = [ 'RASPI_BRAND_TEXT' => 'RaspAP', - 'RASPI_VERSION' => '2.9.9', + 'RASPI_VERSION' => '3.0.1', 'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json', 'RASPI_CONFIG_PROVIDERS' => 'config/vpn-providers.json', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', From 61cf109f11cda541ad5b56dcbfe6988f4297c315 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Nov 2023 14:57:46 +0000 Subject: [PATCH 04/26] Compile en_US local .mo --- locale/en_US/LC_MESSAGES/messages.mo | Bin 39599 -> 40793 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/locale/en_US/LC_MESSAGES/messages.mo b/locale/en_US/LC_MESSAGES/messages.mo index e518f8e0a9a06336c01132b32ec26b097c931977..037f9cc9bdb88010207ec6cf5b95c19b926702c5 100644 GIT binary patch delta 11435 zcmeI%`F{^r-^cMu>>)xdK`JK1PKbTqcM=gxY(*qrgvcH{U$w?oyHb=cT9hK86s6Tx z7fLB=DZRAP>Ty>m_;4?o<0!Tq@B(U0fnoHH|LnKP5*y7nFNy>`Oadn>T; zdWR#=$8ny(ZUK(7*w=BALR9NG*>xO;|C}ZKlZ-i714HXNPHF6pE)K#Xn1!WqCI(?P za!Y4Bw!r;Z9KSK`Ugu|$epD2%=Qz2`t_P`6Mm8`@l)Zs?d0A9qhxEHk&Cs7@rMNRzkCS0Y4J5&_Ld&qyzZ~UYB zx=kIY0k*(u7>~Nad~AUh&g z)UX3J!aZ0Sk6=x_h??2&s0&K8GMlVD`cv+K^>7gCQF<{DH=tHx7wS{;GwQVrXl=@s z(A86GNurSsMLnwt7=$xW&v*@LV9%pE+>0@I3>`jNrQ7h)Aq{BDJBO0s3x33M=-LwSp*HuQsD7Nz=KLV^sv?v`7q&vptS`Da2(>a?*P!n5e-Df@Dh4qi1;U`-W+SM#|XVeNjiJ>?PHL&L}3}3-IcosGD zUs0R&U(^6=b~AgYE$Xf6gPQ1Q)T5b#+H=|6yry9z6 zuFbF#FluSLpf+EB zRQn{mn^14dE-ZvcP@C+y^#j!Ayo7qBKiYclZzM&j@a<_XD1q7w6;Ml8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u7mT!pMO@Q`c*|b90hidkJ=f^pADsTSVk;GE$pdgd5pU}=a6RR} zhz7)~L*EUjI5!LT<8k5}@{#!J_z%fIVmWoI@HX)dQI7HuB1zlpT`Kg=)RTNJetPwgy*^TC(kGNFB;0_Y%cym`6!|)t^C$nle$#$`owixcN!}a8J_(|5=CSYI>sA3 zKlAh9+VqrS1}WTMQ!-h*w8<>d#VGfQPX+UefxnCehKs z;B2Q{iu^FXN9-a>5Cy24N0hhMi7nJOCSD`D5k-g*L?rP!ahcHJL(I1MAgoGxy2_gW z)x<91bK(PHHZj;<9A%}-SwlYTZ{;}h`_xy(BgA*Q$R2OuP@Aiby2QVTcepMOag4ke zp>xh=qPG%`#hfffG&4odPd|PZrtW=W8~JDWx;_7zwFQ1jy^as9lga0iPa-B0iMBqF z`Z!(qYW%)q6r=AaRpXXxr=HzwiC^%_=@O7BvO8l*iGp8hrwBfjfj0*^KV-x9uV2Y z80zohviSqnWHnFi6O)d&c%?d XwrkFMXMLEl!z-(E%313E*N^=lY}w|z From e55f4e2395cfda5893d767c38cfc5a28bf586c50 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 21 Nov 2023 20:14:19 +0000 Subject: [PATCH 05/26] Update _download_latest_files, install app-update.sh --- installers/common.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/installers/common.sh b/installers/common.sh index 32865812..91020989 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -545,12 +545,6 @@ function _create_openvpn_scripts() { # Fetches latest files from github to webroot function _download_latest_files() { - if [ -d "$webroot_dir" ] && [ "$update" == 0 ]; then - sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to remove old webroot directory" - elif [ "$upgrade" == 1 ] || [ "$update" == 1 ]; then - sudo rm -rf "$webroot_dir" - fi - _install_log "Cloning latest files from GitHub" if [ "$repo" == "RaspAP/raspap-insiders" ]; then if [ -n "$username" ] && [ -n "$acctoken" ]; then @@ -570,6 +564,12 @@ function _download_latest_files() { exit 1 fi + if [ -d "$webroot_dir" ] && [ "$update" == 0 ]; then + sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to remove old webroot directory" + elif [ "$upgrade" == 1 ] || [ "$update" == 1 ]; then + sudo rm -rf "$webroot_dir" + fi + _install_log "Installing application to $webroot_dir" sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to $webroot_dir" @@ -780,6 +780,9 @@ function _patch_system_files() { _install_log "Creating RaspAP debug log control script" sudo cp "$webroot_dir/installers/"debuglog.sh "$raspap_dir/system" || _install_status 1 "Unable to move debug logging script" + _install_log "Creating RaspAP application update script" + sudo cp "$webroot_dir/installers/"app-update.sh "$raspap_dir/system" || _install_status 1 "Unable to move application update script" + # Set ownership and permissions sudo chown -c root:root "$raspap_dir/system/"*.sh || _install_status 1 "Unable change owner and/or group" sudo chmod 750 "$raspap_dir/system/"*.sh || _install_status 1 "Unable to change file permissions" From 90456e601e5a20509f7e35b4d2dfb2c8a7411873 Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 22 Nov 2023 19:00:32 +0000 Subject: [PATCH 06/26] Replace mv source > dest with rsync, preserving sys_read_logfile.php --- installers/common.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/installers/common.sh b/installers/common.sh index 91020989..825ff757 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -546,17 +546,18 @@ function _create_openvpn_scripts() { # Fetches latest files from github to webroot function _download_latest_files() { _install_log "Cloning latest files from GitHub" + source_dir="/tmp/raspap-webgui" if [ "$repo" == "RaspAP/raspap-insiders" ]; then if [ -n "$username" ] && [ -n "$acctoken" ]; then insiders_source_url="https://${username}:${acctoken}@github.com/$repo" - git clone --branch $branch --depth 1 -c advice.detachedHead=false $insiders_source_url /tmp/raspap-webgui || clone=false + git clone --branch $branch --depth 1 -c advice.detachedHead=false $insiders_source_url $source_dir || clone=false else _install_status 3 echo "Insiders please read this: https://docs.raspap.com/insiders/#authentication" fi fi if [ -z "$insiders_source_url" ]; then - git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url /tmp/raspap-webgui || clone=false + git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url $source_dir || clone=false fi if [ "$clone" = false ]; then _install_status 1 "Unable to download files from github" @@ -565,13 +566,14 @@ function _download_latest_files() { fi if [ -d "$webroot_dir" ] && [ "$update" == 0 ]; then - sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to remove old webroot directory" + sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to move existing webroot directory" elif [ "$upgrade" == 1 ] || [ "$update" == 1 ]; then - sudo rm -rf "$webroot_dir" + shopt -s extglob + sudo find "$webroot_dir" ! -path "${webroot_dir}/ajax/system/sys_read_logfile.php" -delete 2>/dev/null fi _install_log "Installing application to $webroot_dir" - sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to $webroot_dir" + sudo rsync -av --exclude='/ajax/system/sys_read_logfile.php' "$source_dir"/ "$webroot_dir"/ >/dev/null 2>&1 || _install_status 1 "Unable to install files to $webroot_dir" if [ "$update" == 1 ]; then _install_log "Applying existing configuration to ${webroot_dir}/includes" @@ -582,11 +584,13 @@ function _download_latest_files() { sudo mv /tmp/raspap.auth $raspap_dir || _install_status 1 "Unable to restore authentification credentials file to ${raspap_dir}" fi else - echo "Copying primary RaspAP config to includes/config.php" + echo "Copying primary RaspAP config to ${webroot_dir}/includes/config.php" if [ ! -f "$webroot_dir/includes/config.php" ]; then sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php" fi fi + echo "Removing source files at ${source_dir}" + sudo rm -rf $source_dir _install_status 0 } From 5fbcabd3c2de75b40154b7fefeb18bfa16133534 Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 23 Nov 2023 07:43:33 +0000 Subject: [PATCH 07/26] Initial commit --- installers/app-update.sh | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 installers/app-update.sh diff --git a/installers/app-update.sh b/installers/app-update.sh new file mode 100755 index 00000000..183bbacf --- /dev/null +++ b/installers/app-update.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# RaspAP Application Update +# Safely updates an existing RaspAP installation +# Author: @billz +# Author URI: https://github.com/billz +# Project URI: https://github.com/RaspAP/ +# License: GNU General Public License v3.0 +# License URI: https://github.com/RaspAP/raspap-webgui/blob/master/LICENSE +# +# Reads arguments passed by the RaspAP application and securely executes the +# local raspbian.sh install loader. + +# Exit on error +set -o errexit +# Exit on error inside functions +set -o errtrace +# Exit on pipeline error +set -eo pipefail + +function _main() { + # set defaults + _parse_params "$@" + _load_installer +} + +function _parse_params() { + # set defaults + insiders=0 + acctoken="" + username="" + path="" + + while :; do + case "${1-}" in + -i|--insiders) + insiders=1 + ;; + -t|--token) + acctoken="$2" + shift + ;; + -n|--name) + username="$2" + shift + ;; + -p|--path) + path="$2" + shift + ;; + -*|--*) + echo "Unknown option: $1" + exit 1 + ;; + *) + break + ;; + esac + shift + done +} + +function _load_installer() { + args=() + if [ "$insiders" -eq 1 ]; then + args+=("--insiders") + fi + if [ -n "$path" ]; then + args+=("--path ${path}") + fi + if [ -n "$username" ]; then + args+=("--name ${username}") + fi + if [ -n "$acctoken" ]; then + args+=("--token ${acctoken}") + fi + filtered=() + for arg in "${args[@]}"; do + if [ -n "$arg" ]; then + filtered+=("$arg") + fi + done + + echo "Loading installer..." + echo "${path}/installers/raspbian.sh --update --yes ${filtered[*]}" + $path/installers/raspbian.sh --update --yes ${filtered[*]} || { echo "Failed to execute raspbian.sh - last error: $?"; } +} + +_main "$@" + From e2111fdf1f9b6b0d33cd84a41133ee3150b4da2f Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 23 Nov 2023 07:43:50 +0000 Subject: [PATCH 08/26] Added /etc/raspap/system/app-update.sh to sudoers --- installers/raspap.sudoers | 1 + 1 file changed, 1 insertion(+) diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index 1b5cc806..e49e20a1 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -42,6 +42,7 @@ www-data ALL=(ALL) NOPASSWD:/etc/raspap/lighttpd/configport.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/configauth.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/openvpnlog.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/system/debuglog.sh +www-data ALL=(ALL) NOPASSWD:/etc/raspap/system/app-update.sh www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/hostapd.log www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /var/log/dnsmasq.log www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/wireguard.log From d14040d3a7b88e134e695b556a9c7d419a0f6fd5 Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 23 Nov 2023 07:44:46 +0000 Subject: [PATCH 09/26] Initial commit --- ajax/system/sys_read_logfile.php | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ajax/system/sys_read_logfile.php diff --git a/ajax/system/sys_read_logfile.php b/ajax/system/sys_read_logfile.php new file mode 100644 index 00000000..7715fab2 --- /dev/null +++ b/ajax/system/sys_read_logfile.php @@ -0,0 +1,43 @@ + 1, + 'Updating sources' => 2, + 'Installing required packages' => 3, + 'Cloning latest files' => 4, + 'Installing application' => 5, + 'Installation completed' => 6, + 'error' => 7 +]; +sleep(1); + +if (file_exists($logFile)) { + $handle = fopen($logFile, 'r'); + + if ($handle) { + while (($line = fgets($handle)) !== false) { + foreach ($searchStrings as $searchString => $value) { + if (strpos($line, $searchString) !== false) { + echo $value .PHP_EOL; + flush(); + ob_flush(); + if ($value === 6) { + fclose($handle); + exit(); + } elseif ($value === 7) { + echo $line .PHP_EOL; + fclose($handle); + exit(); + } + } + } + } + fclose($handle); + } else { + echo json_encode("Unable to open file: $logFile"); + } +} else { + echo json_encode("File does not exist: $logFile"); +} + + From 44c8b7c1ae24127edec09330cb323828e5750b52 Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 23 Nov 2023 07:49:03 +0000 Subject: [PATCH 10/26] Create fetchUpdateResponse(), update modals --- app/js/custom.js | 52 +++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index d6d4103d..30ae715e 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -288,7 +288,7 @@ $('#chkupdateModal').on('shown.bs.modal', function (e) { var msgInstall = $('#msgInstall').data('message'); var msgDismiss = $('#js-check-dismiss').data('message'); var faCheck = '
'; - $(".fas.fa-sync-alt").removeClass("fa-spin"); + $("#updateSync").removeClass("fa-spin"); if (update === true) { msg = msgUpdate +' '+tag; $("#msg-check-update").html(msg); @@ -310,28 +310,40 @@ $('#chkupdateModal').on('shown.bs.modal', function (e) { $('#js-sys-check-update').click(function() { $('#chkupdateModal').modal('hide'); - $('#cmdupdateModal').modal('show'); + $('#performupdateModal').modal('show'); }); -$('#cmdupdateModal').on('shown.bs.modal', function (e) { - var csrfToken = $('meta[name=csrf_token]').attr('content'); - $.post('ajax/system/sys_perform_update.php',{ - 'csrf_token': csrfToken - },function(data){ - var response = JSON.parse(data); - $('#shellCmd').val(response); +$('#performupdateModal').on('shown.bs.modal', function (e) { + fetchUpdateResponse(); + setInterval(fetchUpdateResponse, 500); +}); + +function fetchUpdateResponse() { + const xhr = new XMLHttpRequest(); + let phpFile = 'ajax/system/sys_read_logfile.php'; + $.ajax({ + url: phpFile, + type: 'GET', + success: function(response) { + for (let i = 1; i <= 6; i++) { + let divId = '#updateStep' + i; + if (response.includes(i)) { + $(divId).removeClass('invisible'); + if (response.includes('6')) { + $('#updateStep6').removeClass('invisible'); + $('#updateSync2').removeClass("fa-spin"); + break; + } else { + setTimeout(fetchUpdateResponse, 1000); + } + } + } + }, + error: function(xhr, status, error) { + setTimeout(fetchUpdateResponse, 1000); + } }); -}); - -$('#js-cmd-copy').click(function() { - $('#shellCmd').select(); - document.execCommand('copy'); - var btnCancel = $('#cmdupdateCancel'); - var btnText = btnCancel.data('message'); - btnCancel.text(btnText); - btnCancel.removeClass("btn-outline-secondary"); - btnCancel.addClass("btn-primary"); -}); +} $('#hostapdModal').on('shown.bs.modal', function (e) { var seconds = 3; From 37dcaa41f15a803d82635af39697086990655b33 Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 23 Nov 2023 07:51:43 +0000 Subject: [PATCH 11/26] Create performupdateModal w/ progress steps --- templates/about.php | 70 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/templates/about.php b/templates/about.php index 4aa95e4b..b0c40d59 100755 --- a/templates/about.php +++ b/templates/about.php @@ -42,7 +42,7 @@ require_once 'app/lib/Parsedown.php';
From 99fd2f8ce74cff665c0960cd1d8ffdac8c57769e Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 24 Nov 2023 07:48:12 +0000 Subject: [PATCH 19/26] Remove existing /tmp/raspap_install.log --- installers/raspbian.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/installers/raspbian.sh b/installers/raspbian.sh index 81de4bd5..357c184e 100755 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -187,6 +187,9 @@ function _setup_colors() { function _log_output() { readonly LOGFILE_PATH="/tmp" + if [ -f "$LOGFILE_PATH/raspap_install.log" ]; then + rm "$LOGFILE_PATH/raspap_install.log" + fi exec > >(tee -i $LOGFILE_PATH/raspap_install.log) exec 2>&1 } From aa3a88e9b1cd057b87fb09053b0bb6c36f083d73 Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 24 Nov 2023 07:49:52 +0000 Subject: [PATCH 20/26] Use existing raspbian.sh install loader for update --- ajax/system/sys_perform_update.php | 4 +- ajax/system/sys_read_logfile.php | 3 +- installers/app-update.sh | 90 ------------------------------ installers/common.sh | 6 +- installers/raspap.sudoers | 2 +- 5 files changed, 7 insertions(+), 98 deletions(-) delete mode 100755 installers/app-update.sh diff --git a/ajax/system/sys_perform_update.php b/ajax/system/sys_perform_update.php index a33984bc..5008bbd1 100644 --- a/ajax/system/sys_perform_update.php +++ b/ajax/system/sys_perform_update.php @@ -8,8 +8,8 @@ if (isset($_POST['csrf_token'])) { } // set installer path + options $path = getenv("DOCUMENT_ROOT"); - $opts = " --update --path $path --yes"; - $installer = "sudo /etc/raspap/system/app-update.sh"; + $opts = " --update --yes --path $path"; + $installer = "sudo /etc/raspap/system/raspbian.sh"; $execUpdate = $installer.$opts; $response = shell_exec($execUpdate); diff --git a/ajax/system/sys_read_logfile.php b/ajax/system/sys_read_logfile.php index 7715fab2..567de9e1 100644 --- a/ajax/system/sys_read_logfile.php +++ b/ajax/system/sys_read_logfile.php @@ -9,7 +9,7 @@ $searchStrings = [ 'Installation completed' => 6, 'error' => 7 ]; -sleep(1); +usleep(500); if (file_exists($logFile)) { $handle = fopen($logFile, 'r'); @@ -40,4 +40,3 @@ if (file_exists($logFile)) { echo json_encode("File does not exist: $logFile"); } - diff --git a/installers/app-update.sh b/installers/app-update.sh deleted file mode 100755 index 183bbacf..00000000 --- a/installers/app-update.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# -# RaspAP Application Update -# Safely updates an existing RaspAP installation -# Author: @billz -# Author URI: https://github.com/billz -# Project URI: https://github.com/RaspAP/ -# License: GNU General Public License v3.0 -# License URI: https://github.com/RaspAP/raspap-webgui/blob/master/LICENSE -# -# Reads arguments passed by the RaspAP application and securely executes the -# local raspbian.sh install loader. - -# Exit on error -set -o errexit -# Exit on error inside functions -set -o errtrace -# Exit on pipeline error -set -eo pipefail - -function _main() { - # set defaults - _parse_params "$@" - _load_installer -} - -function _parse_params() { - # set defaults - insiders=0 - acctoken="" - username="" - path="" - - while :; do - case "${1-}" in - -i|--insiders) - insiders=1 - ;; - -t|--token) - acctoken="$2" - shift - ;; - -n|--name) - username="$2" - shift - ;; - -p|--path) - path="$2" - shift - ;; - -*|--*) - echo "Unknown option: $1" - exit 1 - ;; - *) - break - ;; - esac - shift - done -} - -function _load_installer() { - args=() - if [ "$insiders" -eq 1 ]; then - args+=("--insiders") - fi - if [ -n "$path" ]; then - args+=("--path ${path}") - fi - if [ -n "$username" ]; then - args+=("--name ${username}") - fi - if [ -n "$acctoken" ]; then - args+=("--token ${acctoken}") - fi - filtered=() - for arg in "${args[@]}"; do - if [ -n "$arg" ]; then - filtered+=("$arg") - fi - done - - echo "Loading installer..." - echo "${path}/installers/raspbian.sh --update --yes ${filtered[*]}" - $path/installers/raspbian.sh --update --yes ${filtered[*]} || { echo "Failed to execute raspbian.sh - last error: $?"; } -} - -_main "$@" - diff --git a/installers/common.sh b/installers/common.sh index 825ff757..02b6d201 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -781,11 +781,11 @@ function _patch_system_files() { sudo mkdir $raspap_dir/system || _install_status 1 "Unable to create directory '$raspap_dir/system'" fi - _install_log "Creating RaspAP debug log control script" + _install_log "Copying RaspAP debug log control script" sudo cp "$webroot_dir/installers/"debuglog.sh "$raspap_dir/system" || _install_status 1 "Unable to move debug logging script" - _install_log "Creating RaspAP application update script" - sudo cp "$webroot_dir/installers/"app-update.sh "$raspap_dir/system" || _install_status 1 "Unable to move application update script" + _install_log "Copying RaspAP install loader" + sudo cp "$webroot_dir/installers/"raspbian.sh "$raspap_dir/system" || _install_status 1 "Unable to move application update script" # Set ownership and permissions sudo chown -c root:root "$raspap_dir/system/"*.sh || _install_status 1 "Unable change owner and/or group" diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index e49e20a1..8d3d817c 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -42,7 +42,7 @@ www-data ALL=(ALL) NOPASSWD:/etc/raspap/lighttpd/configport.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/configauth.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/openvpnlog.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/system/debuglog.sh -www-data ALL=(ALL) NOPASSWD:/etc/raspap/system/app-update.sh +www-data ALL=(ALL) NOPASSWD:/etc/raspap/system/raspbian.sh www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/hostapd.log www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /var/log/dnsmasq.log www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/wireguard.log From d6a4d33758fbc0a819575f8ee5f1b77d5ebfd553 Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 24 Nov 2023 18:07:47 +0000 Subject: [PATCH 21/26] Define RASPI_INSTALL_LOG --- ajax/system/sys_read_logfile.php | 2 +- config/config.php | 1 + includes/defaults.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ajax/system/sys_read_logfile.php b/ajax/system/sys_read_logfile.php index 567de9e1..ff1a59b8 100644 --- a/ajax/system/sys_read_logfile.php +++ b/ajax/system/sys_read_logfile.php @@ -1,5 +1,5 @@ 1, 'Updating sources' => 2, diff --git a/config/config.php b/config/config.php index 1aff2412..459a3496 100755 --- a/config/config.php +++ b/config/config.php @@ -8,6 +8,7 @@ define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); define('RASPI_WIFI_AP_INTERFACE', 'wlan0'); define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); define('RASPI_DEBUG_LOG', 'raspap_debug.log'); +define('RASPI_INSTALL_LOG', 'raspap_install.log'); // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. diff --git a/includes/defaults.php b/includes/defaults.php index 0b46f90f..4a90da40 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -13,6 +13,7 @@ $defaults = [ 'RASPI_WIFI_AP_INTERFACE' => 'wlan0', 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', 'RASPI_DEBUG_LOG' => 'raspap_debug.log', + 'RASPI_INSTALL_LOG' => 'raspap_install.log', // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. From 484a1e87024353e2ede24c9ea6de68cbfd94b42e Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 24 Nov 2023 18:10:16 +0000 Subject: [PATCH 22/26] Cleanup template, fix timing of js execution --- app/js/custom.js | 11 ++++---- templates/about.php | 65 +++++++-------------------------------------- 2 files changed, 15 insertions(+), 61 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index b2dd65b3..3a99eaa7 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -308,16 +308,17 @@ $('#chkupdateModal').on('shown.bs.modal', function (e) { }); }); -$('#js-sys-check-update').click(function() { +$('#performUpdate').on('submit', function(event) { + event.preventDefault(); + var csrfToken = $('meta[name=csrf_token]').attr('content'); + $.post('ajax/system/sys_perform_update.php',{ + 'csrf_token': csrfToken + }) $('#chkupdateModal').modal('hide'); $('#performupdateModal').modal('show'); }); $('#performupdateModal').on('shown.bs.modal', function (e) { - var csrfToken = $('meta[name=csrf_token]').attr('content'); - $.post('ajax/system/sys_perform_update.php',{ - 'csrf_token': csrfToken, - }) fetchUpdateResponse(); }); diff --git a/templates/about.php b/templates/about.php index 74a53c52..8e1be914 100755 --- a/templates/about.php +++ b/templates/about.php @@ -41,66 +41,19 @@ require_once 'app/lib/Parsedown.php'; - - -
From 2102fb904332064b940f473cabba3af15dabd301 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 25 Nov 2023 08:15:10 +0000 Subject: [PATCH 24/26] Remove temp $source_dir if exists, sudo rm raspap_install.log --- installers/common.sh | 6 +++++- installers/raspbian.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/installers/common.sh b/installers/common.sh index 02b6d201..d3b98f55 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -547,6 +547,10 @@ function _create_openvpn_scripts() { function _download_latest_files() { _install_log "Cloning latest files from GitHub" source_dir="/tmp/raspap-webgui" + if [ -d "$source_dir" ]; then + echo "Temporary download destination $source_dir exists. Removing..." + rm -r "$source_dir" + fi if [ "$repo" == "RaspAP/raspap-insiders" ]; then if [ -n "$username" ] && [ -n "$acctoken" ]; then insiders_source_url="https://${username}:${acctoken}@github.com/$repo" @@ -560,7 +564,7 @@ function _download_latest_files() { git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url $source_dir || clone=false fi if [ "$clone" = false ]; then - _install_status 1 "Unable to download files from github" + _install_status 1 "Unable to download files from GitHub" echo "The installer cannot continue." >&2 exit 1 fi diff --git a/installers/raspbian.sh b/installers/raspbian.sh index 357c184e..c4a0a4fe 100755 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -188,7 +188,7 @@ function _setup_colors() { function _log_output() { readonly LOGFILE_PATH="/tmp" if [ -f "$LOGFILE_PATH/raspap_install.log" ]; then - rm "$LOGFILE_PATH/raspap_install.log" + sudo rm "$LOGFILE_PATH/raspap_install.log" fi exec > >(tee -i $LOGFILE_PATH/raspap_install.log) exec 2>&1 From 9a709b3dedc8105298c495288dc8d369a6757073 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 25 Nov 2023 09:54:28 +0000 Subject: [PATCH 25/26] Preserve /tmp/raspap_install.log literal --- ajax/system/sys_read_logfile.php | 4 +--- config/config.php | 1 - includes/defaults.php | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ajax/system/sys_read_logfile.php b/ajax/system/sys_read_logfile.php index 40b41bb8..946a68cc 100644 --- a/ajax/system/sys_read_logfile.php +++ b/ajax/system/sys_read_logfile.php @@ -1,8 +1,6 @@ 1, 'Updating sources' => 2, diff --git a/config/config.php b/config/config.php index 459a3496..1aff2412 100755 --- a/config/config.php +++ b/config/config.php @@ -8,7 +8,6 @@ define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); define('RASPI_WIFI_AP_INTERFACE', 'wlan0'); define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); define('RASPI_DEBUG_LOG', 'raspap_debug.log'); -define('RASPI_INSTALL_LOG', 'raspap_install.log'); // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. diff --git a/includes/defaults.php b/includes/defaults.php index 4a90da40..0b46f90f 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -13,7 +13,6 @@ $defaults = [ 'RASPI_WIFI_AP_INTERFACE' => 'wlan0', 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', 'RASPI_DEBUG_LOG' => 'raspap_debug.log', - 'RASPI_INSTALL_LOG' => 'raspap_install.log', // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. From 61a1f063eaba8e094fd0ab6b6346d80dceb1224c Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 25 Nov 2023 11:30:36 +0000 Subject: [PATCH 26/26] Update rsync exclusion path --- installers/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers/common.sh b/installers/common.sh index d3b98f55..e7a54659 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -577,7 +577,7 @@ function _download_latest_files() { fi _install_log "Installing application to $webroot_dir" - sudo rsync -av --exclude='/ajax/system/sys_read_logfile.php' "$source_dir"/ "$webroot_dir"/ >/dev/null 2>&1 || _install_status 1 "Unable to install files to $webroot_dir" + sudo rsync -av --exclude='ajax/system/sys_read_logfile.php' "$source_dir"/ "$webroot_dir"/ >/dev/null 2>&1 || _install_status 1 "Unable to install files to $webroot_dir" if [ "$update" == 1 ]; then _install_log "Applying existing configuration to ${webroot_dir}/includes"