diff --git a/module/common/UpdateTargetList.sh b/module/UpdateTargetList.sh similarity index 88% rename from module/common/UpdateTargetList.sh rename to module/UpdateTargetList.sh index 8adf24e..981eefe 100644 --- a/module/common/UpdateTargetList.sh +++ b/module/UpdateTargetList.sh @@ -10,14 +10,14 @@ MODDIR="/data/adb/tricky_store/target_list_config" echo "- Checking config files..." echo " " if [ ! -f "$MODDIR/EXCLUDE" ]; then - echo "! Exclude list is missing, please reinstall module" + echo "! Exclude list is missing!" exit 1 else echo "- Exclude config file found." echo " " fi if [ ! -f "$MODDIR/ADDITION" ]; then - echo "! Addition list is missing, please reinstall module" + echo "! Addition list is missing" exit 1 else echo "- Addition config file found." @@ -43,7 +43,8 @@ sleep 1 echo "- Adding addition app... " echo " " for app in $ADDITION; do - if ! grep -qx "$app" /data/adb/tricky_store/target.txt; then + app=$(echo "$app" | tr -d '[:space:]') # Trim any whitespace + if ! grep -Fxq "$app" /data/adb/tricky_store/target.txt; then echo "$app" >> /data/adb/tricky_store/target.txt fi done diff --git a/module/action.sh b/module/action.sh index a147298..b46ab76 100644 --- a/module/action.sh +++ b/module/action.sh @@ -3,9 +3,9 @@ echo "**********************************************" echo "- Staring script..." echo " " -sh "$MODDIR"/common/UpdateTargetList.sh +sh "$MODDIR"/UpdateTargetList.sh echo "**********************************************" echo "\(__All set!__)/" -echo "Exiting in 3 seconds..." -sleep 3 \ No newline at end of file +echo "Exiting in 2 seconds..." +sleep 2 \ No newline at end of file diff --git a/module/customize.sh b/module/customize.sh index 7c28449..f19379b 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -19,7 +19,15 @@ print_modname() { ui_print "*******************************************************" } -if [ -d /data/adb/modules/tricky_store ]; then +COMPATH="$MODPATH/common" +TS="/data/adb/tricky_store" +CONFIG_DIR="$TS/target_list_config" +MODNAME=$(grep '^id=' "$MODPATH/module.prop" | awk -F= '{print $2}' | xargs) +ORG_DIR="/data/adb/modules/$MODNAME" +EXCLUDE=$(grep -vE '^#|^$' "$CONFIG_DIR/EXCLUDE") +ADDITION=$(grep -vE '^#|^$' "$CONFIG_DIR/ADDITION") + +if [ -d "$TS" ]; then echo "- Tricky store module installed" else echo "! Tricky store module is not installed" @@ -46,14 +54,7 @@ key_check() { done } -ui_print "- Installing..." -COMPATH="$MODPATH/common" -CONFIG_DIR="/data/adb/tricky_store/target_list_config" -SCRIPT_DIR="/data/adb/tricky_store" -MODNAME=$(grep '^id=' "$MODPATH/module.prop" | awk -F= '{print $2}' | xargs) - add_exclude() { - EXCLUDE=$(grep -vE '^#|^$' "$CONFIG_DIR/EXCLUDE") for app in $EXCLUDE; do if ! grep -qx "$app" $COMPATH/EXCLUDE; then echo "$app" >> $COMPATH/EXCLUDE @@ -63,7 +64,6 @@ add_exclude() { } add_addition() { - ADDITION=$(grep -vE '^#|^$' "$CONFIG_DIR/ADDITION") for app in $ADDITION; do if ! grep -qx "$app" $COMPATH/ADDITION; then echo "$app" >> $COMPATH/ADDITION @@ -72,19 +72,12 @@ add_addition() { mv "$COMPATH/ADDITION" "$CONFIG_DIR/ADDITION" } -for status in normal ninstalled disabled; do - cp "$MODPATH/module.prop" "$COMPATH/$status" -done -sed -i 's/^description=.*/description=Tricky store is not installed/' "$COMPATH/ninstalled" -sed -i 's/^description=.*/description=Tricky store is disabled/' "$COMPATH/disabled" -rm -f "$SCRIPT_DIR/UpdateTargetList.sh" -cp "$COMPATH/UpdateTargetList.sh" "$SCRIPT_DIR/UpdateTargetList.sh" +ui_print "- Installing..." -if [ ! -d "$CONFIG_DIR" ]; then - mkdir -p "$CONFIG_DIR" - mv "$COMPATH/EXCLUDE" "$CONFIG_DIR/EXCLUDE" - mv "$COMPATH/ADDITION" "$CONFIG_DIR/ADDITION" -elif [ -d "$CONFIG_DIR" ]; then +cp "$MODPATH/UpdateTargetList.sh" "$TS/UpdateTargetList.sh" +cp "$MODPATH/module.prop" "$COMPATH/module.prop.orig" + +if [ -d "$CONFIG_DIR" ]; then if [ ! -f "$CONFIG_DIR/EXCLUDE" ] && [ ! -f "$CONFIG_DIR/ADDITION" ]; then mv "$COMPATH/EXCLUDE" "$CONFIG_DIR/EXCLUDE" mv "$COMPATH/ADDITION" "$CONFIG_DIR/ADDITION" @@ -98,9 +91,12 @@ elif [ -d "$CONFIG_DIR" ]; then add_exclude add_addition fi +else + mkdir -p "$CONFIG_DIR" + mv "$COMPATH/EXCLUDE" "$CONFIG_DIR/EXCLUDE" + mv "$COMPATH/ADDITION" "$CONFIG_DIR/ADDITION" fi -ORG_DIR="/data/adb/modules/$MODNAME" if [ ! -f "$ORG_DIR/boot_hash" ]; then mv "$COMPATH/boot_hash" "$MODPATH/boot_hash" else @@ -124,15 +120,23 @@ ui_print " VOL [-]: NO" ui_print "*********************************************" key_check if [[ "$keycheck" == "KEY_VOLUMEUP" ]]; then - ui_print "*********************************************" - ui_print "- Replacing keybox..." - ui_print "*********************************************" - if [ ! -f "/data/adb/modules/$MODNAME/common/origkeybox" ]; then - mv "$SCRIPT_DIR/keybox.xml" "$COMPATH/origkeybox" - fi - mv "$kb" "$SCRIPT_DIR/keybox.xml" + ui_print "*********************************************" + ui_print "- Replacing keybox..." + ui_print "*********************************************" + + if [ -f "$ORG_DIR/common/origkeybox" ]; then + mv "$ORG_DIR/common/origkeybox" "$COMPATH/origkeybox" + else + mv "$TS/keybox.xml" "$COMPATH/origkeybox" + fi + + mv "$kb" "$TS/keybox.xml" else - rm -f "$kb" + if [ -f "$ORG_DIR/common/origkeybox" ]; then + mv "$ORG_DIR/common/origkeybox" "$COMPATH/origkeybox" + else + rm -f "$kb" + fi fi ui_print " " diff --git a/module/service.sh b/module/service.sh index 595d60f..ef759c1 100644 --- a/module/service.sh +++ b/module/service.sh @@ -1,25 +1,27 @@ -MODDIR=${0%/*} -COMPATH="$MODDIR/common" +MODPATH=${0%/*} TS="/data/adb/modules/tricky_store" -hash_value=$(grep -v '^#' "$MODDIR/boot_hash" | tr -d '[:space:]') +hash_value=$(grep -v '^#' "$MODPATH/boot_hash" | tr -d '[:space:]') if [ -n "$hash_value" ]; then resetprop -n ro.boot.vbmeta.digest "$hash_value" fi -if [ ! -f "$COMPATH/ninstalled" ] || [ ! -f "$COMPATH/disabled" ] || [ ! -f "$COMPATH/normal" ]; then - sed -i 's/^description=.*/description=Module is corrupted, please reinstall module./' "$MODDIR/module.prop" +if [ ! -f "$MODPATH/common/module.prop.orig" ]; then + sed -i 's/^description=.*/description=Module is corrupted, please reinstall module./' "$MODPATH/module.prop" + touch "$MODPATH/disable" exit 1 fi if [ ! -d "$TS" ]; then - cat "$COMPATH/ninstalled" > "$MODDIR/module.prop" + sed -i 's/^description=.*/description=Tricky store is not installed/' "$MODPATH/module.prop" + touch "$MODPATH/disable" elif [ -f "$TS/disable" ]; then - cat "$COMPATH/disabled" > "$MODDIR/module.prop" + sed -i 's/^description=.*/description=Tricky store is disabled/' "$MODPATH/module.prop" + touch "$MODPATH/disable" else - cat "$COMPATH/normal" > "$MODDIR/module.prop" + cat "$MODPATH/common/module.prop.orig" > "$MODPATH/module.prop" until [ "$(getprop sys.boot_completed)" = "1" ]; do sleep 1 done - . "$COMPATH/UpdateTargetList.sh" + . "$MODPATH/UpdateTargetList.sh" fi \ No newline at end of file diff --git a/module/uninstall.sh b/module/uninstall.sh index 26fe0e2..fda929f 100644 --- a/module/uninstall.sh +++ b/module/uninstall.sh @@ -1,9 +1,9 @@ -MODDIR="/data/adb/tricky_store" -# Remove residue and restore original keybox. MODPATH=${0%/*} -rm -rf "$MODDIR/target_list_config" -rm -f "$MODDIR/UpdateTargetList.sh" +TS="/data/adb/tricky_store" +# Remove residue and restore original keybox. +rm -rf "$TS/target_list_config" +rm -f "$TS/UpdateTargetList.sh" if [ -f "$MODPATH/common/origkeybox" ]; then - rm -f "$MODDIR/keybox.xml" - mv "$MODPATH/common/origkeybox" "$MODDIR/keybox.xml" + rm -f "$TS/keybox.xml" + mv "$MODPATH/common/origkeybox" "$TS/keybox.xml" fi \ No newline at end of file