diff options
author | stay steadfast <steadfasterX@users.noreply.github.com> | 2017-03-30 14:45:37 +0200 |
---|---|---|
committer | nailyk-fr <nailyk_git@nailyk.fr> | 2017-04-04 11:54:25 +0000 |
commit | 095fa56bfc35ad63ea06c086f58f7c3ff0a8eb6d (patch) | |
tree | c540a67dbf9045b3269f81b0e2e0f8bcf0939bf9 /rootdir/system | |
parent | b576ed0111f18dd3a9c5a5ee3123320f97b33ba9 (diff) |
shinano-common: init: Stability improvements to credmgr init
* Device wasn't encryptable because of bad return code.
Initial commit message:
> some enhancements you may like ;)
>
> make if loop more bullet proof
> now every command gives an error result back and according to it the script fails or not immediately
> logging to dmesg device to be sure that we can write log messages (just do a "dmesg|grep CREDINIT" to get your log output)
> overall be more verbose
Change-Id: Ife5288522a20a9f962a01630d7a6c52d85ad6db8
Diffstat (limited to 'rootdir/system')
-rwxr-xr-x | rootdir/system/bin/credmgrfirstboot.sh | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/rootdir/system/bin/credmgrfirstboot.sh b/rootdir/system/bin/credmgrfirstboot.sh index 9d9c837..4c21a83 100755 --- a/rootdir/system/bin/credmgrfirstboot.sh +++ b/rootdir/system/bin/credmgrfirstboot.sh @@ -1,9 +1,22 @@ #!/system/bin/sh CREDFOLDER=/data/credmgr +# simple error function +F_ERR(){ + ERR="$1" + MSG="$2" + if [ $ERR -ne 0 ];then + system/bin/toybox echo "CREDINIT: $MSG failed!" >> /dev/kmsg + exit $ERR + else + system/bin/toybox echo "CREDINIT: $MSG finished successfully" >> /dev/kmsg + fi +} + # If credmgrd data doesn't match our +CREDMGRCNT=$(find $CREDFOLDER -group credmgr_client -type f -name "credmgr.db" | wc -l ) -if [ $(find $CREDFOLDER -group credmgr_client -type f -name "credmgr.db" | wc -l ) -eq 0 ]; then +if [ "$CREDMGRCNT" == "0" ]; then # If /data/credmgr exist remove it /system/bin/logwrapper /system/bin/toybox echo "CREDINIT: Dont match" if [ -d "$CREDFOLDER" ]; then @@ -12,16 +25,18 @@ if [ $(find $CREDFOLDER -group credmgr_client -type f -name "credmgr.db" | wc -l fi # Put binary into /cache /system/bin/logwrapper mkdir $CREDFOLDER + F_ERR $? "mkdir $CREDFOLDER" /system/bin/logwrapper chown system:credmgr_client $CREDFOLDER + F_ERR $? "chown $CREDFOLDER" /system/bin/logwrapper chcon u:object_r:credmgrd_data_file:s0 $CREDFOLDER + F_ERR $? "chcon $CREDFOLDER" /system/bin/logwrapper /system/bin/toybox echo "CREDINIT: cp initial file" /system/bin/logwrapper cp -v /system/vendor/CredentialManagerData /cache/CredentialManagerData -fi - -if [ $? -eq 0 ]; then - # Tell init we are ready - /system/bin/setprop sys.credmgrdready true + F_ERR $? "copy CredentialManagerData" else - /system/bin/toybox echo "CREDINIT: Something goes wrong at credmgrd init!" + F_ERR 0 "credmgr found already. no preparation required." fi +# Tell init we are ready +/system/bin/setprop sys.credmgrdready true +F_ERR $? "setting property" |