Pavol
|
2010-10-02
, 16:23
|
Posts: 54 |
Thanked: 7 times |
Joined on Mar 2010
@ Slovakia, Žilina
|
#61
|
|
2010-10-02
, 18:57
|
Posts: 429 |
Thanked: 217 times |
Joined on Apr 2010
@ Dubai
|
#62
|
|
2010-10-02
, 21:11
|
Posts: 1,751 |
Thanked: 844 times |
Joined on Feb 2010
@ Sweden
|
#63
|
@almehdi
i thought instead of giving off an error why not auto install it if not found??Code:if [ ! "`dpkg -l | grep 'rootsh'`" ]; then echo "not installed, installing..." sudo apt-get install rootsh exit elif [ ! "`dpkg -l | grep 'kernel-power'`" ]; then echo "not installed, installing..." apt-get install kernel-power exit elif [ ! "`dpkg -l | grep 'kernel-power-settings'`" ]; then echo "not installed, installing..." apt-get install kernel-power-settings exit else echo "found and installed, will continue" fi
so yeah this is what i ended up with i tested it on two of my mobiles
and i was hoping if you could point out any mistakes within it
cheers
# Is the user root? user=`whoami` if [ $user != "root" ]; then echo "You are not root. You need to be root to run this script. If not installed. Then install it through the Application Manager." exit 1 fi # Check for dependencies if [ ! "`dpkg -l | grep 'kernel-power'`" ]; then echo "Enhanced kernel for power users is not installed, installing..." apt-get install -y kernel-power if [ ! "`dpkg -l | grep 'kernel-power-settings'`" ]; then echo "Enhanced kernel for power users (settings) is not installed, installing..." apt-get install -y kernel-power-settings halt fi fi if [ ! "`dpkg -l | grep 'kernel-power-settings'`" ]; then echo "Enhanced kernel for power users (settings) is not installed, installing..." apt-get install -y kernel-power-settings if [ ! "`dpkg -l | grep 'kernel-power'`" ]; then echo "Enhanced kernel for power users is not installed, installing..." apt-get install kernel-power halt fi fi
|
2010-10-03
, 02:52
|
|
Posts: 511 |
Thanked: 128 times |
Joined on Aug 2010
@ Trinidad and Tobago
|
#64
|
|
2010-10-03
, 10:51
|
Posts: 529 |
Thanked: 194 times |
Joined on Aug 2010
@ UK
|
#65
|
|
2010-10-03
, 11:05
|
Posts: 1,751 |
Thanked: 844 times |
Joined on Feb 2010
@ Sweden
|
#66
|
|
2010-10-03
, 11:31
|
|
Posts: 511 |
Thanked: 128 times |
Joined on Aug 2010
@ Trinidad and Tobago
|
#67
|
The Following User Says Thank You to RenaldoTT For This Useful Post: | ||
|
2010-10-03
, 11:47
|
Posts: 529 |
Thanked: 194 times |
Joined on Aug 2010
@ UK
|
#68
|
|
2010-10-03
, 11:56
|
Posts: 429 |
Thanked: 217 times |
Joined on Apr 2010
@ Dubai
|
#69
|
first screen is proof file is there an secnod is after trying
mv /home/user/MyDocs/oc-script /home/user/MyDocs/oc-script.sh
sh /home/user/MyDocs/.documents/oc-script
|
2010-10-03
, 11:57
|
Posts: 429 |
Thanked: 217 times |
Joined on Apr 2010
@ Dubai
|
#70
|
Yes, that is good. Two things though.. rootsh can't be installed through apt-get. You need to have rootsh to use apt-get so the only way to install it is using the app manager.
And if you don't want the user to be prompted whit the "yes/no" if they want to install.. you could add an "-y" at the end. So it becomes "apt-get install -y kernel-power". Then the process would become more fluid.
Ohh.. and "else" will not be needed. If they already have rootsh and kernel-power installed than that could be come confusing. And "exit" was only needed for the rootsh one as that is the only reason for the script to abort. The dependecies get's installed in the other cases.
You could add another if-statment in case it need an reboot (halt). As you need to be root to use the script.. i added an check for that instead of the check for rootsh.
Code:# Is the user root? user=`whoami` if [ $user != "root" ]; then echo "You are not root. You need to be root to run this script. If not installed. Then install it through the Application Manager." exit 1 fi # Check for dependencies if [ ! "`dpkg -l | grep 'kernel-power'`" ]; then echo "Enhanced kernel for power users is not installed, installing..." apt-get install -y kernel-power if [ ! "`dpkg -l | grep 'kernel-power-settings'`" ]; then echo "Enhanced kernel for power users (settings) is not installed, installing..." apt-get install -y kernel-power-settings halt fi fi if [ ! "`dpkg -l | grep 'kernel-power-settings'`" ]; then echo "Enhanced kernel for power users (settings) is not installed, installing..." apt-get install -y kernel-power-settings if [ ! "`dpkg -l | grep 'kernel-power'`" ]; then echo "Enhanced kernel for power users is not installed, installing..." apt-get install kernel-power halt fi fi