[Q] Chromecast command line primer - Google Chromecast

Apologies if this has already been covered but a quick search turned up nothing. I recently rooted and was wondering if there was any resource to describe the ins and outs of the chromecast shell. Specifically I wanted to know if there is a way to define a custom start up script. For the moment I would just like to auto update the PATH env variable to include my own bin directory on /data with some of the more useful busybox commands symlinked and maybe add some cooler stuff later. I've done something similar in dd-wrt with a special nvram variable to point to a script, but I don't know if there is an equivalent here. Thanks.

bobcat987 said:
Apologies if this has already been covered but a quick search turned up nothing. I recently rooted and was wondering if there was any resource to describe the ins and outs of the chromecast shell. Specifically I wanted to know if there is a way to define a custom start up script. For the moment I would just like to auto update the PATH env variable to include my own bin directory on /data with some of the more useful busybox commands symlinked and maybe add some cooler stuff later. I've done something similar in dd-wrt with a special nvram variable to point to a script, but I don't know if there is an equivalent here. Thanks.
Click to expand...
Click to collapse
I think we need to edit /init.rc
but it's write protected =/

bobcat987 said:
Apologies if this has already been covered but a quick search turned up nothing. I recently rooted and was wondering if there was any resource to describe the ins and outs of the chromecast shell. Specifically I wanted to know if there is a way to define a custom start up script. For the moment I would just like to auto update the PATH env variable to include my own bin directory on /data with some of the more useful busybox commands symlinked and maybe add some cooler stuff later. I've done something similar in dd-wrt with a special nvram variable to point to a script, but I don't know if there is an equivalent here. Thanks.
Click to expand...
Click to collapse
Mape0661 said:
I think we need to edit /init.rc
but it's write protected =/
Click to expand...
Click to collapse
You can, but you would have to do the modifications with an extracted system image, re-squashfs it back up, and then flash it back to the device.

Thanks for the replies. If I'm feeling bold this weekend I'll take a look at creating a one-off /system for this.

bobcat987 said:
Thanks for the replies. If I'm feeling bold this weekend I'll take a look at creating a one-off /system for this.
Click to expand...
Click to collapse
I've been writing some, gonna post it later on git if you want to see it.
mostly stuff to make it easy to start ftp, samba etc.
/mape

ddggttff3 said:
You can, but you would have to do the modifications with an extracted system image, re-squashfs it back up, and then flash it back to the device.
Click to expand...
Click to collapse
Seeing this you guys are making me think (always dangerous!)
Is it possible to code and inject an on device player app that could be inserted into the system (similar to Netflix) that could be triggered by another app for local playback without the need for an Internet connection?
Something like that would really increase the streaming capability for areas where Internet connection is not available.
And if the right code is found could even give local streams DHT capability if we had the ability to add those codecs to the player system.

ddggttff3 said:
You can, but you would have to do the modifications with an extracted system image, re-squashfs it back up, and then flash it back to the device.
Click to expand...
Click to collapse
I've been looking at system.img from 19084.001.zip
it seems it only got this then I unsquashfs it
[email protected]:~/squashfs-root# ls
bin boot chrome etc lib netflix res usr
I'm I looking in the wrong file?

