From e87ce1147d2e828ad413c9fad5492b2bf6e9a574 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Wed, 9 Apr 2025 21:46:47 +0200 Subject: [PATCH] winterbreak/jb.sh: fix formatting; remove undefined keywords Makes the current formatting a bit nicer, also does the following things: - removes the `local` keyrword. This is undefined in POSIX sh. - adds double quotes around some expressions to avoid word splitting - changes the `==` equality operator to `=`, since `==` is also not supported by POSIX sh. --- winterbreak/jb.sh | 118 +++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 65 deletions(-) diff --git a/winterbreak/jb.sh b/winterbreak/jb.sh index 9f874e0..dc7325c 100644 --- a/winterbreak/jb.sh +++ b/winterbreak/jb.sh @@ -8,68 +8,60 @@ # ## - - set +e # If boot is halted stuff seriously goes wrong (actually we don't need this anymore but I'm keeping it) - ### # Define logging function ### POS=1 wb_log() { - echo "${1}" >> /mnt/us/winterbreak.log + echo "${1}" >>/mnt/us/winterbreak.log eips 0 $POS "${1}" echo "${1}" - POS=$((POS+1)) + POS=$((POS + 1)) } ### # Prevents potential bootloop for people who didn't properly remove the beta (from when it was called MountSus) ### if [ -f /var/local/root/mntus.params ]; then - if [ $(grep -i "/mnt/us/JB.sh" "/var/local/root/mntus.params") != "" ] ; then + if [ "$(grep -i "/mnt/us/JB.sh" "/var/local/root/mntus.params")" != "" ]; then wb_log "ERROR: MountSus Detected - exiting" exit 0 # The jailbreak has already been run before fi fi if [ -f /var/local/system/mntus.params ]; then - if [ $(grep -i "/mnt/us/JB.sh" "/var/local/system/mntus.params") != "" ] ; then # Just in case! - wb_log "ERROR: MountSus Detected - exiting" - exit 0 # The jailbreak has already been run before + if [ "$(grep -i "/mnt/us/JB.sh" "/var/local/system/mntus.params")" != "" ]; then # Just in case! + wb_log "ERROR: MountSus Detected - exiting" + exit 0 # The jailbreak has already been run before fi fi - - ### # Helper functions ### make_mutable() { - local my_path="${1}" - # NOTE: Can't do that on symlinks, hence the hoop-jumping... - if [ -d "${my_path}" ] ; then - find "${my_path}" -type d -exec chattr -i '{}' \; - find "${my_path}" -type f -exec chattr -i '{}' \; - elif [ -f "${my_path}" ] ; then - chattr -i "${my_path}" - fi + my_path="${1}" + # NOTE: Can't do that on symlinks, hence the hoop-jumping... + if [ -d "${my_path}" ]; then + find "${my_path}" -type d -exec chattr -i '{}' \; + find "${my_path}" -type f -exec chattr -i '{}' \; + elif [ -f "${my_path}" ]; then + chattr -i "${my_path}" + fi } make_immutable() { - local my_path="${1}" - if [ -d "${my_path}" ] ; then - find "${my_path}" -type d -exec chattr +i '{}' \; - find "${my_path}" -type f -exec chattr +i '{}' \; - elif [ -f "${my_path}" ] ; then - chattr +i "${my_path}" - fi + my_path="${1}" + if [ -d "${my_path}" ]; then + find "${my_path}" -type d -exec chattr +i '{}' \; + find "${my_path}" -type f -exec chattr +i '{}' \; + elif [ -f "${my_path}" ]; then + chattr +i "${my_path}" + fi } - - - ### # Actual JB from here ### @@ -90,16 +82,14 @@ wb_log "- Isaac Asimov" wb_log "" wb_log "" - ### # Main key install functions ### -install_touch_update_key() -{ - wb_log "install_touch_update_key - Copying the jailbreak updater key" - make_mutable "/etc/uks/pubdevkey01.pem" - rm -rf "/etc/uks/pubdevkey01.pem" - cat > "/etc/uks/pubdevkey01.pem" << EOF +install_touch_update_key() { + wb_log "install_touch_update_key - Copying the jailbreak updater key" + make_mutable "/etc/uks/pubdevkey01.pem" + rm -rf "/etc/uks/pubdevkey01.pem" + cat >"/etc/uks/pubdevkey01.pem" <