Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

2019.2 #1281

Open
wants to merge 6 commits into
base: 2019.2
Choose a base branch
from
Open

2019.2 #1281

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 64 additions & 24 deletions nethunter-installer/boot-patcher/patch.d/02-no-verity-opt-encrypt
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,77 @@ print "Disabling dm-verity & forced encryption..."

found_fstab=false

for fstab in fstab.*; do
[ -f "$fstab" ] || continue
device_name=$(getprop ro.product.device)
isEncrypted=$(getprop ro.crypto.state)

if [ "$device_name" = "cheeseburger" ] || [ "$device_name" = "dumpling" ]; then
print "Device is $device_name"
if [ "$isEncrypted" = "unencrypted" ]; then
print "Phone is not encrypted"
for fstab in /system/vendor/etc/fstab.*; do
[ -f "$fstab" ] || continue
found_fstab=true
print "Found fstab: $fstab"
print "Changing fileencryption=ice to encryptable=footer"
sed "s/fileencryption=ice/encryptable=footer/g" "$fstab" | awk '
$1 ~ /^\// {
n = split($5, flags, ",")
newflags=""
for (i = 1; i <= n; i++) {
if (flags[i] == "")
continue
if (flags[i] ~ /^verify/)
continue
if (flags[i] ~ /^support_scfs/)
continue
if (i > 1) newflags = newflags ","
newflags = newflags flags[i]
}
if ($5 != newflags) $5 = newflags
if ($5 == "") $5 = "defaults"
}
{ print }
' > "$fstab-"
replace_file "$fstab" "$fstab-"
done
else
print "Device is encrypted!! There will be no change for fstab.qcom"
print "This may result a bootloop for any encrypted device, if you got bootloop, please make a factory reset in recovery and full wipe the system and data partition."
fi
else
for fstab in fstab.*; do
[ -f "$fstab" ] || continue
found_fstab=true
print "Found fstab: $fstab"
sed "
s/\b\(forceencrypt\|forcefdeorfbe\)=/encryptable=/g
" "$fstab" | awk '
$1 ~ /^\// {
n = split($5, flags, ",")
newflags=""
for (i = 1; i <= n; i++) {
if (flags[i] == "")
continue
if (flags[i] ~ /^verify/)
continue
if (flags[i] ~ /^support_scfs/)
continue
if (i > 1) newflags = newflags ","
newflags = newflags flags[i]
}
if ($5 != newflags) $5 = newflags
if ($5 == "") $5 = "defaults"
sed "s/\b\(forceencrypt\|forcefdeorfbe\)=/encryptable=/g" "$fstab" | awk '
$1 ~ /^\// {
n = split($5, flags, ",")
newflags=""
for (i = 1; i <= n; i++) {
if (flags[i] == "")
continue
if (flags[i] ~ /^verify/)
continue
if (flags[i] ~ /^support_scfs/)
continue
if (i > 1) newflags = newflags ","
newflags = newflags flags[i]
}
{ print }
' > "$fstab-"
if ($5 != newflags) $5 = newflags
if ($5 == "") $5 = "defaults"
}
{ print }
' > "$fstab-"
replace_file "$fstab" "$fstab-"
found_fstab=true
done
done
fi

$found_fstab || print "Unable to find the fstab!"

print "Setting ro.config.dmverity to false"
setprop ro.config.dmverity false
print "Removing verity_key and /sbin/firmware_key.cer"
rm -f verity_key sbin/firmware_key.cer
print "Done."

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,12 @@ print " NetHunter Uninstaller "
print "***********************"

mount /system
mount /data

# Remove added firmware (folder would only exist if you installed NetHunter)
[ -d "/system/etc/firmware/rtlwifi" ] && {
print "@Removing Firmware";
rm -rf /system/etc/firmware/rtlwifi
rm -rf /system/etc/firmware/zd1211
rm -f /system/etc/firmware/ar9170-1.fw
rm -f /system/etc/firmware/ar9170-2.fw
rm -f /system/etc/firmware/carl9170.fw
rm -f /system/etc/firmware/htc_7010.fw
rm -f /system/etc/firmware/rt73.bin
rm -f /system/etc/firmware/rt2561.bin
rm -f /system/etc/firmware/rt2860.bin
rm -f /system/etc/firmware/rt2870.bin
rm -f /system/etc/firmware/rt3070.bin
}

[ -d "/system/priv-app/NetHunter" ] && {
print "@Removing NetHunter.apk"
rm -rf /system/priv-app/NetHunter
}

[ -d "/data/data/com.offsec.nethunter" ] && {
print "@Removing NetHunter chroot/data"
rm -rf /data/data/com.offsec.nethunter
[ -d "/data/local/nhsystem" ] && {
print "@Removing nhsystem"
rm -rf /data/local/nhsystem
}

cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ progress 0.7
install "/data/local" 0755 0644
}

