diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index 08e2135a12..de8f73aa15 100644 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -3044,7 +3044,7 @@ #IPv6 status local ipv6_enabled=1 local ipv6_status_text='Enabled' - if [ -f /etc/modprobe.d/blacklist-ipv6.conf ]; then + if [ -f /etc/modprobe.d/99-dietpi-blacklist-ipv6.conf ]; then ipv6_enabled=0 ipv6_status_text='Disabled' fi @@ -3125,7 +3125,16 @@ if (( $CHOICE == 0 )); then - echo -e "blacklist ipv6" > /etc/modprobe.d/blacklist-ipv6.conf + # - Blacklist kernel module + echo 'blacklist ipv6' > /etc/modprobe.d/99-dietpi-blacklist-ipv6.conf + # - APT force IPv4 + echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4 + # - Wget prefer IPv4 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + echo 'prefer-family = IPv4' >> /etc/wgetrc REBOOT_REQUIRED=1 fi @@ -3138,7 +3147,15 @@ if (( $CHOICE == 0 )); then - rm /etc/modprobe.d/blacklist-ipv6.conf &> /dev/null + rm /etc/modprobe.d/99-dietpi-blacklist-ipv6.conf &> /dev/null + # - APT allow IPv6 but do not force it: https://github.com/Fourdee/DietPi/issues/472#issuecomment-356444922 + rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4 &> /dev/null + # - Wget prefer IPv6 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + echo 'prefer-family = IPv6' >> /etc/wgetrc REBOOT_REQUIRED=1 fi diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index 36f277f553..5277020b56 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -73,7 +73,7 @@ # $1 = Optional input directory (eg: G_TREESIZE /etc/apt) G_TREESIZE() { - du -k --max-depth=1 $1 | sort -nr | awk ' + du -k --max-depth=1 "$1" | sort -nr | awk ' BEGIN { split("KB,MB,GB,TB", Units, ","); } @@ -92,6 +92,8 @@ # DietPi-Notify # $1: + # -2=process animation + # - $2 = text # -1=autodetect_fail_ok # - $2 = EXIT_CODE # 0=OK @@ -121,79 +123,71 @@ Print_Process_Animation(){ + local bright_dot="\e[1;93m.\e[0m" + local dimmed_dot="\e[2;33m.\e[0m" local aprocess_string=( - #"\e[90m[\e[1;93m\u23F9 \e[90m]\e[0m" - #"\e[90m[\e[2;33m\u23F9\e[0m\e[1;93m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[2;33m\u23F9\e[0m\e[1;93m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[2;33m\u23F9\e[0m\e[1;93m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[2;33m\u23F9\e[0m\e[1;93m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[2;33m\u23F9\e[0m\e[1;93m\u23F9\e[0m\e[90m]\e[0m" - #"\e[90m[ \e[1;93m\u23F9\e[0m\e[2;33m\u23F9\e[0m\e[90m]\e[0m" - #"\e[90m[ \e[1;93m\u23F9\e[0m\e[2;33m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[1;93m\u23F9\e[0m\e[2;33m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[ \e[1;93m\u23F9\e[0m\e[2;33m\u23F9 \e[0m\e[90m]\e[0m" - #"\e[90m[\e[1;93m\u23F9\e[0m\e[2;33m\u23F9 \e[0m\e[90m]\e[0m" - "\e[90m[\e[1;93m. \e[90m]\e[0m" - "\e[90m[\e[2;33m.\e[0m\e[1;93m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[2;33m.\e[0m\e[1;93m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[2;33m.\e[0m\e[1;93m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[2;33m.\e[0m\e[1;93m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[2;33m.\e[0m\e[1;93m.\e[0m\e[90m]\e[0m" - "\e[90m[ \e[1;93m.\e[0m\e[2;33m.\e[0m\e[90m]\e[0m" - "\e[90m[ \e[1;93m.\e[0m\e[2;33m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[1;93m.\e[0m\e[2;33m. \e[0m\e[90m]\e[0m" - "\e[90m[ \e[1;93m.\e[0m\e[2;33m. \e[0m\e[90m]\e[0m" - "\e[90m[\e[1;93m.\e[0m\e[2;33m. \e[0m\e[90m]\e[0m" + #\u23F9 + "$bright_dot " + "$dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot" + " $bright_dot$dimmed_dot" + " $bright_dot$dimmed_dot " + " $bright_dot$dimmed_dot " + " $bright_dot$dimmed_dot " + "$bright_dot$dimmed_dot " ) - for (( i=0; i<=${#aprocess_string[*]}; i++ )); do + for (( i=0; i<=${#aprocess_string[@]}; i++ )); do (( i == 11 )) && i=1 - builtin printf "\r${aprocess_string[i]} " + [ -f /tmp/dietpi-process.pid ] && printf "\r$bracket_string_l${aprocess_string[i]}$bracket_string_r " || break sleep 0.15 done - unset aprocess_string - } Clean_Process_Animation(){ - if [ -f /var/run/dietpi-process.pid ]; then + if [ -f /tmp/dietpi-process.pid ]; then - kill $( /dev/null - rm /var/run/dietpi-process.pid + kill "$( /dev/null + rm /tmp/dietpi-process.pid &> /dev/null || sudo rm /tmp/dietpi-process.pid &> /dev/null + # In case, the output took more than one line, clean from cursor (animation position) until end of terminal. + tput ed fi - echo -en "\r\e[K" + printf "\r\e[K" } Print_Process(){ - echo -ne "\r\e[9C" + printf "\r\e[9C" } Print_Ok(){ Clean_Process_Animation - echo -ne "$bracket_string_l$status_text_ok$bracket_string_r " + printf "$bracket_string_l$status_text_ok$bracket_string_r " } Print_Failed(){ Clean_Process_Animation - echo -ne "$bracket_string_l$status_text_error$bracket_string_r " + printf "$bracket_string_l$status_text_error$bracket_string_r " } Print_Info(){ Clean_Process_Animation - echo -ne "$bracket_string_l$status_text_info$bracket_string_r " + printf "$bracket_string_l$status_text_info$bracket_string_r " } @@ -204,18 +198,9 @@ local i=0 for (( i=$1;i<${#ainput_string[@]} ;i++)) do - echo -ne "${ainput_string[$i]}" + printf "${ainput_string[$i]}" done - # echo -e "SIZE = ${#ainput_string}" - - # ainput_string="$@" - # for (( i=$1;i<${#ainput_string} ;i++)) - # do - # echo -ne "${ainput_string:$i:1}" - # sleep 0.02 - # done - } #-------------------------------------------------------------------------------------- @@ -249,7 +234,17 @@ Print_Process Print_Input_String 1 - [ ! -f /var/run/dietpi-process.pid ] && ( Print_Process_Animation & builtin echo $! > /var/run/dietpi-process.pid ) + # Calculate the amount of output lines and in case move cursor up for correct animation and to allow cleaning the whole output. + local string="$*" + local lines=0 + (( lines=(${#string}+6)/$(tput cols) )) + while (( lines > 0 )); do + + tput cuu1 + (( lines-- )) + + done + [ ! -f /tmp/dietpi-process.pid ] && touch /tmp/dietpi-process.pid && ( Print_Process_Animation & echo $! > /tmp/dietpi-process.pid ) #Status Ok #$@ = txt desc @@ -284,19 +279,16 @@ echo -e "\n \e[38;5;154m$2\e[0m" echo -e "$header_line" echo -e " \e[90mMode: \e[0m$(Print_Input_String 2)\n" - #Print_Process - #echo -ne "\e[90mPlease wait...\e[0m" - #[ ! -f /var/run/dietpi-process.pid ] && ( Print_Process_Animation & builtin echo $! > /var/run/dietpi-process.pid ) fi #----------------------------------------------------------------------------------- - unset ainput_string # Unset also internal functions, otherwise they are accessible from terminal. unset Print_Process_Animation + unset Clean_Process_Animation + unset Print_Process unset Print_Ok unset Print_Failed unset Print_Info - unset Print_Process unset Print_Input_String #----------------------------------------------------------------------------------- @@ -951,7 +943,7 @@ $print_logfile_info local string=( "$@" ) local packages_to_install='' - G_DIETPI-NOTIFY 2 "Checking for pre-req APT packages: ${string[@]}" + G_DIETPI-NOTIFY 2 "Checking for pre-req APT packages: ${string[*]}" dpkg --get-selections > "$fp_temp" for i in "${string[@]}" diff --git a/dietpi/func/dietpi-set_core_environment b/dietpi/func/dietpi-set_core_environment index 1dc96197f1..ad26f1e4ab 100644 --- a/dietpi/func/dietpi-set_core_environment +++ b/dietpi/func/dietpi-set_core_environment @@ -347,14 +347,6 @@ _EOF_ fi - G_DIETPI-NOTIFY 2 "Configuring: prefer IPv4 (wget):" - - sed -i '/prefer-family =/c\prefer-family = IPv4' /etc/wgetrc - - G_DIETPI-NOTIFY 2 "Configuring: force IPv4 (APT):" - - echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv - #----------------------------------------------------------------------------------- #MISC @@ -371,8 +363,8 @@ _EOF_ G_DIETPI-NOTIFY 2 "Setting vm.swappiness=1:" - sed -i '/vm.swappiness=/d' /etc/sysctl.conf - echo -e "vm.swappiness=1" > /etc/sysctl.d/97-dietpi.conf + sed -i '/^[[:blank:]]*vm.swappiness=/d' /etc/sysctl.conf + echo -e "vm.swappiness=1" > /etc/sysctl.d/99-dietpi.conf #----------------------------------------------------------------------------------- G_DIETPI-NOTIFY 0 "Completed DietPi core environment"