mirror of
https://github.com/adron-s/mtik_initrd_hacks.git
synced 2025-12-10 07:44:40 +01:00
Implemented a work_dir autodetection(fixed broken IPQ-40XX support)
This commit is contained in:
parent
1f9564198c
commit
5cfbf786f7
6 changed files with 28 additions and 14 deletions
|
|
@ -7,7 +7,8 @@ The author has not liable for any of you actions and their consequences!
|
||||||
This code is presented as is and is solely for educational purposes ONLY!
|
This code is presented as is and is solely for educational purposes ONLY!
|
||||||
|
|
||||||
0) Use RouterOS 6.44 or 7.0b1!
|
0) Use RouterOS 6.44 or 7.0b1!
|
||||||
1) Upload(using FTP) content of ./for_ftp_upload/* to /pub folder on target RouterOS device
|
1) Upload(using FTP) content of ./for_ftp_upload/pub/* to /pub
|
||||||
|
(or /flash/rw/disk/pub) folder on target RouterOS device
|
||||||
2) Netboot with kernel-new.elf
|
2) Netboot with kernel-new.elf
|
||||||
3) telnet x.x.x.x 22111
|
3) telnet x.x.x.x 22111
|
||||||
|
|
||||||
|
|
@ -27,6 +28,6 @@ For Developers:
|
||||||
cd ..
|
cd ..
|
||||||
Make the necessary changes to the ./cpio-fs(compile add add busybox, etc...)
|
Make the necessary changes to the ./cpio-fs(compile add add busybox, etc...)
|
||||||
In the end, when everything is ready, to get ./bins/kernel-new.elf, run: ./pack-kernel.sh
|
In the end, when everything is ready, to get ./bins/kernel-new.elf, run: ./pack-kernel.sh
|
||||||
Upload content of ./for_ftp_upload/* to target RouterOS device via FTP(to /pub)
|
Upload content of ./for_ftp_upload/pub/* to target RouterOS device via FTP(to /pub or /flash/rw/disk/pub)
|
||||||
Put ./bins/kernel-new.elf to your tftp and Netboot from it
|
Put ./bins/kernel-new.elf to your tftp and Netboot from it
|
||||||
telnet x.x.x.x 22111
|
telnet x.x.x.x 22111
|
||||||
|
|
|
||||||
BIN
cpio-fs/init
BIN
cpio-fs/init
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
||||||
ROOT=/flash/rw/disk/pub/OWL
|
ROOT=${1}/OWL
|
||||||
cd $ROOT
|
cd $ROOT
|
||||||
[ -f $ROOT/bin/busybox -a ! -f $ROOT/bin/sh ] && {
|
[ -f $ROOT/bin/busybox -a ! -f $ROOT/bin/sh ] && {
|
||||||
echo "Initializing busybox"
|
echo "Initializing busybox"
|
||||||
35
init/init.c
35
init/init.c
|
|
@ -21,24 +21,37 @@ void my_system(char *cmd, char *arg1, char *arg2, char *arg3){
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WORK_DIR "/flash/rw/disk/pub"
|
static char work_dir1[ ] = "/flash/rw/disk/pub";
|
||||||
#define BIN_BUSYBOX WORK_DIR "/OWL/bin/busybox"
|
static char work_dir2[ ] = "/flash/rw/disk/flash/rw/disk/pub";
|
||||||
#define OWL_SH WORK_DIR "/OWL.sh"
|
static char *work_dir = work_dir1;
|
||||||
void daemonized_OWL(void){
|
void daemonized_OWL(void){
|
||||||
//int a = 0;
|
int a = 0;
|
||||||
|
static char bin_busybox[128];
|
||||||
|
static char owl_sh[128];
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
while(1){
|
while(1){
|
||||||
/* if(a++ % 10 == 0){
|
/* if(a++ % 10 == 0){
|
||||||
printf("OWL is here! %d\n", a);
|
printf("OWL is here! %d\n", a);
|
||||||
} */
|
}*/
|
||||||
if(stat(BIN_BUSYBOX, &sb) == 0 && !(sb.st_mode & S_IXUSR)){
|
do{ //autodetect work_dir
|
||||||
printf("Making %s executable\n", BIN_BUSYBOX);
|
if(work_dir == work_dir1)
|
||||||
my_system("/bin/busybox", "chmod", "777", BIN_BUSYBOX);
|
work_dir = work_dir2;
|
||||||
|
else
|
||||||
|
work_dir = work_dir1;
|
||||||
|
printf("%d: Trying work_dir: '%s'\n", a++, work_dir);
|
||||||
|
sleep(5);
|
||||||
|
}while(stat(work_dir, &sb) != 0);
|
||||||
|
printf("work_dir found at: '%s'\n", work_dir);
|
||||||
|
snprintf(bin_busybox, sizeof(bin_busybox), "%s/OWL/bin/busybox", work_dir);
|
||||||
|
snprintf(owl_sh, sizeof(owl_sh), "%s/OWL.sh", work_dir);
|
||||||
|
if(stat(bin_busybox, &sb) == 0 && !(sb.st_mode & S_IXUSR)){
|
||||||
|
printf("Making %s executable\n", bin_busybox);
|
||||||
|
my_system("/bin/busybox", "chmod", "777", bin_busybox);
|
||||||
}
|
}
|
||||||
if(stat(OWL_SH, &sb) == 0)
|
if(stat(owl_sh, &sb) == 0)
|
||||||
my_system("/bin/busybox", "sh", OWL_SH, NULL);
|
my_system("/bin/busybox", "sh", owl_sh, work_dir);
|
||||||
//my_system("/bin/busybox", "rm", "-Rf", "/flash/rw/disk/pub/OWL");
|
//my_system("/bin/busybox", "rm", "-Rf", "/flash/rw/disk/pub/OWL");
|
||||||
//my_system("/bin/busybox", "ls", "-l", "/");
|
//my_system("/bin/busybox", "ls", "-l", "/flash/rw/disk/flash/rw/disk");
|
||||||
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh");
|
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh");
|
||||||
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub");
|
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub");
|
||||||
//my_system("/bin/busybox", "--help", NULL);
|
//my_system("/bin/busybox", "--help", NULL);
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue