mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Use existing raspbian.sh install loader for update
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
| @@ -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"); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,90 +0,0 @@ | ||||
| #!/bin/bash | ||||
| # | ||||
| # RaspAP Application Update | ||||
| # Safely updates an existing RaspAP installation | ||||
| # Author: @billz <billzimmerman@gmail.com> | ||||
| # 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 "$@" | ||||
|  | ||||
| @@ -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" | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user