From d13e61c2ddc8ab3e5b338e9e7bd355f18075b941 Mon Sep 17 00:00:00 2001 From: Joulinar <47155374+Joulinar@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:35:47 +0100 Subject: [PATCH 1/8] v9.9 DietPi-Software | frp - switch from ini to toml configuration file --- dietpi/dietpi-software | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 9981da9a91..0bdd691d30 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6556,7 +6556,7 @@ StartLimitBurst=3 [Service] User=frp AmbientCapabilities=CAP_NET_BIND_SERVICE -ExecStart=/usr/local/bin/frps -c /etc/frp/frps.ini +ExecStart=/usr/local/bin/frps -c /etc/frp/frps.toml Restart=on-failure RestartSec=5s @@ -6565,19 +6565,19 @@ WantedBy=multi-user.target _EOF_ # Pre-create config file to turn on dashboard token=$(openssl rand -hex 15) - [[ -f '/etc/frp/frps.ini' ]] || cat << _EOF_ > /etc/frp/frps.ini -[common] -bind_port = 7000 + [[ -f '/etc/frp/frps.toml' ]] || cat << _EOF_ > /etc/frp/frps.toml +bindPort = 7000 -dashboard_port = 7500 -dashboard_user = admin -dashboard_pwd = $GLOBAL_PW +webServer.addr = "0.0.0.0" +webServer.port = 7500 +webServer.user = "admin" +webServer.password = "$GLOBAL_PW" -authentication_method = token -token = $token +auth.method = "token" +auth.token = "$token" _EOF_ - G_EXEC chmod 0640 /etc/frp/frps.ini - G_EXEC chown root:frp /etc/frp/frps.ini + G_EXEC chmod 0640 /etc/frp/frps.toml + G_EXEC chown root:frp /etc/frp/frps.toml aENABLE_SERVICES+=('frps') fi @@ -6594,8 +6594,8 @@ StartLimitBurst=3 [Service] User=frp -ExecStart=/usr/local/bin/frpc -c /etc/frp/frpc.ini -ExecReload=/usr/local/bin/frpc reload -c /etc/frp/frpc.ini +ExecStart=/usr/local/bin/frpc -c /etc/frp/frpc.toml +ExecReload=/usr/local/bin/frpc reload -c /etc/frp/frpc.toml Restart=on-failure RestartSec=5s @@ -6632,20 +6632,20 @@ _EOF_ fi # Pre-create config file to turn on admin UI - [[ -f '/etc/frp/frpc.ini' ]] || cat << _EOF_ > /etc/frp/frpc.ini -[common] -server_addr = $server_addr -server_port = $server_port + [[ -f '/etc/frp/frpc.toml' ]] || cat << _EOF_ > /etc/frp/frpc.toml +serverAddr = "$server_addr" +serverPort = $server_port -admin_addr = 0.0.0.0 -admin_port = 7400 -admin_user = admin -admin_pwd = $GLOBAL_PW +webServer.addr = "0.0.0.0" +webServer.port = 7400 +webServer.user = "admin" +webServer.password = "$GLOBAL_PW" -token = $token +auth.method = "token" +auth.token = "$token" _EOF_ - G_EXEC chmod 0660 /etc/frp/frpc.ini - G_EXEC chown root:frp /etc/frp/frpc.ini + G_EXEC chmod 0660 /etc/frp/frpc.toml + G_EXEC chown root:frp /etc/frp/frpc.toml aENABLE_SERVICES+=('frpc') fi From 49af19d4aaa9216f5cbc8f7e58fb65d570ae211f Mon Sep 17 00:00:00 2001 From: Joulinar <47155374+Joulinar@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:37:51 +0100 Subject: [PATCH 2/8] v9.9 DietPi-Software | frp - add a separation for ARMv6 and ARMv7 --- dietpi/dietpi-software | 1 + 1 file changed, 1 insertion(+) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 5eb0746613..1be52f7ef9 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6525,6 +6525,7 @@ _EOF_ if To_Install 171 # frp then case $G_HW_ARCH in + 1) local arch='arm';; 3) local arch='arm64';; 10) local arch='amd64';; 11) local arch='riscv64';; From 619aa3279453073ad9e0c0fe725fc3800b1b79e7 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 16:36:15 +0100 Subject: [PATCH 3/8] v9.9 - DietPi-Software | frp: Fix parsing client input, allow any characters for the token (as we do not know any limitations), and make use of the native G_WHIP_INPUTBOX input validation. Also expose the server bind address in our default config, which might be more commonly changed to limit access to particular networks. --- dietpi/dietpi-software | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 1be52f7ef9..c2e229892e 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6526,10 +6526,10 @@ _EOF_ then case $G_HW_ARCH in 1) local arch='arm';; + 2) local arch='arm_hf';; 3) local arch='arm64';; 10) local arch='amd64';; - 11) local arch='riscv64';; - *) local arch='arm_hf';; + *) local arch='riscv64';; esac # Download @@ -6580,6 +6580,7 @@ _EOF_ # Pre-create config file to turn on dashboard token=$(openssl rand -hex 15) [[ -f '/etc/frp/frps.toml' ]] || cat << _EOF_ > /etc/frp/frps.toml +bindAddr = "0.0.0.0" bindPort = 7000 webServer.addr = "0.0.0.0" @@ -6616,33 +6617,18 @@ RestartSec=5s [Install] WantedBy=multi-user.target _EOF_ - local server_addr=127.0.0.1 server_port=7000 + local server_addr='127.0.0.1' server_port=7000 if [[ $G_WHIP_RETURNED_VALUE == 'Client' ]] then - local invalid_entry= - while : - do - if G_WHIP_INPUTBOX "${invalid_entry}Please enter the IP address of your frp server, including port (default 7000)" && [[ $G_WHIP_RETURNED_VALUE =~ ^[0-9.:]+$ ]] - then - server_addr=${G_WHIP_RETURNED_VALUE#*:} - [[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE%:*} - invalid_entry= - break - else - invalid_entry='[FAILED] Please enter a valid IP address\n\n' - fi - done - - while : - do - if G_WHIP_INPUTBOX "${invalid_entry}Please enter the authentication token of your frp server" && [[ $G_WHIP_RETURNED_VALUE =~ ^[0-9.]+$ ]] - then - token=$G_WHIP_RETURNED_VALUE - break - else - invalid_entry='[FAILED] Please enter a token\n\n' - fi - done + G_WHIP_DEFAULT_ITEM="$server_addr:$server_port" + G_WHIP_INPUTBOX_REGEX='^[0-9.:]+$' + G_WHIP_INPUTBOX_REGEX_TEXT='be a valid IP address, optionally with appended network port number, like "192.168.1.100:7000"' + G_WHIP_INPUTBOX 'Please enter the IP address of your frp server, optionally including port (default 7000):' + server_addr=${G_WHIP_RETURNED_VALUE%:*} + [[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE##*:} + + G_WHIP_INPUTBOX 'Please enter the authentication token of your frp server:' + token=$G_WHIP_RETURNED_VALUE fi # Pre-create config file to turn on admin UI From 90d871bba5dee1f23ecb4af68aa55c226bc1b7dc Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 17:49:16 +0100 Subject: [PATCH 4/8] v9.9 - DietPi-Software | frp: Inform about new toml config file and leave old ini as backup in place. Do not offer client inputs, if the config exists already (and is hence not generated anyway). Allow an empty token input, which is generally possible. Allow unattended installs, using both server and client as default, and applying default values to all inputs and menus. - DietPi-Globals | G_WHIP: Return default value for inputbox, checkbox and menu, if not interactive, but keep returning error code, so that it can be handled in parent script. Minor coding enhancements. - CI | DietPi-Software: Enable frp checks now that it can be installed unattended --- .github/workflows/dietpi-software.bash | 2 +- dietpi/dietpi-software | 76 +++++++++++----- dietpi/func/dietpi-globals | 118 +++++++++++-------------- 3 files changed, 107 insertions(+), 89 deletions(-) diff --git a/.github/workflows/dietpi-software.bash b/.github/workflows/dietpi-software.bash index 8dd83980c0..0c3383578a 100644 --- a/.github/workflows/dietpi-software.bash +++ b/.github/workflows/dietpi-software.bash @@ -204,7 +204,7 @@ Process_Software() 167) (( $arch < 3 )) || aSERVICES[i]='raspotify';; # 32-bit ARM fails with: "arm-binfmt-P: /usr/bin/librespot: Unable to find a guest_base to satisfy all guest address mapping requirements" #169) aSERVICES[i]='voice-recognizer';; "RuntimeError: This module can only be run on a Raspberry Pi!" 170) aCOMMANDS[i]='unrar -V';; - #171) aSERVICES[i]='frps frpc' aTCP[i]='7000 7400 7500';; Interactive install with service and ports depending on server/client/both choice + 171) aSERVICES[i]='frps frpc' aTCP[i]='7000 7400 7500';; 172) aSERVICES[i]='wg-quick@wg0' aUDP[i]='51820';; 174) aCOMMANDS[i]='gimp -v';; 176) aSERVICES[i]='mycroft';; diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index c2e229892e..e377c9b8f2 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -1509,7 +1509,6 @@ Available commands: aSOFTWARE_DESC[$software_id]='reverse proxy' aSOFTWARE_CATX[$software_id]=16 aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/advanced_networking/#frp' - aSOFTWARE_INTERACTIVE[$software_id]=1 # Home Automation #-------------------------------------------------------------------------------- @@ -6538,18 +6537,16 @@ _EOF_ G_EXEC cd frp_* - local choice_required= - while : - do - G_WHIP_MENU_ARRAY=( - 'Server' ': Use this machine as a server, with a public IP' - 'Client' ': Use this machine as a client, without a public IP' - 'Both' ': Run the reverse proxy only on this machine' - ) + # Mode choice + G_WHIP_MENU_ARRAY=( + 'Server' ': Use this machine as a server, with a public IP' + 'Client' ': Use this machine as a client, without a public IP' + 'Both' ': Run the reverse proxy only on this machine' + ) - G_WHIP_MENU "${choice_required}Please choose how you are going to run frp." && break - choice_required='[ERROR] A choice is required to finish the frp install.\n\n' - done + G_WHIP_NOCANCEL=1 + G_WHIP_DEFAULT_ITEM='Both' + G_WHIP_MENU 'Please choose how you are going to run frp:' local mode=$G_WHIP_RETURNED_VALUE G_EXEC mkdir -p /etc/frp @@ -6577,6 +6574,18 @@ RestartSec=5s [Install] WantedBy=multi-user.target _EOF_ + # Pre-v9.9: Inform about config file migration + if [[ -f '/etc/frp/frps.ini' ]] + then + G_WHIP_MSG '[WARNING] New toml config file will be generated +\nfrp deprecated the ini format for its config files, hence /etc/frp/frps.toml will be generated and used from now on. +\nAn automated conversion is not possible and hence need to be done manually, if you did changes. A backup of the ini config it kept in place: +- /etc/frp/frps.ini.bak +\nA full overview of all config keys can be found here: +- https://github.com/fatedier/frp/blob/dev/conf/frps_full_example.toml' + G_EXEC mv /etc/frp/frps.ini{,.bak} + fi + # Pre-create config file to turn on dashboard token=$(openssl rand -hex 15) [[ -f '/etc/frp/frps.toml' ]] || cat << _EOF_ > /etc/frp/frps.toml @@ -6617,22 +6626,39 @@ RestartSec=5s [Install] WantedBy=multi-user.target _EOF_ - local server_addr='127.0.0.1' server_port=7000 - if [[ $G_WHIP_RETURNED_VALUE == 'Client' ]] + # Pre-v9.9: Inform about config file migration + if [[ -f '/etc/frp/frpc.ini' ]] then - G_WHIP_DEFAULT_ITEM="$server_addr:$server_port" - G_WHIP_INPUTBOX_REGEX='^[0-9.:]+$' - G_WHIP_INPUTBOX_REGEX_TEXT='be a valid IP address, optionally with appended network port number, like "192.168.1.100:7000"' - G_WHIP_INPUTBOX 'Please enter the IP address of your frp server, optionally including port (default 7000):' - server_addr=${G_WHIP_RETURNED_VALUE%:*} - [[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE##*:} - - G_WHIP_INPUTBOX 'Please enter the authentication token of your frp server:' - token=$G_WHIP_RETURNED_VALUE + G_WHIP_MSG '[WARNING] New toml config file will be generated +\nfrp deprecated the ini format for its config files, hence /etc/frp/frpc.toml will be generated and used from now on. +\nAn automated conversion is not possible and hence need to be done manually, if you did changes. A backup of the ini config it kept in place: +- /etc/frp/frpc.ini.bak +\nA full overview of all config keys can be found here: +- https://github.com/fatedier/frp/blob/dev/conf/frpc_full_example.toml' + G_EXEC mv /etc/frp/frpc.ini{,.bak} fi # Pre-create config file to turn on admin UI - [[ -f '/etc/frp/frpc.toml' ]] || cat << _EOF_ > /etc/frp/frpc.toml + if [[ ! -f '/etc/frp/frpc.toml' ]] + then + local server_addr='127.0.0.1' server_port=7000 + if [[ $G_WHIP_RETURNED_VALUE == 'Client' ]] + then + G_WHIP_NOCANCEL=1 + G_WHIP_DEFAULT_ITEM="$server_addr:$server_port" + G_WHIP_INPUTBOX_REGEX='^[0-9.:]+$' + G_WHIP_INPUTBOX_REGEX_TEXT='be a valid IP address, optionally with appended network port number, like "192.168.1.100:7000"' + G_WHIP_INPUTBOX 'Please enter the IP address of your frp server, optionally including port (default 7000):' + server_addr=${G_WHIP_RETURNED_VALUE%:*} + [[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE##*:} + + G_WHIP_NOCANCEL=1 + G_WHIP_INPUTBOX_REGEX='*' + G_WHIP_INPUTBOX 'Please enter the authentication token of your frp server:' + token=$G_WHIP_RETURNED_VALUE + fi + + cat << _EOF_ > /etc/frp/frpc.toml serverAddr = "$server_addr" serverPort = $server_port @@ -6644,6 +6670,8 @@ webServer.password = "$GLOBAL_PW" auth.method = "token" auth.token = "$token" _EOF_ + fi + G_EXEC chmod 0660 /etc/frp/frpc.toml G_EXEC chown root:frp /etc/frp/frpc.toml aENABLE_SERVICES+=('frpc') diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index 36a6efd12c..4136e15a8e 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -483,8 +483,8 @@ $grey───────────────────────── local whip_chars_text=$(( $WHIP_SIZE_X - 4 )) # Due to internal margins, the available width is 4 characters smaller WHIP_SCROLLTEXT= # Add "--scrolltext" automatically if text height exceeds max available - Process_Line(){ - + Process_Line() + { local split line=$1 # Split line by "\n" newline escape sequences, the only one which is interpreted by whiptail, in a strict way: "\\n" still creates a newline, hence the sequence cannot be escaped! @@ -504,27 +504,25 @@ $grey───────────────────────── (( whip_lines_text += 1 + ( ${#line} - 1 ) / $whip_chars_text )) # Stop counting if required size exceeds screen already (( $whip_lines_text <= $WHIP_SIZE_Y )) || return 1 - } # - WHIP_MESSAGE - if [[ $WHIP_ERROR$WHIP_MESSAGE ]]; then - + if [[ $WHIP_ERROR$WHIP_MESSAGE ]] + then while read -r line; do Process_Line "$line" || break; done <<< "$WHIP_ERROR$WHIP_MESSAGE" # - WHIP_TEXTFILE - elif [[ $WHIP_TEXTFILE ]]; then - + elif [[ $WHIP_TEXTFILE ]] + then while read -r line; do Process_Line "$line" || break; done < "$WHIP_TEXTFILE" - fi unset -f Process_Line # Process menu and checklist # - G_WHIP_MENU - if [[ $input_mode == 2 ]]; then - + if [[ $input_mode == 2 ]] + then # Requires 1 additional line for text ((whip_lines_text++)) @@ -554,8 +552,8 @@ $grey───────────────────────── done # - G_WHIP_CHECKLIST - elif [[ $input_mode == 3 ]]; then - + elif [[ $input_mode == 3 ]] + then # Lines required for checklist: ( ${#array} + 2 ) to round up single+double array entries WHIP_SIZE_Z=$(( ( ${#G_WHIP_CHECKLIST_ARRAY[@]} + 2 ) / 3 )) @@ -580,44 +578,37 @@ $grey───────────────────────── G_WHIP_CHECKLIST_ARRAY[$i]+='●' done - fi # Adjust sizes to fit content # - G_WHIP_MENU/G_WHIP_CHECKLIST needs to hold text + selection field (WHIP_SIZE_Z) - if [[ $input_mode == [23] ]]; then - + if [[ $input_mode == [23] ]] + then # If required lines would exceed screen, reduce WHIP_SIZE_Z - if (( $whip_lines_text + $WHIP_SIZE_Z > $WHIP_SIZE_Y )); then - + if (( $whip_lines_text + $WHIP_SIZE_Z > $WHIP_SIZE_Y )) + then WHIP_SIZE_Z=$(( $WHIP_SIZE_Y - $whip_lines_text )) # Assure at least 2 lines to have the selection field scroll bar identifiable - if (( $WHIP_SIZE_Z < 2 )); then - + if (( $WHIP_SIZE_Z < 2 )) + then WHIP_SIZE_Z=2 # Since text is partly hidden now, add text scroll ability and info to backtitle WHIP_SCROLLTEXT='--scrolltext' WHIP_BACKTITLE+=' | Use up/down buttons to scroll text' - fi # else reduce WHIP_SIZE_Y to hold all content else - WHIP_SIZE_Y=$(( $whip_lines_text + $WHIP_SIZE_Z )) - fi # - Everything else needs to hold text only - elif (( $whip_lines_text > $WHIP_SIZE_Y )); then - + elif (( $whip_lines_text > $WHIP_SIZE_Y )) + then WHIP_SCROLLTEXT='--scrolltext' WHIP_BACKTITLE+=' | Use up/down buttons to scroll text' - else - WHIP_SIZE_Y=$whip_lines_text - fi } @@ -627,17 +618,14 @@ $grey───────────────────────── { local WHIP_MESSAGE=$* - if [[ $G_INTERACTIVE == 1 ]]; then - + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y G_WHIP_INIT # shellcheck disable=SC2086 whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --msgbox "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" - else - G_DIETPI-NOTIFY 2 "$WHIP_MESSAGE" - fi G_WHIP_DESTROY @@ -650,30 +638,26 @@ $grey───────────────────────── { local result=0 - if [[ $G_INTERACTIVE == 1 ]]; then - + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_MESSAGE WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_TEXTFILE=$1 header='File viewer' [[ $log == 1 ]] && header='Log viewer' - if [[ -f $WHIP_TEXTFILE ]]; then - + if [[ -f $WHIP_TEXTFILE ]] + then G_WHIP_INIT # shellcheck disable=SC2086 whiptail --title "${G_PROGRAM_NAME:+$G_PROGRAM_NAME | }$header" --backtitle "$WHIP_BACKTITLE" --textbox "$WHIP_TEXTFILE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" - else - result=1 WHIP_ERROR="[FAILED] File does not exist: $WHIP_TEXTFILE" G_WHIP_INIT # shellcheck disable=SC2086 whiptail --title "${G_PROGRAM_NAME:+$G_PROGRAM_NAME | }$header" --backtitle "$WHIP_BACKTITLE" --msgbox "$WHIP_ERROR" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" - fi - fi G_WHIP_DESTROY - return "$result" + return "${result:-1}" } # G_WHIP_YESNO "message" @@ -684,18 +668,17 @@ $grey───────────────────────── local result=1 default_no='--defaultno' [[ ${G_WHIP_DEFAULT_ITEM,,} == 'yes' || ${G_WHIP_DEFAULT_ITEM,,} == 'ok' ]] && result=0 default_no= - if [[ $G_INTERACTIVE == 1 ]]; then - + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_MESSAGE=$* G_WHIP_INIT # shellcheck disable=SC2086 whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --yesno "$WHIP_MESSAGE" --yes-button "$G_WHIP_BUTTON_OK_TEXT" --no-button "$G_WHIP_BUTTON_CANCEL_TEXT" "$default_no" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" result=$? - fi G_WHIP_DESTROY - return "$result" + return "${result:-1}" } # G_WHIP_INPUTBOX "message" @@ -707,26 +690,27 @@ $grey───────────────────────── local result=1 unset -v G_WHIP_RETURNED_VALUE # in case left from last G_WHIP - if [[ $G_INTERACTIVE == 1 ]]; then - + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_MESSAGE=$* NOCANCEL=() + G_WHIP_INPUTBOX_REGEX=${G_WHIP_INPUTBOX_REGEX:-'.'} + G_WHIP_INPUTBOX_REGEX_TEXT=${G_WHIP_INPUTBOX_REGEX_TEXT:-'not be empty'} [[ $G_WHIP_NOCANCEL == 1 ]] && NOCANCEL=('--nocancel') while : do G_WHIP_INIT - G_WHIP_INPUTBOX_REGEX=${G_WHIP_INPUTBOX_REGEX:-'.'} - G_WHIP_INPUTBOX_REGEX_TEXT=${G_WHIP_INPUTBOX_REGEX_TEXT:-'not be empty'} # shellcheck disable=SC2086 G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --inputbox "$WHIP_ERROR$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" "${NOCANCEL[@]}" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" "$G_WHIP_DEFAULT_ITEM" 3>&1 1>&2 2>&3-; echo $? > /tmp/.G_WHIP_INPUTBOX_RESULT) read -r result < /tmp/.G_WHIP_INPUTBOX_RESULT; rm -f /tmp/.G_WHIP_INPUTBOX_RESULT [[ $result == 0 && ! $G_WHIP_RETURNED_VALUE =~ $G_WHIP_INPUTBOX_REGEX ]] && { WHIP_ERROR="[FAILED] Input must $G_WHIP_INPUTBOX_REGEX_TEXT, please try again ...\n\n"; continue; } break done - + else + G_WHIP_RETURNED_VALUE=$G_WHIP_DEFAULT_ITEM fi G_WHIP_DESTROY - return "$result" + return "${result:-1}" } # G_WHIP_PASSWORD "message" @@ -738,8 +722,8 @@ $grey───────────────────────── local return_value=1 unset -v result # in case left from last call - if [[ $G_INTERACTIVE == 1 ]]; then - + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_MESSAGE=$* while : do @@ -753,11 +737,10 @@ $grey───────────────────────── return_value=0 break done - fi G_WHIP_DESTROY - return "$return_value" + return "${return_value:-1}" } # G_WHIP_MENU "message" @@ -768,19 +751,24 @@ $grey───────────────────────── local result=1 unset -v G_WHIP_RETURNED_VALUE # in case left from last call - [[ $G_INTERACTIVE == 1 ]] && until [[ $G_WHIP_RETURNED_VALUE ]] # Stay in menu if empty option was selected (separator line) - do + if [[ $G_INTERACTIVE == 1 ]] + then local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_SIZE_Z WHIP_MESSAGE=$* NOCANCEL=() [[ $G_WHIP_NOCANCEL == 1 ]] && NOCANCEL=('--nocancel') - G_WHIP_INIT 2 - # shellcheck disable=SC2086 - G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --menu "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" "${NOCANCEL[@]}" --default-item "$G_WHIP_DEFAULT_ITEM" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" "$WHIP_SIZE_Z" -- "${G_WHIP_MENU_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_MENU_RESULT) - read -r result < /tmp/.WHIP_MENU_RESULT; rm -f /tmp/.WHIP_MENU_RESULT - [[ ${result:=1} == 0 ]] || break # Exit loop in case of cancel button selection or error or if .WHIP_MENU_RESULT could not be created - done + until [[ $G_WHIP_RETURNED_VALUE ]] # Stay in menu if empty option was selected (separator line) + do + G_WHIP_INIT 2 + # shellcheck disable=SC2086 + G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --menu "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" "${NOCANCEL[@]}" --default-item "$G_WHIP_DEFAULT_ITEM" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" "$WHIP_SIZE_Z" -- "${G_WHIP_MENU_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_MENU_RESULT) + read -r result < /tmp/.WHIP_MENU_RESULT; rm -f /tmp/.WHIP_MENU_RESULT + [[ ${result:=1} == 0 ]] || break # Exit loop in case of cancel button selection or error or if .WHIP_MENU_RESULT could not be created + done + else + G_WHIP_RETURNED_VALUE=$G_WHIP_DEFAULT_ITEM + fi G_WHIP_DESTROY - return "$result" + return "${result:-1}" } # G_WHIP_CHECKLIST "message" @@ -800,6 +788,8 @@ $grey───────────────────────── G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME:+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE | Use spacebar to toggle selection" --checklist "$WHIP_MESSAGE" --separate-output --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" "${NOCANCEL[@]}" --default-item "$G_WHIP_DEFAULT_ITEM" $WHIP_SCROLLTEXT "$WHIP_SIZE_Y" "$WHIP_SIZE_X" "$WHIP_SIZE_Z" -- "${G_WHIP_CHECKLIST_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_CHECKLIST_RESULT) G_WHIP_RETURNED_VALUE=$(echo -e "$G_WHIP_RETURNED_VALUE" | tr '\n' ' ') read -r result < /tmp/.WHIP_CHECKLIST_RESULT; rm -f /tmp/.WHIP_CHECKLIST_RESULT + else + G_WHIP_RETURNED_VALUE=$G_WHIP_DEFAULT_ITEM fi G_WHIP_DESTROY From 0a61f7baedc2f5fb82723a58bf1fd25b5e393ff0 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 18:03:44 +0100 Subject: [PATCH 5/8] v9.9 - CHANGELOG | Add frp changes --- CHANGELOG.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a0b004dc67..72a33a5196 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,6 +10,8 @@ Enhancements: - DietPi-Software | NFS Server: The "fsid=0" option has been removed from the /mnt/dietpi_userdata default export. As it is uncommon and not respected in "showmount -e" export lists, it caused confusion and issues. - DietPi-Software | YaCy: The latest YaCy version will now be installed, and the global software password will be set as default admin password on fresh installs. - DietPi-Software | MineOS: As a security enhancement and workaround for a web UI login issue, a dedicated "mineos" user is created again. For new MineOS installs or after reinstall, one can login with this user, and the global software password. It has permissions to install and manage Minecraft instances. +- DietPi-Software | frp: It is now possible to connect the client to a server which has no (an empty) authentication token configured. frp can now be installed non-interactively, where client + server daemons are both installed and configured to work with each other, with respective defaults for all inputs. +- DietPi-Software | frp: Since the ini format for config files has been deprecated, and support will be removed in a future frp release, new installs and reinstalls/updates will generated toml format config files from now on. As of the large amount of config keys, which all changed between those formats, an automated conversion is sadly not possible. When doing a reinstall with existing ini configs, you will be informed about it, the old config(s) will be kept as backup in place, for a manual migration. All config keys for the toml format can be found here: https://github.com/fatedier/frp/tree/dev/conf Bug fixes: - NanoPi M1 Plus | Resolved an issue where Ethernet did not work because of a faulty kernel patch. Many thanks to @InnovoMagicCube and @InnovoDeveloper for reporting this issue: https://github.com/MichaIng/DietPi/issues/6974 @@ -21,6 +23,7 @@ Bug fixes: - DietPi-Software | MineOS: Worked around an issue where the install failed on Bookworm systems, as one of the Node.js modules failed to compile for unknown reasons. Many thanks to @mikedebian for reporting this issue: https://github.com/MichaIng/DietPi/issues/7265 - DietPi-Software | MineOS: Worked around an issue where login into the web interface failed since Bullseye, as MineOS does not support the new default yescrypt password hash algorithm for UNIX users. A new dedicated "mineos" user is now created, and its password set explicitly with SHA512 hash algorithm. Many thanks to @maybaxstv for reporting this issue: https://github.com/MichaIng/DietPi/issues/5759 - DietPi-Software | Node.js: Resolved an issue where node failed on ARMv7 Bullseye systems, since the latest version for this architecture requires a newer C++ standard library than provided on Bullseye. +- DietPi-Software | frp: Resolved an issue where server address and port inputs for the client config generation were parsed incorrectly. As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/ADDME From 9a2486ae2d74b5bb5454db1b48aed6dfd8e642d2 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 20:22:17 +0100 Subject: [PATCH 6/8] v9.9 - DietPi-Software | frp: In case ESC is accidentally pressed, continue with default choice --- dietpi/dietpi-software | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index e377c9b8f2..8e85dd4830 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6547,7 +6547,7 @@ _EOF_ G_WHIP_NOCANCEL=1 G_WHIP_DEFAULT_ITEM='Both' G_WHIP_MENU 'Please choose how you are going to run frp:' - local mode=$G_WHIP_RETURNED_VALUE + local mode=${G_WHIP_RETURNED_VALUE:-$G_WHIP_DEFAULT_ITEM} G_EXEC mkdir -p /etc/frp Create_User frp -d /etc/frp From b675711ebb31867231621a2e6c65e0cc850d0039 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 20:24:27 +0100 Subject: [PATCH 7/8] v9.9 - DietPi-Software | frp: G_WHIP_DEFAULT_ITEM is unset within G_WHIP call --- dietpi/dietpi-software | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 8e85dd4830..773e663de4 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6547,7 +6547,7 @@ _EOF_ G_WHIP_NOCANCEL=1 G_WHIP_DEFAULT_ITEM='Both' G_WHIP_MENU 'Please choose how you are going to run frp:' - local mode=${G_WHIP_RETURNED_VALUE:-$G_WHIP_DEFAULT_ITEM} + local mode=${G_WHIP_RETURNED_VALUE:-Both} G_EXEC mkdir -p /etc/frp Create_User frp -d /etc/frp From f49ae342ade9f1d5bae1cd40e6cb77e0327aa8a7 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sun, 1 Dec 2024 20:27:16 +0100 Subject: [PATCH 8/8] v9.9 - DietPi-Software | frp: Use default server address if ESC is accidentally hit to abort input --- dietpi/dietpi-software | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 773e663de4..8fc948754c 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -6649,7 +6649,7 @@ _EOF_ G_WHIP_INPUTBOX_REGEX='^[0-9.:]+$' G_WHIP_INPUTBOX_REGEX_TEXT='be a valid IP address, optionally with appended network port number, like "192.168.1.100:7000"' G_WHIP_INPUTBOX 'Please enter the IP address of your frp server, optionally including port (default 7000):' - server_addr=${G_WHIP_RETURNED_VALUE%:*} + [[ $G_WHIP_RETURNED_VALUE ]] && server_addr=${G_WHIP_RETURNED_VALUE%:*} [[ $G_WHIP_RETURNED_VALUE =~ : ]] && server_port=${G_WHIP_RETURNED_VALUE##*:} G_WHIP_NOCANCEL=1