Magisk/src/main/res/raw/magiskdb.sh

33 lines
738 B
Bash
Raw Normal View History

2018-04-05 17:54:09 +00:00
db_clean() {
2018-02-18 04:41:58 +00:00
local USERID=$1
local DIR="/sbin/.core/db-${USERID}"
umount -l /data/user*/*/*/databases/su.db $DIR $DIR/*
rm -rf $DIR
2018-02-18 10:12:12 +00:00
[ "$USERID" = "*" ] && rm -f /data/adb/magisk.db
}
2018-04-05 17:54:09 +00:00
db_init() {
2018-02-18 10:12:12 +00:00
ADB_CONTEXT=`/system/bin/ls -dZ /data/adb | awk '{print $1}'`
chcon u:object_r:su_file:s0 /data/adb
chmod 777 /data/adb
}
2018-04-05 17:54:09 +00:00
db_restore() {
2018-02-18 10:12:12 +00:00
chcon $ADB_CONTEXT /data/adb
chmod 700 /data/adb
2018-02-18 04:41:58 +00:00
}
2018-04-05 17:54:09 +00:00
db_setup() {
2018-02-18 04:41:58 +00:00
local USER=$1
local USERID=$(($USER / 100000))
local DIR=/sbin/.core/db-${USERID}
mkdir -p $DIR
touch $DIR/magisk.db
2018-02-18 10:12:12 +00:00
mount -o bind /data/adb/magisk.db $DIR/magisk.db
rm -f /data/adb/magisk.db-journal
2018-02-18 04:41:58 +00:00
chcon u:object_r:su_file:s0 $DIR $DIR/*
chmod 700 $DIR
chown $USER.$USER $DIR
chmod 666 $DIR/*
}