简体   繁体   中英

Explaining this Bash Script

Alright i was flashing a debloater script on my S6 EDGE , but i was curious about how these commands acutally works so i decided to ask for some help...

update-script

unmount("/system");
unmount("/data");
unmount("/preload");
ui_print(" ");

ui_print("Android 6.0 & 7.0 Debloat Script by Windforce0511");
ui_print("Script version: v1");
ui_print(" ");

ui_print("Mounting partitions: /system /data /cache");
run_program("/sbin/mount", "-t", "auto", "/system");
run_program("/sbin/mount", "-t", "auto", "/data");
run_program("/sbin/mount", "-t", "auto", "/cache");
ui_print("Partitions mounted");
ui_print(" ");

ui_print("Removing bloatware from /system/app");
run_program("/sbin/rm", "-rf", "system/app/AASAservice");
run_program("/sbin/rm", "-rf", "system/app/BluetoothMidiService");
run_program("/sbin/rm", "-rf", "system/app/CloudGateway2017");
run_program("/sbin/rm", "-rf", "system/app/GooglePrintRecommendationService");
run_program("/sbin/rm", "-rf", "system/app/FlipboardBriefing");
run_program("/sbin/rm", "-rf", "system/app/KnoxFolderContainer2");
run_program("/sbin/rm", "-rf", "system/app/KnoxRemoteContentsProvider");
run_program("/sbin/rm", "-rf", "system/app/Photos");
run_program("/sbin/rm", "-rf", "system/app/SBrowser_5.0");
run_program("/sbin/rm", "-rf", "system/app/ShareLink");
run_program("/sbin/rm", "-rf", "system/app/SPrintSpooler7");
run_program("/sbin/rm", "-rf", "system/app/Videos");
run_program("/sbin/rm", "-rf", "system/app/ANTPlusPlugins");
run_program("/sbin/rm", "-rf", "system/app/ANTPlusTest");
run_program("/sbin/rm", "-rf", "system/app/ANTRadioService");
run_program("/sbin/rm", "-rf", "system/app/AdvSoundDetector2015");
run_program("/sbin/rm", "-rf", "system/app/AllShareCastPlayer");
run_program("/sbin/rm", "-rf", "system/app/AllshareFileShare");
#run_program("/sbin/rm", "-rf", "system/app/EasyOneHand3");
run_program("/sbin/rm", "-rf", "system/app/FlipboardBriefingPanel");
run_program("/sbin/rm", "-rf", "system/app/Music2");
run_program("/sbin/rm", "-rf", "system/app/QuickConnect_40");
run_program("/sbin/rm", "-rf", "system/app/BBCAgent");
run_program("/sbin/rm", "-rf", "system/app/SBrowser_4_LATEST");
run_program("/sbin/rm", "-rf", "system/app/ColorBlind_M");
run_program("/sbin/rm", "-rf", "system/app/SecMemo3");
run_program("/sbin/rm", "-rf", "system/app/SimpleSharing");
ui_print("Done!");
ui_print(" ");

