replicant-vendor_replicant/prebuilt/common/etc/init.d/50selinuxrelabel
Chirayu Desai c7e9230614 selinuxrelabel: Add a check for dalvik-cache
Change-Id: Ic8087450756ae81458e155aa1ca22d5055547664
2013-12-07 20:55:29 +05:30

70 lines
1.5 KiB
Bash

#!/system/bin/sh
L="log -p i -t SELinuxLabel"
# Bail out early if not on a SELinux build
getprop ro.build.selinux | grep -q 1 || exit
if [ ! -f /file_contexts ]; then
exit
fi
LABELDATA=0
LABELSYS=0
LABELDALVIKCACHE=0
# Test /data
ls -Zd /data/system | grep -q unlabeled
if [ $? -eq 0 ]; then
$L "userdata is unlabeled, fixing..."
LABELDATA=1
fi
ls -Z /system/bin/surfaceflinger | grep -q unlabeled
if [ $? -eq 0 ]; then
$L "system is unlabeled, fixing... (You really should update your recovery)"
LABELSYS=1
fi
ls -Z /system/priv-app/GoogleServicesFramework.apk | grep -q unlabeled
if [ $LABELSYS = "0" -a $? -eq 0 ]; then
$L "Found unlabeled Google framework, fixing..."
LABELSYS=1
fi
ls -Zd /data/dalvik-cache | grep -q unlabeled
if [ $? -eq 0 ]; then
$L "dalvik-cache is unlabeled, fixing..."
LABELDALVIKCACHE=1
fi
ls -Zd /cache/dalvik-cache | grep -q unlabeled
if [ $? -eq 0 ]; then
$L "dalvik-cache is unlabeled, fixing..."
LABELDALVIKCACHE=1
fi
if [ $LABELSYS = "1" ]; then
busybox mount -o remount,rw /system
$L "/system relabel starting..."
restorecon -R /system
$L "/system relabel complete"
busybox mount -o remount,ro /system
fi
if [ $LABELDATA = "1" ]; then
$L "/data relabel starting..."
restorecon -R /data
$L "/data relabel complete"
$L "/cache relabel starting..."
restorecon -R /cache
$L "/cache relabel complete"
fi
if [ $LABELDALVIKCACHE = "1" ]; then
$L "dalvik-cache relabel starting..."
restorecon -R /data/dalvik-cache
restorecon -R /cache/dalvik-cache
$L "dalvik-cache relabel complete"
fi