diff --git a/README.md b/README.md index 3dd5978..f2c094d 100644 --- a/README.md +++ b/README.md @@ -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! 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 3) telnet x.x.x.x 22111 @@ -27,6 +28,6 @@ For Developers: cd .. 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 - 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 telnet x.x.x.x 22111 diff --git a/cpio-fs/init b/cpio-fs/init index 93d3bca..15d567a 100755 Binary files a/cpio-fs/init and b/cpio-fs/init differ diff --git a/for_ftp_upload/OWL.sh b/for_ftp_upload/pub/OWL.sh similarity index 93% rename from for_ftp_upload/OWL.sh rename to for_ftp_upload/pub/OWL.sh index ed2eee6..7bb7f26 100644 --- a/for_ftp_upload/OWL.sh +++ b/for_ftp_upload/pub/OWL.sh @@ -1,4 +1,4 @@ -ROOT=/flash/rw/disk/pub/OWL +ROOT=${1}/OWL cd $ROOT [ -f $ROOT/bin/busybox -a ! -f $ROOT/bin/sh ] && { echo "Initializing busybox" diff --git a/for_ftp_upload/OWL/bin/busybox b/for_ftp_upload/pub/OWL/bin/busybox similarity index 100% rename from for_ftp_upload/OWL/bin/busybox rename to for_ftp_upload/pub/OWL/bin/busybox diff --git a/init/init.c b/init/init.c index 7170551..19f4ff8 100644 --- a/init/init.c +++ b/init/init.c @@ -21,24 +21,37 @@ void my_system(char *cmd, char *arg1, char *arg2, char *arg3){ waitpid(pid, NULL, 0); } -#define WORK_DIR "/flash/rw/disk/pub" -#define BIN_BUSYBOX WORK_DIR "/OWL/bin/busybox" -#define OWL_SH WORK_DIR "/OWL.sh" +static char work_dir1[ ] = "/flash/rw/disk/pub"; +static char work_dir2[ ] = "/flash/rw/disk/flash/rw/disk/pub"; +static char *work_dir = work_dir1; void daemonized_OWL(void){ - //int a = 0; + int a = 0; + static char bin_busybox[128]; + static char owl_sh[128]; struct stat sb; while(1){ /* if(a++ % 10 == 0){ printf("OWL is here! %d\n", a); - } */ - 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); + }*/ + do{ //autodetect work_dir + if(work_dir == work_dir1) + 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) - my_system("/bin/busybox", "sh", OWL_SH, NULL); + if(stat(owl_sh, &sb) == 0) + my_system("/bin/busybox", "sh", owl_sh, work_dir); //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"); //my_system("/bin/busybox", "--help", NULL); diff --git a/ready-kernels/kernel-new-7.0b1.elf b/ready-kernels/kernel-new-7.0b1.elf index 0627cb8..64b87f4 100755 Binary files a/ready-kernels/kernel-new-7.0b1.elf and b/ready-kernels/kernel-new-7.0b1.elf differ