Mape0661 said:
I've been looking at system.img from 19084.001.zip
it seems it only got this then I unsquashfs it
[email protected]:~/squashfs-root# ls
bin boot chrome etc lib netflix res usr
I'm I looking in the wrong file?
Click to expand...
Click to collapse
if you want to modify init.rc, then you need to extract the initramfs from the kernel, modify it, repackage the initramfs, compile the kernel from src (as the default one is signed, and can't be merged with a modified initramfs), and then merge the compiled kernel with the initramfs you modified.

ddggttff3 said:
if you want to modify init.rc, then you need to extract the initramfs from the kernel, modify it, repackage the initramfs, compile the kernel from src (as the default one is signed, and can't be merged with a modified initramfs), and then merge the compiled kernel with the initramfs you modified.
Click to expand...
Click to collapse
Looks like this gonna be my "children are sleeping" project for some time .-)
Well I extracted initramfs from boot.img and mounted it with cpio. At least I'm looking at the right files. I have never compiled a kernel for this kind of devices before (only for my computer) and I having trubble to cross compile, my arm compiled programs wont run on CC.
Do you got some good pages I can read and learn this stuff from?

Related

Questionable Directories

I have two directories on my phone that I'm not sure about. Here is what ls in the root of my phone spits out:
Code:
sqlite_stmt_journals
config
cache
emmc
sdcard
d
etc
system
sys
sbin
proc
logo.rle
init.rc
init.heroc.rc~
init.heroc.rc
init.hero.rc~
init.goldfish.rc
init
default.prop
data
root
dev
The ones in question are:
init.heroc.rc~
init.hero.rc~
d
Does anyone if these are legit and if they can be deleted or not?
Well, the .rc's are not directories, (or at least they shouldn't be) they are likely configuration files. Since they are appended by tildas (~) they are likely old versions of the originals (can't say for certain). The d folder likely contains daemons.
I am basing this off my own linux knowledge, I do not have experience with an android as of yet.
Transmition said:
Well, the .rc's are not directories, (or at least they shouldn't be) they are likely configuration files. Since they are appended by tildas (~) they are likely old versions of the originals (can't say for certain). The d folder likely contains daemons.
I am basing this off my own linux knowledge, I do not have experience with an android as of yet.
Click to expand...
Click to collapse
So the .rc~'s can go? Not sure what a daemon is, but I'm thinking it's not something I want to delete though
I'll nandroid and give it a shot and see what happens.
the init.hero.rc~ files are backups created while editing. Common when using beta/testing software. You can delete them, but they will return as they are in the ramdisk.
The d is an error. You also have a directory named init . You're supposed to have a directory named init.d, and no dir named init or named d. If this is not something you have done, let the developer of the ROM know there's a little bug that needs fixed.
Off topic, insomnia sucks and I needed to say that
gbhil said:
the init.hero.rc~ files are backups created while editing. Common when using beta/testing software. You can delete them, but they will return as they are in the ramdisk.
The d is an error. You also have a directory named init . You're supposed to have a directory named init.d, and no dir named init or named d. If this is not something you have done, let the developer of the ROM know there's a little bug that needs fixed.
Off topic, insomnia sucks and I needed to say that
Click to expand...
Click to collapse
Thanks! And yes I agree, insomnia is a bummer :/
Are you really from Tanzania?
gbhil said:
Off topic, insomnia sucks and I needed to say that
Click to expand...
Click to collapse
right there with ya man.
Gregalous said:
Thanks! And yes I agree, insomnia is a bummer :/
Are you really from Tanzania?
Click to expand...
Click to collapse
Tanzania? No I'm from Florida. Why do you ask?
And your welcome
edit: nevermind lol. how the hell did that get there??
gbhil said:
If this is not something you have done, let the developer of the ROM know there's a little bug that needs fixed.
Click to expand...
Click to collapse
Darch's AOSP 2.1 actually. I know you're working with him on it so maybe you could let him know. I'll post it in the thread too but this is a fairly minor issue

{TOOL}MetaMorph Builder v2-Linux Only[8-5]

This could be considered part of the development forum or the apps and theme forum depending on how you look at it. if you have an issue, just click the report button and request that it be moved. no need to flame and troll and post that you reported it, just do it and move on.
Lots of people have asked me how to put together a theme control file, and its actually VERY easy but this tool makes it even easier.
this is an example of a theme control file created by this tool
Test-Theme.xml
Code:
<themename>Test-theme</themename>
<author>tater-salad</author>
<phone>Android Phone Codename Hulk</phone>
<rom>CM 8</rom>
<item>Phone.apk</item>
<path>/system/app<path>
<item>framework-res.apk</item>
<path>/system/framework</path>
<description>Requires reboot</description>
<item>FM-Reciever.apk</item>
<path>/data/app<path>
<item>My-custom-app.apk</item>
<path>/data/app<path>
run the mm-builder script and follow the on screen directions. you will of course need to put the correct replacement files in their respective directories, but this script will make all the right folders and set up your theme.xml for you. Bash scrip means linux only. This is also a super easy script, so i may get a batch version soon.
You can extract this file to any directory
All thanks to Stericson. W/O him we wouldnt have a metamorph app to begin with
######################################################################################################
v2
includes these additions
Code:
mkdir $app
mkdir $app/res
mkdir $app/res/drawable
mkdir $app/res/drawable-mdpi
mkdir $app/res/drawable-land-mdpi
mkdir $app/res/drawable-port-mdpi
these are the commonly used directories when it comes to theming. now all the sub-folders should be set up right.
So you are saying this will create the res folder and other folders needed?
ya.
it works by reading the user input.
you specifiy what apps you will be morphing, and the script adds the necessary lines to the .xml and creates the folders for them too.
EDIT:
nevermind, i see what you mean. it doesnt set up the sub-folders.
let me work that up and ill have a new version up-if you want to use before then you will need to make the sub-directories yourself.
ban_dover said:
ya.
it works by reading the user input.
you specifiy what apps you will be morphing, and the script adds the necessary lines to the .xml and creates the folders for them too.
Click to expand...
Click to collapse
EDIT: Since this is Andrizoid, for all I know its a virus you stole from someone and put your info in.
droidkevlar said:
Very cool. If you get a winblows version out, this will make it very easy to change icons for all apps. Nice work!
Click to expand...
Click to collapse
as i said in the other thread, batch is pretty alien coming from bash, but im sure it can be done pretty easily.
it is really easy to install ubuntu on a VB though. i have wyndoze on a VB with Ubuntu as the host, so thats why all my stuff is bash haha.
once i start messing aroud on my VBox and get a feel for batch ill start working on it. its a really simple script if you look at it so it shouldnt involve too much hassle.
adding
Code:
mkdir $app
mkdir $app/res
mkdir $app/res/drawable
mkdir $app/res/drawable-mdpi
mkdir $app/res/drawable-land-mdpi
mkdir $app/res/drawable-port-mdpi
drawable, drawable-mdpi, drawable-port-mdpi, and drawable-land-mdpi seem to be the only onces ever used in a theme-i checked like 15 of them that i have saved. let me know if i missed any commonly used folders and ill be sure to get them in soon.
noticed that i missed two "/" characters in the script that will cause the them xml to not run right. ill fix it in a minute. just look at the other thread under development though-i dont want 2 threads
droidkevlar said:
EDIT: Since this is Andrizoid, for all I know its a virus you stole from someone and put your info in.
Click to expand...
Click to collapse
Are you serious? That's just stupid, leave him alone.

[Q] Permanently change system file

i want to change the file "sys/devices/i2c-0/0-0066/leds/jogball-backlight/period" to "2"
to do this i have to edit the permissions for it to work, but every time i reboot it reverts back to the original file
does anyone know how i can change this file permanently?
when i change it, it says file backed up as "period.bak" but i cant find where this is backed up to
This is not a real file. This is a virtual file - interface to device driver parameters. To change it permanently, you need either to see where the initial value comes from and change it there somehow, or to overwrite the driver interface file each boot.
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
bassmadrigal said:
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
Click to expand...
Click to collapse
sorry, 777 permissions? as in tick all of em? never mind
maxib123 said:
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
Click to expand...
Click to collapse
Most probably it's hard-coded somewhere in the system, which would require recompiling. Overwriting the value each boot, for example with init.d scripts as suggested above, would be much simpler. Just make sure that the value is initialized by the time you're executing your script, and that the ROM is configured to run them.
Jack_R1 said:
Most probably it's hard-coded somewhere in the system, which would require recompiling. Overwriting the value each boot, for example with init.d scripts as suggested above, would be much simpler. Just make sure that the value is initialized by the time you're executing your script, and that the ROM is configured to run them.
Click to expand...
Click to collapse
how would i do that?
bassmadrigal said:
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
Click to expand...
Click to collapse
just checking, does the "99setpulserate" file just need to be a new file, or do i copy it over and rename it?
I'm not exactly sure what you mean. It needs to be a new file, but you can copy the text and past it in (if you use adb, or the browser on the phone).
The numbers at the beginning are the order in which things should be run (if I remember correctly from my old linux classes, Slackware uses the RC files which is slightly different). So technically, you can pick any number, but it is best to leave user scripts at 99 so that everything that needs to get loaded beforehand can get loaded.
bassmadrigal said:
I'm not exactly sure what you mean. It needs to be a new file, but you can copy the text and past it in (if you use adb, or the browser on the phone).
The numbers at the beginning are the order in which things should be run (if I remember correctly from my old linux classes, Slackware uses the RC files which is slightly different). So technically, you can pick any number, but it is best to leave user scripts at 99 so that everything that needs to get loaded beforehand can get loaded.
Click to expand...
Click to collapse
yeh... its doesnt work :L
maxib123 said:
yeh... its doesnt work :L
Click to expand...
Click to collapse
What if you manually run the file?
Code:
sh 99setpulserate
See if it is a screwup in the script or my understanding of the init system of Android (I am leaning towards the second one, because I double checked the script and it seems fine).
bassmadrigal said:
What if you manually run the file?
Code:
sh 99setpulserate
See if it is a screwup in the script or my understanding of the init system of Android (I am leaning towards the second one, because I double checked the script and it seems fine).
Click to expand...
Click to collapse
2: not found
tried on adb and emulator
Include the full path to the script when you run it from shell.
I don't know why it wouldn't be working, but I suppose worst case, you could always just add the contents of the script (except for the first line) to the 20userinit file at the bottom.
maxib123 said:
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
Click to expand...
Click to collapse
i can show you exactly where the source code is for this file. its the microp.c file in arch/arm/mach-msm folder of the source code kernel.
EDIT: here is the actual file source code.
https://github.com/CyanogenMod/cm-k....37/arch/arm/mach-msm/board-mahimahi-microp.c
you could possibly have someone compile a kernel with changes to this that would set it to your value so you wouldnt have to mess with it each boot up. but i havent look at the code yet to know, so i'll take a look and see.
EDIT: so it looks like when powered up this driver defines the particular data in question from this register address:
Code:
#define MICROP_I2C_WCMD_JOGBALL_LED_PERIOD_SET 0x5D
so you could easily just add some code to set it to your value of 2 upon initialization. i want to say that you can permanently set that register address to a different value. but it seems like its getting cleared upon each reboot, so your best option is to just have the code set it manually.
probably easier than compiling your own kernel would be to just create some simple BASH script that does this upon boot up. though the more fun proper way is change the code.
Jack_R1 said:
Include the full path to the script when you run it from shell.
Click to expand...
Click to collapse
Yeh I did
Sent from my Nexus One using XDA App
How about creating a pre-modified version of the period file, and have the init overwrite the current one at each boot, rather than trying to edit it in the fly...?
danger-rat said:
How about creating a pre-modified version of the period file, and have the init overwrite the current one at each boot, rather than trying to edit it in the fly...?
Click to expand...
Click to collapse
what do i need to do to do that?
If you look at that code, its not an actual file but just a virtual register read from the hardware. So your only option is to create a startup init script to write your desired value to that register (file) on boot up.
why has it changed? it used to be how i want it on the older versions of cyanogen, isnt there some files i could just take from those files and take it over?? seems like a much simpler option :L

How to make a Magisk module replace a certain string inside a system-file?

Hi there!
I am searching for an easy way to make a Magisk module that can do the following:
Look for file /system/<whatever>
Look inside this file for a string, e.g. value = 0
Replace this string with value = 1
Systemlessly replace the modified file.
I'm pretty sure this should be possible with post-fs scripts, but I'm too bad at shell-scripts to know how.
I am aware that I could just copy the file, edit it on the computer and create a simple replacement module, but this solution would always replace the whole file and would thus possibly be device specific. It would give trouble on devices which need other content around the line to be replaced.
The solution that I'm looking for would be much more universal and would work on any device which has that file, regardless of the content.
Can anybody help?
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
Code:
cp /system/<filenamehere> /magisk/<yourmodulename>/system/<filenamehere>
sed -i 's/<originalstring>/<newstring>/g' /magisk/<yourmodulename>/system/<filenamehere>
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Didgeridoohan said:
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Click to expand...
Click to collapse
The idea looks kinda interesting. Wouldn't the cp command be obsolete if I could make the sed command take /system/<file> as input and output to /magisk/<Modname>/system/<file> ?
I guess I'll try to study some documents about sed before continuing. But the idea is already pretty good I think.
Naudiz said:
The idea looks kinda interesting. Wouldn't the cp command be obsolete if I could make the sed command take /system/<file> as input and output to /magisk/<Modname>/system/<file> ?
I guess I'll try to study some documents about sed before continuing. But the idea is already pretty good I think.
Click to expand...
Click to collapse
You need to copy the file to the magisk module folder for it to work as a magisk mod properly. Essentially this is necessary.
Sed is what removes, finds, replaces, or injects lines or matches within a file.
How can I modify or replace /proc/sys/net/ip_default_ttl
Which is better option?
To modify I would change from 64 to 65 or put new file..
Thanks in advanced
RawSlugs said:
How can I modify or replace /proc/sys/net/ip_default_ttl
Which is better option?
To modify I would change from 64 to 65 or put new file..
Thanks in advanced
Click to expand...
Click to collapse
Magisk can't mount anything there (only to /system). If you don't want to do it manually, you can create a module with a boot script (post-fs-data.sh or service.sh, depending on the timing you want) that modifies the file (with sed), or simply use a boot script in post-fs-data.d or service.d.
You can find more details on the different boot stages and stuff in the official Magisk docs.
Didgeridoohan said:
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
Code:
cp /system/<filenamehere> /magisk/<yourmodulename>/system/<filenamehere>
sed -i 's/<originalstring>/<newstring>/g' /magisk/<yourmodulename>/system/<filenamehere>
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Click to expand...
Click to collapse
Code is good, and adding the --archive flag to the cp command will make it preserve the older properties, mode, contexts, etc
And also if the string contains any PATHs or just a slash in it, then sed will not recognize the pattern and give an error, so using pipes as sed delimeters will prevent this
This is all I could say
MCMotherEffin' said:
Code is good, and adding the --archive flag to the cp command will make it preserve the older properties, mode, contexts, etc
And also if the string contains any PATHs or just a slash in it, then sed will not recognize the pattern and give an error, so using pipes as sed delimeters will prevent this
This is all I could say
Click to expand...
Click to collapse
Thanks, but that's a year old post and I've since had plenty of opportunity to test. And yes, what you say is true. :good:
Didgeridoohan said:
Thanks, but that's a year old post and I've since had plenty of opportunity to test. And yes, what you say is true. :good:
Click to expand...
Click to collapse
Oops, forgive me, I forgot to see the date

[Help] Trying to make module, getting stuck at bootloop

I'm trying to make a module that tricks the Nexus 6 to thinking it's a Pixel for the unlimited, original quality photo backup. Not really experienced in doing this stuff and not sure what I'm doing wrong. When I flash this, it won't boot.
The Disclaimer for anyone trying this: This will likely ONLY work on Nexus 6. The XML system file is named differently on the 6p and 5x and the rest of the xml code here might be different, breaking other features.
In a nutshell, what this is supposed to do is replace /system/etc/sysconfig/google.xml with a modified xml file. I was considering looking up how to simply add the code to the xml file, but not sure how you'd target a location to inject the code to in the file. There's an opening and closing tag it needs to sit between. But if this can be done, it would probably expand support to more devices than just the Nexus 6.
EDIT: I found a typo in my module. This was the problem
Have you made sure you're using the correct encoding and line endings, and that it doesn't need any other permissions than those set by the module? Also, have you made sure that there are no other files that also need changing so there'll be conflict if you don't change them all?
In theory, you should be able to use a script (in post-fs-data.sh maybe?) to copy (cp command) the original file into your module folder and then use more scripting to edit/replace/prepend/append (sed, echo, and so on) the lines you want. I've never tried it myself or seen anyone do it though, that's why I'm saying "in theory".
Didgeridoohan said:
Have you made sure you're using the correct encoding and line endings, and that it doesn't need any other permissions than those set by the module? Also, have you made sure that there are no other files that also need changing so there'll be conflict if you don't change them all?
In theory, you should be able to use a script (in post-fs-data.sh maybe?) to copy (cp command) the original file into your module folder and then use more scripting to edit/replace/prepend/append (sed, echo, and so on) the lines you want. I've never tried it myself or seen anyone do it though, that's why I'm saying "in theory".
Click to expand...
Click to collapse
Thanks for the suggestion. I am a visually creative person. My extent of programming is HTML and CSS. So this is a quite the learning experience for me. Plus statistically, learning a language (and programming is similar to language) is more difficult for people as they get older... I'm not that old, but I'm not young either lol.
I'm not sure what you mean about encoding. I mean, I understand what encoding is, but not how to check it or verify what it should be.
If it helps, directly replacing the file in System by itself (not using Magisk) does work and make the necessary changes/affect. So I am assuming no other files are necessary to be modified or replaced. In fact, the XML doesn't reference any other outside files that I've noticed. I thought simply replacing it through Magisk would work as well. I haven't tried specifying permissions, but I can try that next.
Glad it worked. Typos can be a pain in the ass!
Now on to making it device independent...

Categories

Resources