init.d scripts improvements

merge-requests/23/head
Vladimir Filatov 5 years ago committed by Christopher Roy Bratusek
parent 46fcd73a84
commit a63159fc0e

@ -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

@ -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

@ -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"

@ -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"

@ -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)"

@ -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

@ -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
Loading…
Cancel
Save