ui_print("Removing bloatware from /system/priv-app");
run_program("/sbin/rm", "-rf", "system/priv-app/AutoPreconfig");
run_program("/sbin/rm", "-rf", "system/priv-app/AccessControl_N");
run_program("/sbin/rm", "-rf", "system/priv-app/AutomationTest_FB");
run_program("/sbin/rm", "-rf", "system/priv-app/CallLogBackup");
run_program("/sbin/rm", "-rf", "system/priv-app/AssistantMenu_N");
run_program("/sbin/rm", "-rf", "system/priv-app/AxelSpringer");
run_program("/sbin/rm", "-rf", "system/priv-app/BeaconManager");
run_program("/sbin/rm", "-rf", "system/priv-app/ColorBlind_N");
run_program("/sbin/rm", "-rf", "system/priv-app/EasySetup");
#run_program("/sbin/rm", "-rf", "system/priv-app/GalaxyApps_3xh");
run_program("/sbin/rm", "-rf", "system/priv-app/GalaxyAppsWidget_Phone");
run_program("/sbin/rm", "-rf", "system/priv-app/GameHome");
run_program("/sbin/rm", "-rf", "system/priv-app/GameTools");
run_program("/sbin/rm", "-rf", "system/priv-app/OneDrive_Samsung_v2");
run_program("/sbin/rm", "-rf", "system/priv-app/PreloadInstaller");
#run_program("/sbin/rm", "-rf", "system/priv-app/SamsungAccount_Dream");
run_program("/sbin/rm", "-rf", "system/priv-app/SamsungCloud");
run_program("/sbin/rm", "-rf", "system/priv-app/SamsungMagnifier3");
run_program("/sbin/rm", "-rf", "system/priv-app/SamsungPass_1.1");
run_program("/sbin/rm", "-rf", "system/priv-app/SecEmail_N");
run_program("/sbin/rm", "-rf", "system/priv-app/SecureFolderStub");
run_program("/sbin/rm", "-rf", "system/priv-app/SFinder_v6");
run_program("/sbin/rm", "-rf", "system/priv-app/SNS_v2_N");
run_program("/sbin/rm", "-rf", "system/priv-app/SVoice");
run_program("/sbin/rm", "-rf", "system/priv-app/SvoicePLM");
run_program("/sbin/rm", "-rf", "system/priv-app/VoiceNote_5.0");
run_program("/sbin/rm", "-rf", "system/priv-app/VoiceNote_4.0");
run_program("/sbin/rm", "-rf", "system/priv-app/Fmm");
run_program("/sbin/rm", "-rf", "system/priv-app/FotaAgent");
run_program("/sbin/rm", "-rf", "system/priv-app/GalaxyBeta");
run_program("/sbin/rm", "-rf", "system/priv-app/GearManager");
run_program("/sbin/rm", "-rf", "system/priv-app/GoogleFeedback");
run_program("/sbin/rm", "-rf", "system/priv-app/HwModuleTest");
run_program("/sbin/rm", "-rf", "system/priv-app/ImsLogger+");
run_program("/sbin/rm", "-rf", "system/priv-app/KLMSAgent");
run_program("/sbin/rm", "-rf", "system/priv-app/LiveBroadcast");
run_program("/sbin/rm", "-rf", "system/priv-app/MyPlaces_Hero");
run_program("/sbin/rm", "-rf", "system/priv-app/PhoneErrService");
run_program("/sbin/rm", "-rf", "system/priv-app/PowerPoint_SamsungStub");
run_program("/sbin/rm", "-rf", "system/priv-app/RNB");
run_program("/sbin/rm", "-rf", "system/priv-app/RNBShell");
run_program("/sbin/rm", "-rf", "system/priv-app/sCloudBackupAppMOSUpgrade");
run_program("/sbin/rm", "-rf", "system/priv-app/SCloudService");
run_program("/sbin/rm", "-rf", "system/priv-app/SKSMAgent");
run_program("/sbin/rm", "-rf", "system/priv-app/SNS_v2");
run_program("/sbin/rm", "-rf", "system/priv-app/SOAgent");
run_program("/sbin/rm", "-rf", "system/priv-app/SPDClient");
run_program("/sbin/rm", "-rf", "system/priv-app/SPPPushClient_Prod");
run_program("/sbin/rm", "-rf", "system/priv-app/SVoiceLang_EnglishPack_GB_1.0");
run_program("/sbin/rm", "-rf", "system/priv-app/SVoiceLang_EnglishPack_US_1.0");
run_program("/sbin/rm", "-rf", "system/priv-app/SVoiceLang_FrenchPack_1.0");
ui_print("Done!");
ui_print(" ");

ui_print("Cleaning Cache and Dalvik-cache");
delete_recursive("/cache");
delete_recursive("/data/dalvik-cache");

ui_print("Unmounting partitions: /system /data /cache");
unmount("/data");
unmount("/cache");
unmount("/system");
ui_print(" ");

ui_print("Enjoy smoothness and much better battery life! :)");
ui_print(" ");
ui_print(" ");

ui_print("You can easily edit script and add character ' # ' to exclude certain APP from deleting.");
ui_print(" ");

ui_print("############################################");

Here are the things that i don't understand:

  1. sbin/rm
  2. sbin/mount
  3. t
  4. auto

I've checked the sbin directory on my phone but there was no rm or mount files.. So please anyone explain to me in detail 'cause i'm a newbie in Bash Scripting.

the things you don't understand can be divide into two command group,

  1. rm group
    /sbin/rm -fr delete directory and files silently
  2. mount group
    /sbin/mount -t auto mount partitions under auto configured parameters, mostly related with mtab and fstab

you can do more research on quoted terminology above

if you cant see the rm and mount file under /sbin , there are two explanation i can think of

  1. only app with effective root privilege can do that, and you are viewing in an app that does not holding root privilege when scanning /sbin .
    rooting device is by placing a special binary file su under special dir.
    app has to call exec("su") explicitly to start a process with root privilege
    so that it can delete system files, mount or umount partitions, etc.
  2. you are viewing in a chroot environment, the real /sbin is outside the environment.
    which is less likely to happen on your phone,
    it is a way of relocating / directory for process(and its sub-process).

Allright I've figured this out.

The scripting language used is called Edify . While similar to bash, the format is different, but both call Linux programs to perform tasks. You can read the manual (man) page for rm and mount if you want to. And for anyone who is looking for rm and mount files inside sbin , stop looking for it you won't find it, even as a root user


Typically, these days, in TWRP. The recovery will mount a busybox implementation which provides access to basic Linux like programs mounted in the sbin directory. You must reboot to recovery to have access to these.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM