From ce378fa20b9f0ea1c04283894154b8ac95ace0f8 Mon Sep 17 00:00:00 2001 From: powerAn <25736019+powerAn2020@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:29:55 +0800 Subject: [PATCH] init --- META-INF/com/google/android/update-binary | 33 +++++++++++++++++++ META-INF/com/google/android/updater-script | 1 + README.md | 20 ++++++++++++ customize.sh | 38 ++++++++++++++++++++++ module.prop | 6 ++++ service.sh | 15 +++++++++ uninstall.sh | 5 +++ 7 files changed, 118 insertions(+) create mode 100644 META-INF/com/google/android/update-binary create mode 100644 META-INF/com/google/android/updater-script create mode 100644 README.md create mode 100644 customize.sh create mode 100644 module.prop create mode 100644 service.sh create mode 100644 uninstall.sh diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..631d35d --- /dev/null +++ b/META-INF/com/google/android/update-binary @@ -0,0 +1,33 @@ +#!/sbin/sh + +################# +# Initialization +################# + +umask 022 + +# echo before loading util_functions +ui_print() { echo "$1"; } + +require_new_magisk() { + ui_print "*******************************" + ui_print " Please install Magisk v20.4+! " + ui_print "*******************************" + exit 1 +} + +######################### +# Load util_functions.sh +######################### + +OUTFD=$2 +ZIPFILE=$3 + +mount /data 2>/dev/null + +[ -f /data/adb/magisk/util_functions.sh ] && { + . /data/adb/magisk/util_functions.sh + [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk + install_module + exit 0 +} diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..11d5c96 --- /dev/null +++ b/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +#MAGISK diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f49d70 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# crond4Android + +支持 KernelSU、APatch、Magisk下运行。调用对应框架busybox实现crond定时。 + +## 数据目录 + +日志: `/data/adb/crond/run.log` + +任务数据: `/data/adb/crond/` + +crontab: `/system/xbin/crontab` +`注意:如果替换了root实现方案,记得修改这个脚本,或者重新安装一次,不然无法执行。` +## 使用样例 + +```shell +# 创建任务 (也可以直接编辑文件) +echo '53 * * * * command' >> /data/adb/crond/root # for root user +# 查看任务 +crontab -c /data/adb/crond -l +``` diff --git a/customize.sh b/customize.sh new file mode 100644 index 0000000..f1d138e --- /dev/null +++ b/customize.sh @@ -0,0 +1,38 @@ + +if [ "$BOOTMODE" != true ]; then + ui_print "-----------------------------------------------------------" + ui_print "! Please install in Magisk Manager or KernelSU Manager or APatch Manager" + ui_print "! Install from recovery is NOT supported" + abort "-----------------------------------------------------------" +fi + +cronDataDir='/data/adb/crond' +crontabCmd="${MODPATH}/system/xbin/crontab" + +if [ ! -d ${cronDataDir} ];then + ui_print "mkdir ${cronDataDir}" + mkdir -p ${cronDataDir} + touch ${cronDataDir}/root +fi + +ui_print "- Installed crontab cmd to ${crontabCmd}" +echo '#!/system/bin/sh' >${crontabCmd} + +if [ "$KSU" = true ]; then + ui_print "- kernelSU version: $KSU_VER ($KSU_VER_CODE)" + echo '/data/adb/ksu/bin/busybox crontab -c '${cronDataDir}' $@' >> ${crontabCmd} +elif [ "$APATCH" = true ]; then + ui_print "- APatch version: $APATCH_VER ($APATCH_VER_CODE)" + echo '/data/adb/ap/bin/busybox crontab -c '${cronDataDir}' $@' >> ${crontabCmd} +else + ui_print "- Magisk version: $MAGISK_VER ($MAGISK_VER_CODE)" + echo '/data/adb/magisk/bin/busybox crontab -c '${cronDataDir}' $@' >> ${crontabCmd} +fi + +ui_print "set_perm" + +set_perm ${crontabCmd} 0 0 0755 +set_perm $MODPATH/service.sh 0 0 0755 +set_perm $MODPATH/uninstall.sh 0 0 0755 + +ui_print "done" diff --git a/module.prop b/module.prop new file mode 100644 index 0000000..c69dd10 --- /dev/null +++ b/module.prop @@ -0,0 +1,6 @@ +id=crond4android +name=Crond for Android +version=1.0.0 +versionCode=100 +author=powerAn2020 +description=Busybox Crond with service scripts for Android \ No newline at end of file diff --git a/service.sh b/service.sh new file mode 100644 index 0000000..4af0d7d --- /dev/null +++ b/service.sh @@ -0,0 +1,15 @@ +#!/system/bin/sh + +cronDataDir='/data/adb/crond' +args="crond -b -c ${cronDataDir} -L ${cronDataDir}/run.log" +# check version +if [ "$KSU" = true ]; then + echo "- kernelSU version: $KSU_VER ($KSU_VER_CODE)" + /data/adb/ksu/bin/busybox $args +elif [ "$APATCH" = true ]; then + echo "- APatch version: $APATCH_VER ($APATCH_VER_CODE)" + /data/adb/ap/bin/busybox $args +else + echo "- Magisk version: $MAGISK_VER ($MAGISK_VER_CODE)" + /data/adb/magisk/busybox $args +fi \ No newline at end of file diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..705ee3e --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,5 @@ +#!/system/bin/sh + +if [ ! -f "/data/adb/crond/KEEP_ON_UNINSTALL" ]; then + rm -rf /data/adb/crond +fi