Hidden Shutdown Options - How do they work?

Discussion in 'Bugless' started by Se7enLC, Jun 17, 2010.

  1. Se7enLC
    Offline

    Se7enLC Active Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    36
    Ratings:
    +0


    I was intrigued when the way to disable this new feature was to erase /system/bin/shutdown, so I looked at the contents of that script:

    Code:
    #!/system/bin/sh
    
    stop;
    stop dhcpcd;
    
    sleep 1;
    
    for i in `cat /proc/mounts | cut -f 2 -d " "`;
    do
       busybox mount -o remount,ro $i 2>&1 > /dev/null;
    done
    
    sync;
    
    if [ "$1" = "-r" ];
    then
       toolbox reboot;
    fi
    
    if [ "$1" = "-rr" ];
    then
       toolbox reboot recovery;
    else 
       reboot -p;
    fi
    Looks pretty straightforward to me. That must not be what actually checks the keys, though. I looked at a diff between the V01 and V02 update files - and that shutdown script is the only change!

    Does this mean that the hidden recovery options were there all along and the shutdown script was just missing? Did you have to do something else to enable this feature, Pete?

    I'm tempted to go one step further and map those keys to OTHER things by editing this script. It'll be a little (a lot) kludgy to have a shutdown script that does other stuff that isn't shutting down, but remapping hardware keys to custom linux scripts can't be a bad thing...
  2. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    I was trying to figure out how to just disable the camera button shutdown, but keep the reboot options. Tried adding this to the beginning of the script but not having any luck.

    Code:
    if [[ "$1" != "-r" && "$1" != "-rr" ]];
    then
    exit 0;
    fi
    
  3. Se7enLC
    Offline

    Se7enLC Active Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    36
    Ratings:
    +0
    Try single brackets instead of double?
  4. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    nope no go, on both versions none of the shutdown combos work after i've added the if statement.
  5. Se7enLC
    Offline

    Se7enLC Active Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    36
    Ratings:
    +0
    Are you editing the file on the phone, or pushing it from a computer? I've been having some problems with files made on the phone for some reason. I think the semicolon key is wrong, perhaps?

    Anyway, I pasted almost your exact change into the script, and changed all the actual commands to "echo" so I could test it without rebooting all the time. Running it from the commandline directly seems to work fine, only does something when you give it -r and -rr, does nothing when you give it no command.
  6. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    got it, instead of creating the file on my pc and pushing it to the phone, i just edited the current shutdown script and it worked.

    only thing is now, instead of shutdown with the camera button, it now just locks up the phone and i have to do a battery pull. the reboot ones work fine. Should i be exiting the script a different way than "exit 0;" ?
  7. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    hah, just saw this
  8. Se7enLC
    Offline

    Se7enLC Active Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    36
    Ratings:
    +0
    Here's the real (working) version. I just tested it out - the volume buttons still do stuff, camera button doesn't.

    Make sure you chmod 0755 the file once you copy it in.
  9. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    you sure this is the same one you tested? camera button still shuts down on me
  10. Se7enLC
    Offline

    Se7enLC Active Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    36
    Ratings:
    +0
    Positive. But I'm running a non-standard shell for /system/bin/sh, so that could be it. I'll look into it a little closer later, perhaps.
  11. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    ah could be it, i'll keep digging. Thanks for the help
  12. Tallica
    Offline

    Tallica Premium Member Rescue Squad Premium Member

    Joined:
    Mar 17, 2010
    Messages:
    3,259
    Likes Received:
    1
    Trophy Points:
    101
    Location:
    Middleboro, MA
    Ratings:
    +1
    This is how you stop it.

    -Hidden Shutdown Options using keys (credit to Pete):
    To Remove These Options Delete /system/bin/shutdown

    to just disable rename the file to shutdown.bak
  13. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0

    agreed, but i don't want to stop it all, just want to disable the camera button one.
  14. Tallica
    Offline

    Tallica Premium Member Rescue Squad Premium Member

    Joined:
    Mar 17, 2010
    Messages:
    3,259
    Likes Received:
    1
    Trophy Points:
    101
    Location:
    Middleboro, MA
    Ratings:
    +1
    sorry, my bad
  15. Reserved Name
    Offline

    Reserved Name Member

    Joined:
    Mar 7, 2010
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    [​IMG]
    magnets
Search tags for this page
android command line shutdown
,
android halt command
,
android script shutdown
,

android shutdown command

,
android shutdown options
,

android shutdown script

,
change shutdown options android
,
droid x2 how to change shutdown
,
shutdown android command
,

shutdown command android