[ -d data/local/nhscripts ] && {
print "Copying helper scripts to /data/local/nhscripts"
install "/data/local/nhscripts" 0755 0755
}

[ -d system/etc/init.d ] && {
print "Installing init.d scripts"
install "/system/etc/init.d" 0755 0755
Expand Down
67 changes: 67 additions & 0 deletions nethunter-installer/update/data/local/nhscripts/ath9k_disable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/system/bin/sh

##
# Script to remove of atheros ath9k modules via init.d or immediately
##

SYSTEM_DEVICE="/dev/block/bootdevice/by-name/system"
INIT_DIR=""

# use init.d folder if available
if [ -d /system/etc/init.d ]; then
INIT_DIR="/system/etc/init.d"
fi

# if Magisk is available use its init folder
if [ -d /sbin/.magisk/img/.core/post-fs-data.d ]; then
INIT_DIR="/sbin/.magisk/img/.core/post-fs-data.d"
fi

# no init folders found, only manual mode possible
if [ -z "$INIT_DIR" ] && [ ! -z "$1" ]; then
echo "You need Magisk installed or a kernel which supports /system/etc/init.d folder to use a modules loading init script!"
echo "You however still can use the command line option 'now' with this script to unload modules immediately."
echo "Don't forget to reboot afterwards!"
exit 1
fi

# check if needed modules are available otherwise quit
if [ ! -f /system/lib/modules/mac80211.ko -o ! -f /system/lib/modules/ath9k.ko -o ! -f /system/lib/modules/ath9k_common.ko -o ! -f /system/lib/modules/ath9k_htc.ko -o ! -f /system/lib/modules/ath9k.ko ]; then
echo "At least one of the needed modules are missing!"
echo "Modules mac80211.ko, ath9k.ko, ath9k_common.ko, ath9k_htc.ko, ath9k.ko"
echo "must be present in /system/lib/modules/"
echo "Be sure that you use a kernel which has atheros ath9k chipset support enabled!"
exit 1
fi

# use this to unload modules immediately
if [ "$1" == "now" ]; then
busybox rmmod ath9k_htc
busybox rmmod ath9k
busybox rmmod ath9k_common
busybox rmmod ath9k_hw
if [ -f /system/lib/modules/ath.ko ]; then
busybox rmmod ath
fi
busybox rmmod mac80211
sleep 1
# enable systems wifi
svc wifi enable
echo "Modules unloaded, please reboot now!"
exit 0
fi

# default is to remove init script again and do a reboot (lesser problems expected)
if [ -f $INIT_DIR/99_ath9k_init.sh ]; then
mount -o rw,remount /system
rm $INIT_DIR/99_ath9k_init.sh
busybox sync
mount -o ro,remount /system
# enable systems wifi
svc wifi enable
# finally reboot
echo 0 > /sys/kernel/dyn_fsync/Dyn_fsync_active
busybox sync
sleep 1
/system/bin/reboot
fi
93 changes: 93 additions & 0 deletions nethunter-installer/update/data/local/nhscripts/ath9k_enable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/system/bin/sh

##
# Script to proper load atheros ath9k modules via init.d or immediately
##

# system device
SYSTEM_DEVICE="/dev/block/bootdevice/by-name/system"
INIT_DIR=""

# use init.d folder if available
if [ -d /system/etc/init.d ]; then
INIT_DIR="/system/etc/init.d"
fi

# if Magisk is available use its init folder
if [ -d /sbin/.magisk/img/.core/post-fs-data.d ]; then
INIT_DIR="/sbin/.magisk/img/.core/post-fs-data.d"
fi

# no init folders found, only manual mode possible
if [ -z "$INIT_DIR" ] && [ ! -z "$1" ]; then
echo "You need Magisk installed or a kernel which supports /system/etc/init.d folder to use a modules loading init script!"
echo "You however still can use the command line option 'now' with this script to unload modules immediately."
echo "Don't forget to reboot afterwards!"
exit 1
fi

# check if needed modules are available otherwise quit
if [ ! -f /system/lib/modules/mac80211.ko -o ! -f /system/lib/modules/ath9k.ko -o ! -f /system/lib/modules/ath9k_common.ko -o ! -f /system/lib/modules/ath9k_htc.ko -o ! -f /system/lib/modules/ath9k.ko ]; then
echo "At least one of the needed modules are missing!"
echo "Modules mac80211.ko, ath9k.ko, ath9k_common.ko, ath9k_htc.ko, ath9k.ko"
echo "must be present in /system/lib/modules/"
echo "Be sure that you use a kernel which has atheros ath9k chipset support enabled!"
exit 1
fi

# use 'now' option to load modules immediately
if [ "$1" == "now" ]; then

# disable systems wifi
svc wifi disable
sleep 2

# load modules in proper dependency order (mac80211.ko always first)
busybox insmod /system/lib/modules/mac80211.ko

# only add ath module if available (newer driver versions have that module)
if [ -f /system/lib/modules/ath.ko ]; then
busybox insmod /system/lib/modules/ath.ko
fi

# ath9k module sequence
busybox insmod /system/lib/modules/ath9k_hw.ko
busybox insmod /system/lib/modules/ath9k_common.ko
busybox insmod /system/lib/modules/ath9k_htc.ko
busybox insmod /system/lib/modules/ath9k.ko
exit 0
fi

# create init script in init folder and reboot
if [ ! -f $INIT_DIR/99_ath9k_init.sh ]; then

# disable systems wifi (+reboot = important to avoid possible driver clash!)
svc wifi disable

# create init script
mount -o rw,remount /system
echo "#!/system/bin/sh" > $INIT_DIR/99_ath9k_init.sh
echo "busybox insmod /system/lib/modules/mac80211.ko" >> $INIT_DIR/99_ath9k_init.sh

# only add ath.ko module if available (newer driver versions have that module)
if [ -f /system/lib/modules/ath.ko ]; then
echo "busybox insmod /system/lib/modules/ath.ko" >> $INIT_DIR/99_ath9k_init.sh
fi

# ath9k module sequence
echo "busybox insmod /system/lib/modules/ath9k_hw.ko" >> $INIT_DIR/99_ath9k_init.sh
echo "busybox insmod /system/lib/modules/ath9k_common.ko" >> $INIT_DIR/99_ath9k_init.sh
echo "busybox insmod /system/lib/modules/ath9k_htc.ko" >> $INIT_DIR/99_ath9k_init.sh
echo "busybox insmod /system/lib/modules/ath9k.ko" >> $INIT_DIR/99_ath9k_init.sh

# make it executeable
busybox chmod 775 $INIT_DIR/99_ath9k_init.sh
busybox sync
mount -o ro,remount /system

# finally reboot
echo 0 > /sys/kernel/dyn_fsync/Dyn_fsync_active
busybox sync
sleep 2
/system/bin/reboot
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/system/bin/sh
##
# use this in a root shell to disable OTG inactivity timeout on OOS roms
# more infos: https://www.xda-developers.com/enable-always-on-otg-oxygenos/
##
settings put global oneplus_otg_auto_disable 0

62 changes: 62 additions & 0 deletions nethunter-installer/update/data/local/nhscripts/rtl8187_disable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/system/bin/sh

##
# Script to remove of realtek rtl8187 modules via init.d or immediately
##

# system device
SYSTEM_DEVICE="/dev/block/bootdevice/by-name/system"
INIT_DIR=""

# use init.d folder if available
if [ -d /system/etc/init.d ]; then
INIT_DIR="/system/etc/init.d"
fi

# if Magisk is available use its init folder
if [ -d /sbin/.magisk/img/.core/post-fs-data.d ]; then
INIT_DIR="/sbin/.magisk/img/.core/post-fs-data.d"
fi

# no init folders found, only manual mode possible
if [ -z "$INIT_DIR" ] && [ ! -z "$1" ]; then
echo "You need Magisk installed or a kernel which supports /system/etc/init.d folder to use a modules loading init script!"
echo "You however still can use the command line option 'now' with this script to unload modules immediately."
echo "Don't forget to reboot afterwards!"
exit 1
fi

# check if needed modules are available otherwise quit
if [ ! -f /system/lib/modules/mac80211.ko -o ! -f /system/lib/modules/rtl8187.ko -o ! -f /system/lib/modules/eeprom_93cx6.ko ]; then
echo "At least one of the needed modules are missing!"
echo "Modules mac80211.ko, rtl8187.ko, eeprom_93cx6.ko"
echo "must be present in /system/lib/modules/"
echo "Be sure that you use a kernel which has realtek rtl8187 chipset support enabled!"
exit 1
fi

# use this to unload modules immediately
if [ "$1" == "now" ]; then
busybox rmmod rtl8187
busybox rmmod eeprom_93cx6
busybox rmmod mac80211
sleep 1
# enable systems wifi
svc wifi enable
exit 0
fi

# but default is to remove init script and do a reboot (lesser problems expected)
if [ -f $INIT_DIR/99_rtl8187_init.sh ]; then
mount -o rw,remount /system
rm $INIT_DIR/99_rtl8187_init.sh
busybox sync
mount -o ro,remount /system
# enable systems wifi
svc wifi enable
# finally reboot
echo 0 > /sys/kernel/dyn_fsync/Dyn_fsync_active
busybox sync
sleep 1
/system/bin/reboot
fi
Loading