Skip to content

Commit

Permalink
v6.35
Browse files Browse the repository at this point in the history
+ DietPi-Set_swapfile | Resolve an issue where "zram"/"zram0" dietpi.txt path entries were dropped, when running the script without input arguments. This especially broke applying zram-swap on first boot.
  • Loading branch information
MichaIng authored Dec 25, 2020
1 parent 4973b52 commit 8eb0973
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dietpi/func/dietpi-set_swapfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
SWAP_SIZE=$(mawk '$2=="file" {printf "%.0f",$3/1024;exit}' /proc/swaps) && disable_error=1 G_CHECK_VALIDINT "$SWAP_SIZE" || SWAP_SIZE=1

fi
# - Path: Store current saved (only absolute paths to exclude zram) and active paths for later use
SWAP_PATH_CURRENT=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=\//{s/^[^=]*=//p;q}' /boot/dietpi.txt)
# - Path: Store dietpi.txt entry (excluding zram-swap) and active swap files for disabling and removal before creating a new swap space
SWAP_PATH=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
read -ra SWAP_FILES_ACTIVE < <(mawk '$2=="file" {print $1}' /proc/swaps)
[[ $SWAP_PATH == '/'* && $SWAP_PATH != '/dev/zram0' ]] && SWAP_FILES_ACTIVE+=("$SWAP_PATH")
if [[ $2 == '/'* || $2 == 'zram' || $2 == 'zram0' ]]; then

SWAP_PATH=$2

elif SWAP_PATH=$SWAP_PATH_CURRENT; [[ $SWAP_PATH != '/'* && $SWAP_PATH != 'zram' && $SWAP_PATH != 'zram0' ]]; then
elif [[ $SWAP_PATH != '/'* && $SWAP_PATH != 'zram' && $SWAP_PATH != 'zram0' ]]; then

SWAP_PATH=$(mawk '$2=="file" {print $1;exit}' /proc/swaps) && [[ $SWAP_PATH == '/'* || $SWAP_PATH == 'zram' || $SWAP_PATH == 'zram0' ]] || SWAP_PATH='/var/swap'

Expand Down Expand Up @@ -79,7 +80,7 @@

G_DIETPI-NOTIFY 2 'Disabling and deleting all existing swap files'
G_EXEC_NOHALT=1 G_EXEC swapoff -a
rm -fv "$SWAP_PATH_CURRENT" "${SWAP_FILES_ACTIVE[@]}"
rm -fv "${SWAP_FILES_ACTIVE[@]}"
sed -i '/[[:blank:]]swap[[:blank:]]/d' /etc/fstab
# zram-swap
[[ -f '/etc/modules-load.d/dietpi-zram-swap.conf' ]] && rm -v /etc/modules-load.d/dietpi-zram-swap.conf
Expand Down

0 comments on commit 8eb0973

Please sign in to comment.