Skip to content

Commit

Permalink
Debug start issues
Browse files Browse the repository at this point in the history
  • Loading branch information
janithcooray authored Oct 26, 2024
1 parent 396e91d commit 83b2073
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# - zip

# Don't forget to increment these
MODFILE_VERSION="v2.0-b"
MODFILE_VERCODE="9"
MODFILE_VERSION="v2.0-c-debug"
MODFILE_VERCODE="10"

set -eu
REPO_TOPLEVEL=$(git rev-parse --show-toplevel)
Expand Down
31 changes: 27 additions & 4 deletions module/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,45 @@
# This will make your scripts compatible even if Magisk change its mount point in the future
MODDIR=${0%/*}

echo "-------------------" >> /data/swap/swapfile.log
now=$(date)
echo "$now" >> /data/swap/swapfile.log
echo "----------BOOT---------" >> /data/swap/swapfile.log
function print_log(){
now=$(date)
echo "$now : $1 - $2" >> /data/swap/swapfile.log
}

function check_file(){
print_log "Checking if $1 Exists"
if [ -e $1 ]; then
echo "File exists."
else
echo "File does not exist."
fi
}

function check_bin(){
if command -v $1 >/dev/null 2>&1; then
echo "$1 exists."
else
echo "$1 does not exist."
fi
}

# START BOOT SAFETY
# We create a file before swap on and delete it after successful start
# If the file exists on service boot, that means there has been an issue from the
# Module. Ask the user to share the /data/swap/swapfile.log file with devs
check_file "/system/bin/swapon"
check_bin "swapon"
check_bin "sysctl"

if [ -e "/data/swap/INCOMPLETE" ]; then
echo "$now : INCOMPLETE FILE still exists! Did it Fail to boot?" >> /data/swap/swapfile.log
else
echo "INCOMPLETE" >> /data/swap/INCOMPLETE
SWAP_FILE_PRIOR="$(cat /data/swap/SWAP_FILE_PRIOR)"
SWAPPINESS="$(cat /data/swap/SWAPPINESS)"
sysctl vm.swappiness=99
sysctl vm.swappiness=$SWAPPINESS
# At this point if it fails, it will exit the script leaving /data/swap/INCOMPLETE
if [[ "$SWAP_FILE_PRIOR" -eq 0 ]]; then
/system/bin/swapon /data/swap/swapfile >> /data/swap/swapfile.log
else
Expand Down

0 comments on commit 83b2073

Please sign in to comment.