I created a script for my rom. But..

ungaze

Senior Member
Jul 27, 2010
401
158
0
manila
Alright, get tips from the master.

Also, I don't have a linux machine but when making scripts(for android) I just use "root explorer's text editor to make the script itself and make corrections if needed and use terminal to test it. This way errors are addressed real time and making the corrections are far more efficient.

Like what ruigui has suggested, try making a bunch of "echo" loops, to know that all your functions work correctly and link's to each other. When everything's ok, then you can add the real commands and test them one by one.
 

Bytecode

Inactive Recognized Developer
Dec 30, 2010
2,684
4,487
0
22
/dev/null
could you update us on what your script looks like now? Lot of unclosed blocks on your script up there which you have probably corrected by now.

and this:
Code:
read $boot
should be like this:
Code:
read boot
and when asking for an input with only 2 possible answers, if-fi loop should fit the job perfectly rather than the case loop, as such on you on and off functions.
Oh crap,i did this and now script works!!! Thanks guys. But BTW i get an error when exiting script. I get a loop of "Goodbye!" but nothing. Here's the script:
Code:
#! /system/bin/bash   

##########################################################################
# openOptimus tweaks v2 beta 5                                           #
# Script created by ciaox,only for openOptimus.                          #
##########################################################################


reboot(){
echo Phone is rebooting.. applying changes.
reboot
}

heap48(){
setprop dalvik.vm.heapsize=48m
echo Now Heapsize is 48m.
read -p "Press any key to return to main menu.."
clear
main_menu
}

heap32(){
setprop dalvik.vm.heapsize=32m
echo Now Heapsize is 32m.
read -p "Press any key to return to main menu.."
clear
main_menu
}

heap24(){
setprop dalvik.vm.heapsize=24m
echo Now Heapsize is 24m.
read -p "Press any key to return to main menu.."
clear
main_menu
}

heapsize(){
clear
echo --------------------------------------------------------- 
echo -          Heap size changer                            -
echo ---------------------------------------------------------   
echo Please choose an option:
echo 1.Raise Heapsize to 48m
echo 2.Decrease Heapsize to 32m
echo 3.Decrease Heapsize to 24m
    read heap48
        case $heap48 in
        1)
            heap48
        ;;
        2)
            heap32
        ;;
        3)
            heap24
        ;;
        esac 
}
exit(){
echo Goodbye! And hope you will enjoy openOptimus.
exit
}

hwon(){
setprop debug.sf.hw=1
  echo Hardware acceleration enabled.
read -p "Press any key to return to main menu.."
clear
main_menu
}

hwoff(){
setprop debug.sf.hw=0
  echo Hardware acceleration disabled.
read -p "Press any key to return to main menu.."
clear
main_menu
}

sfon(){
setprop media.stagefright.enable-player=true
setprop media.stagefright.enable-meta=true
setprop media.stagefright.enable-scan=true
setprop media.stagefright.enable-http=true
echo Stagefright player enabled.
read -p "Press any key to return to main menu.."
clear
main_menu
}

sfoff(){
setprop media.stagefright.enable-player=false
setprop media.stagefright.enable-meta=false
setprop media.stagefright.enable-scan=false
setprop media.stagefright.enable-http=false
echo Stagefright player disabled.
read -p "Press any key to return to main menu.."
clear
main_menu
}

megatron(){
cp /sdcard/openOptimus_resources/Megatron/bootanimation.zip /data/local
echo Boot animation copied.
read -p "Press any key to return to main menu.."
clear
main_menu
}

particles(){
cp /sdcard/openOptimus_resources/Particles/bootanimation.zip /data/local
echo Boot animation copied.
read -p "Press any key to return to main menu.."
clear
main_menu
}

cyan7(){
cp /sdcard/openOptimus_resources/CM7/bootanimation.zip /data/local
echo Boot animation copied.
read -p "Press any key to return to main menu.."
clear
main_menu
}

coin(){
cp /sdcard/openOptimus_resources/Coin/bootanimation.zip /data/local
echo Boot animation copied.
read -p "Press any key to return to main menu.."
clear
main_menu
}

boot(){
echo --------------------------------------------------------- 
echo -          Boot animation changer                       -
echo ---------------------------------------------------------   
echo Please choose one:
echo 1.Megatron boot animation
echo 2.Android particles
echo 3.CyanogenMod 7
echo 4.Coin
    read megatron
        case $megatron in
        1)
            megatron
        ;;
        2)
            particles
        ;;
        3)
            cyan7
        ;; 
        4)
            coin
        esac 
}
tx(){
iwconfig wlan0
read -p "Press any key to return to main menu.."
clear
main_menu
}

sf(){
echo --------------------------------------------------------- 
echo -          Stagefright player enabler/disabler          -
echo ---------------------------------------------------------                                                


echo Please choose an option:
echo 1.Enable Stagefright player
echo 2.Disable stagefright player
    read sfon
        case $sfon in
        1)
            sfon
        ;;
        2)
            sfoff
        esac 
}

hw(){
echo --------------------------------------------------------- 
echo -          Hardware acceleration enabler/disabler       -
echo ---------------------------------------------------------                                      
echo 
echo Please choose an option:
echo 1.Enable Hardware acceleration
echo 2.Disable Hardware acceleration

    read hwon
        case $sfon in
        1)
            hwon
        ;;
        2)
            hwoff
        esac 
}

main_menu(){
echo --------------------------------------------------------- 
echo -          Welcome to openOptimus modding Script!       -
echo ---------------------------------------------------------         
     

echo Choose an option:
echo 1.Change boot animation
echo 2.Disable/enable Stagefright player
echo 3.Enable/disable Hardware acceleration
echo 4.Check Wi-Fi Tx-Power,run only with Wifi On.
echo 5.Exit
echo 6.Reboot

    read boot
        case $boot in
        1)
            boot
        ;;
        2)
            sf
        ;;
        3)
            hw
        ;; 
        4)
            tx
        ;; 
        5)
            exit
        ;; 
        6)
            reboot
        esac
}
 
main_menu
EDIT:Now script fully works. Thanks for help guys,especially kpbotbot and ungaze.
 
Last edited: