From a63159fc0e255727d22d7f05fd16338064c2bf48 Mon Sep 17 00:00:00 2001 From: Vladimir Filatov Date: Wed, 8 May 2019 17:09:16 +0000 Subject: [PATCH] init.d scripts improvements --- Full/system/etc/init.d/10_sqlite | 37 +++++++++++++++++++ Full/system/etc/init.d/20_fstrim | 23 ++++++++++++ Full/system/etc/init.d/{logcat => 30_logcat} | 4 +- .../init.d/{external_sd => 40_external_sd} | 4 +- .../init.d/{logscleaner => 50_logscleaner} | 4 +- Full/system/etc/init.d/fstrim | 17 --------- Full/system/etc/init.d/sqlite | 31 ---------------- 7 files changed, 66 insertions(+), 54 deletions(-) create mode 100755 Full/system/etc/init.d/10_sqlite create mode 100755 Full/system/etc/init.d/20_fstrim rename Full/system/etc/init.d/{logcat => 30_logcat} (83%) rename Full/system/etc/init.d/{external_sd => 40_external_sd} (89%) rename Full/system/etc/init.d/{logscleaner => 50_logscleaner} (91%) delete mode 100755 Full/system/etc/init.d/fstrim delete mode 100755 Full/system/etc/init.d/sqlite diff --git a/Full/system/etc/init.d/10_sqlite b/Full/system/etc/init.d/10_sqlite new file mode 100755 index 0000000..1539a1a --- /dev/null +++ b/Full/system/etc/init.d/10_sqlite @@ -0,0 +1,37 @@ +#!/system/bin/sh + +# be sure init.rc post-fs-data completed +until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done + +# run script only when battery charged enough +capacity=$(cat /sys/class/power_supply/battery/capacity) +if [ "$capacity" -gt "15" ]; then + + echo "sqlite init script" + + if which sqlite3 >/dev/null; then + echo "SQLite database VACUUM and REINDEX started at $(date +%Y%m%d-%H.%M.%S)" + for i in `find /data/* -iname "*.db"`; do + sqlite3 $i 'VACUUM;' + resVac=$? + if [ $resVac == 0 ]; then + resVac="SUCCESS" + else + resVac="ERRCODE-$resVac" + fi; + + sqlite3 $i 'REINDEX;' + resIndex=$? + if [ $resIndex == 0 ]; then + resIndex="SUCCESS" + else + resIndex="ERRCODE-$resIndex" + fi + echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" + done + + echo "SQLite database VACUUM and REINDEX finished at $(date +%Y%m%d-%H.%M.%S)" + else + echo "sqlite3 not installed, stop" + fi +fi diff --git a/Full/system/etc/init.d/20_fstrim b/Full/system/etc/init.d/20_fstrim new file mode 100755 index 0000000..e8b08b4 --- /dev/null +++ b/Full/system/etc/init.d/20_fstrim @@ -0,0 +1,23 @@ +#!/system/bin/sh + +# be sure init.rc post-fs-data completed +until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done + +# run script only when battery charged enough +capacity=$(cat /sys/class/power_supply/battery/capacity) +if [ "$capacity" -gt "15" ]; then + + echo "fstrim init script" + + if [ -e /init.fstrim.sh ]; then + echo "/init.fstrim.sh exists, trimming /preload only" + fstrim -v /preload + else + echo "/init.fstrim.sh does not exist, trimming /cache, /system, /vendor, /data, /preload" + fstrim -v /cache + fstrim -v /system + fstrim -v /vendor + fstrim -v /data + fstrim -v /preload + fi +fi \ No newline at end of file diff --git a/Full/system/etc/init.d/logcat b/Full/system/etc/init.d/30_logcat similarity index 83% rename from Full/system/etc/init.d/logcat rename to Full/system/etc/init.d/30_logcat index 8eff502..767a929 100755 --- a/Full/system/etc/init.d/logcat +++ b/Full/system/etc/init.d/30_logcat @@ -1,7 +1,7 @@ #!/system/bin/sh -# wait until boot completed -until [ `getprop sys.boot_completed`. = 1. ]; do sleep 1; done +# be sure init.rc post-fs-data completed +until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done LOGDIR="/data/adb/logcats" diff --git a/Full/system/etc/init.d/external_sd b/Full/system/etc/init.d/40_external_sd similarity index 89% rename from Full/system/etc/init.d/external_sd rename to Full/system/etc/init.d/40_external_sd index 509b8db..41add20 100755 --- a/Full/system/etc/init.d/external_sd +++ b/Full/system/etc/init.d/40_external_sd @@ -2,8 +2,8 @@ echo "external_sd init script" -# wait until boot completed -until [ `getprop sys.boot_completed`. = 1. ]; do sleep 1; done +# be sure init.rc post-fs-data completed +until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done if getprop ro.build.characteristics | grep -q nosdcard; then echo ">> no SD Card Slot" diff --git a/Full/system/etc/init.d/logscleaner b/Full/system/etc/init.d/50_logscleaner similarity index 91% rename from Full/system/etc/init.d/logscleaner rename to Full/system/etc/init.d/50_logscleaner index 487afe7..fc7a8b6 100755 --- a/Full/system/etc/init.d/logscleaner +++ b/Full/system/etc/init.d/50_logscleaner @@ -1,7 +1,7 @@ #!/system/bin/sh -# wait until boot completed -until [ `getprop sys.boot_completed`. = 1. ]; do sleep 1; done +# be sure init.rc post-fs-data completed +until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done echo "logscleaner init script" echo "Starting Automatic Cleaning at $(date +%Y%m%d-%H.%M.%S)" diff --git a/Full/system/etc/init.d/fstrim b/Full/system/etc/init.d/fstrim deleted file mode 100755 index 120def5..0000000 --- a/Full/system/etc/init.d/fstrim +++ /dev/null @@ -1,17 +0,0 @@ -#!/system/bin/sh - -# wait until boot completed -until [ `getprop sys.boot_completed`. = 1. ]; do sleep 1; done - -echo "fstrim init script" - -if [ -e /init.fstrim.sh ]; then - echo "/init.fstrim.sh exists, trimming /preload only" - fstrim -v /preload -else - echo "/init.fstrim.sh does not exist, trimming /cache, /system, /data, /preload" - fstrim -v /cache - fstrim -v /system - fstrim -v /data - fstrim -v /preload -fi diff --git a/Full/system/etc/init.d/sqlite b/Full/system/etc/init.d/sqlite deleted file mode 100755 index 86e8116..0000000 --- a/Full/system/etc/init.d/sqlite +++ /dev/null @@ -1,31 +0,0 @@ -#!/system/bin/sh - -# wait until boot completed -until [ `getprop sys.boot_completed`. = 1. ]; do sleep 1; done - -echo "sqlite init script" - -if which sqlite3 >/dev/null; then - echo "SQLite database VACUUM and REINDEX started at $(date +%Y%m%d-%H.%M.%S)" - for i in `find /data/* -iname "*.db"`; do - sqlite3 $i 'VACUUM;' - resVac=$? - if [ $resVac == 0 ]; then - resVac="SUCCESS" - else - resVac="ERRCODE-$resVac" - fi; - - sqlite3 $i 'REINDEX;' - resIndex=$? - if [ $resIndex == 0 ]; then - resIndex="SUCCESS" - else - resIndex="ERRCODE-$resIndex" - fi - echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" - done - - echo "SQLite database VACUUM and REINDEX finished at $(date +%Y%m%d-%H.%M.%S)" -else echo "sqlite3 not installed, stop" -fi