[Q] Anyone good with BASH? (linux) - Off-topic

Hey, I wonder if anyone is good with BASH is around here, what I want is simple, but for some reason it didn't work for me
So here is what I want, a .sh (or any other linux executable) file that executes the following code if the user input was the character 'm'
Code:
sudo mkdir /media/mp3
sudo chmod 775 /media/mp3
sudo mtpfs -o allow_other /media/mp3
and this if the input was 'u'
Code:
sudo umount /media/mp3
sudo rmdir /media/mp3
anything else: exit
thanks in advance

are you looking for something like this?
Code:
#!/bin/bash
if [ `whoami` != "root" ]; then
echo "you must execute this script with root priveleges!"
exit
fi
clear
echo
echo "enter m to mount /media/mp3 or enter u to unmount it"
echo
read moru
if [ "$moru" = "m" ]; then
mkdir -p /media/mp3
chmod 775 /media/mp3
mtpfs -o allow_other /media/mp3
elif [ "$moru" = "u" ]; then
umount /media/mp3
rmdir /media/mp3
fi
exit
HTH

the code seems ok, but still not working, the is the output in kate when I pipe it to terminal
(not that I was root when before I pipe it using su)
Code:
Dash-Netbook Desktop # #!/bin/bash
Dash-Netbook Desktop #
Dash-Netbook Desktop # if [ `whoami` != "root" ]; then
> echo "you must execute this script with root priveleges!"
echo "you must execute this script with root priveleges"]; then
bash: syntax error near unexpected token `then'
Dash-Netbook Desktop # exit
exit
[email protected] ~/Desktop $ fi
bash: syntax error near unexpected token `fi'
[email protected] ~/Desktop $
[email protected] ~/Desktop $ clear
[email protected] ~/Desktop $ echo
[email protected] ~/Desktop $ echo "enter m to mount /media/mp3 or enter u to unmount it"
enter m to mount /media/mp3 or enter u to unmount it
[email protected] ~/Desktop $ echo
[email protected] ~/Desktop $ read moru
[email protected] ~/Desktop $
[email protected] ~/Desktop $ if [ "$moru" = "m" ]; then
> mkdir -p /media/mp3
> chmod 775 /media/mp3
> mtpfs -o allow_other /media/mp3
> elif [ "$moru" = "u" ]; then
> umount /media/mp3
> rmdir /media/mp3
> fi
[email protected] ~/Desktop $
[email protected] ~/Desktop $ exit

husam666 said:
Hey, I wonder if anyone is good with BASH is around here, what I want is simple, but for some reason it didn't work for me
So here is what I want, a .sh (or any other linux executable) file that executes the following code if the user input was the character 'm'
Code:
sudo mkdir /media/mp3
sudo chmod 775 /media/mp3
sudo mtpfs -o allow_other /media/mp3
and this if the input was 'u'
Code:
sudo umount /media/mp3
sudo rmdir /media/mp3
anything else: exit
thanks in advance
Click to expand...
Click to collapse
I know it sounds stuff, but I don't know my way around Linux. What does that script actually do?
Sent from my HTC Wildfire S A510e using XDA

Bad-Wolf said:
I know it sounds stuff, but I don't know my way around Linux. What does that script actually do?
Sent from my HTC Wildfire S A510e using XDA
Click to expand...
Click to collapse
the first part mounts my mp3 player (MTP device) on the /media/mp3 directory
The other part unmounts it and deletes the directory
Sent from the brick

What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...

use this one Husam!
on a terminal:
Code:
sudo -s
chmod +x husam.sh
sh husam.sh
I tweaked the code a bit and added extra functionality
You might wanna try that script without root...

.Ahau said:
What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...
Click to expand...
Click to collapse
ok, I'm using linux mint kde 12.1, and I use kate for a text editor, I didn't do the chmod thing, I only used sh file.sh
@dex, ok..

.Ahau said:
What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...
Click to expand...
Click to collapse
ok, it worked
thx
@dex, what kind of idiot do you think I am -_-
I always check executables before executing

husam666 said:
ok, it worked
thx
@dex, what kind of idiot do you think I am -_-
I always check executables before executing
Click to expand...
Click to collapse
oh come on
I know you liked my modifications

dexter93 said:
oh come on
I know you liked my modifications
Click to expand...
Click to collapse
btw, should I check the link you gave me?

husam666 said:
btw, should I check the link you gave me?
Click to expand...
Click to collapse
the "surprise" one? depends.. if you are brave enough
(you already know what it is though)
but the download link in my post is legit, it works

dexter93 said:
the "surprise" one? depends.. if you are brave enough
(you already know what it is though)
but the download link in my post is legit, it works
Click to expand...
Click to collapse
lmao, check my latest fb status then

husam666 said:
lmao, check my latest fb status then
Click to expand...
Click to collapse
that's where i got the idea from

glad it's working for you!

Related

mkdir: no such tool

it is inside /system/xbin and link to busybox, busybox mkdir works...
now root explorer/ cifs manager cannot create directory, how to fix?
Sent from my Milestone using XDA App
my rom is CM7 RC4.1
sorry cannot post to dev
can someone give me some idea of wth is happening? discussion is okay.
Sent from my Milestone using XDA App
any guide to update/reinstall busybox?
Sent from my Milestone using XDA App
Busybox is available on the market: https://market.android.com/details?id=stericson.busybox&feature=search_result
I'm not sure if that's what you're looking for, but there it is if you need it
I have the same problem even after installing the most recent busybox.
$
$ mkdir
mkdir: no such tool
$
$ echo $PATH
/data/local/bin:/sbin:/system/sbin:/system/bin:/system/xbin
$
$ /system/xbin/mkdir
BusyBox v1.19.0.git.adrynalyne (2010-12-21 22:03:30 MST) multi-call binary.
Usage: mkdir [OPTIONS] DIRECTORY...
Create DIRECTORY
Options:
-m MODE Mode
-p No error if exists; make parent directories as needed
$
as a workaround use /system/xbin/mkdir
janosik47 said:
I have the same problem even after installing the most recent busybox.
$
$ mkdir
mkdir: no such tool
$
$ echo $PATH
/data/local/bin:/sbin:/system/sbin:/system/bin:/system/xbin
$
$ /system/xbin/mkdir
BusyBox v1.19.0.git.adrynalyne (2010-12-21 22:03:30 MST) multi-call binary.
Usage: mkdir [OPTIONS] DIRECTORY...
Create DIRECTORY
Options:
-m MODE Mode
-p No error if exists; make parent directories as needed
$
as a workaround use /system/xbin/mkdir
Click to expand...
Click to collapse
Can you please explain how you run the above command? I always get mkdir : no such tool and I'm not clear how you ran the above command.

[MOD] v0.3.1 Working Full Ubuntu for 1.5.7 and 1.8.3 based on Sogarth's script

Sogarth's webtop2sd will be released soon, you really should wait and install that instead of this! Thanks -The Management
No longer breaks on 1.83, thanks to Romracer
Update: This script worked on my phone. Mind you I was installing it from a fresh SBF flash, but it should work on your phone too. Absolutely no guarantees as usual.
Update 11th April 2011, 06:59 PM: Won't be getting CWM package because it'd be huuuuuuuuuge.
Update 28th April 2011. 16:38 PM: Removing BETA tag since there have been no issues with the script for quite some time.
First off I would like to thank Sogarth for making this script in the first place as well as Romracer for fixing it for 1.83. Since he is busy doing more important work I decided to do this little hack for those of us that updated to 1.5.7 and dont feel like flashing back to earlier versions to get full Ubuntu working.
Again, this is only necessary if you're already running 1.5.7 or 1.8.3.
Secondly, I am still working on this script so it may not work for you. If you have a problem you may post in the thread or PM me showing exactly the error message, word for word, that you receive.
Updates will be included in the OP from time to time as I fix errors.
Instructions:
1) install.bat (from your computer)
2) adb shell (get a shell on your phone)
3) su (get root on your phone in that shell)
4) . /data/local/tmp/install.sh (run the install script *on your phone* don't forget the "." and the space after the dot, or you will have to chmod 755 the shell script manually)
5) ?????
6) profit\
Noob instructions, written by Viamonte (I take no credit or responsibility):
Thanks again for all your help. Now the noob instructions:
"1-Download "Terminal Emulator" from the market, on your phone (or any other terminal), and the file anexed in this thread to your computer.
2-Connect the Atrix to the computer via USB, configuring the connection mode to "None" and enabling USB Debugging mode (Settings>Applications>Development>USB debugging)
3-Unzip the file you downloaded on your pc, and run Install.bat. This will push the script to your phone.
4-Go back to your phone and open the emulator you downloaded. Then type "su" (without quotes) and press enter. Then type ". /data/local/tmp/install.sh" (without quotes) and press enter again.
The script should begin running now. It will stop in two moments where you'll be instructed to get a cup of coffee, and may take several minutes to continue form this point. When finished, the Atrix will reboot.
To check if this worked, use the Webtop either on your multimidia dock or your lapdock and verify if new itens appeared on your task bar and on the right upper side of the screen"
0.3.1 release
0.2 release
0.1 first release
Changelog
0.3.1 fix to gconf file's mdate so it does what its supposed to do =)
0.3 Small typo fixes and cpp package install fix by romracer, now works on 1.83 =)
0.2 Fixed some typos in uninstall.sh and make sure the %gconf file wound up in the right spot.
0.1 - first version. NOT CWM install but ready to be packaged for that more or less
Nice, I'll give this a shot later.
Ill give it a shot when I get home!
Sent from Motorola Atrix on TELUS.
My phone is working perfectly, so why not ruin it?
I'm giving this a try right now!
1.4.57 - Rooted and gingerblurred with HDMI Mirroring and Webtop hack.
I'll update as progress goes along:
Edit 1:
Initial try gave me this
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] y
Mounting the filesystem...
07.sh
--------------------------------------------
EXECUTION FAILED
Unable to mount the filesystem file. ERR 07
--------------------------------------------
Press any key to continue . . .
Edit 2:
Ok, it doesnt work with resetting it. How about removing?
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] n
A filesystem file already exists. Delete it? [n] y
Deleting the filesystem file...
--------------------------------------
EXECUTION FAILED
Unable to delete the filesystem file.
--------------------------------------
Press any key to continue . . .
Edit 3:
Ok, only one option left then.
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] n
A filesystem file already exists. Delete it? [n] n
--------------------------------------------------------------------------
EXECUTION FAILED
The filesystem file already exists, but no operations have been selected.
--------------------------------------------------------------------------
Press any key to continue . . .
=====================================================================
Edit 4:
Since execution is failing I'm trying to find the problem. Using ADB Shell i tried to manually run the shell scripts and stumbled here:
(I tried chmod 777 @ 02.sh to see if that was the problem, no change is results)
# ls -l
...
...
-rwsr-sr-x shell shell 87 2011-04-06 12:13 03.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
-rwsr-sr-x shell shell 251 2011-04-06 12:04 01.sh
# pwd
pwd
/data/tmp/shell
# /data/tmp/shell/02.sh
/data/tmp/shell/02.sh
/data/tmp/shell/02.sh: not found
I had the same issue as flybob when I tried to run the script.
Sent from my MB860 using XDA Premium App
Good effort, but 1.57 changes how we have to run commands as root. On a normal linux box, I'm sure your methods would work fine, but we're not dealing with a normal su binary. You should look into doing this as CWM as opposed to .bat files. I had a hell of a time getting around the restrictions since the psneuter exploit was closed.
Ah, I did not think about that Ririal, thanks for the info. I am not familiar with CWM though.
Why is the /tmp directory in /data ? That would certainly cause every script to fail.
I'll look at this some more tonight.
Ririal said:
Good effort, but 1.57 changes how we have to run commands as root. On a normal linux box, I'm sure your methods would work fine, but we're not dealing with a normal su binary. You should look into doing this as CWM as opposed to .bat files. I had a hell of a time getting around the restrictions since the psneuter exploit was closed.
Click to expand...
Click to collapse
How about a shell script that we can run in terminal emulator ? and the output goes to screen and a log file for debug !
molotof said:
How about a shell script that we can run in terminal emulator ? and the output goes to screen and a log file for debug !
Click to expand...
Click to collapse
most of the script is now run by shell scripts, no reason you couldn't run them in the terminal emulator, just get the order right. There are also a few lines I didn't translate to shell so you'd have to enter them by hand.
In any case I'll keep working on this until Sogarth releases his version with union mounts =D
You might be interested to know this;
# cd /tmp
cd /tmp
# pwd
pwd
/data/tmp
# ls -l /tmp
lrwxrwxrwx root root 2011-04-09 14:47 tmp -> /data/tmp
I'll happily help with the script, i know tons of linux and got my Atrix ready to be bricked
flybob said:
You might be interested to know this;
# cd /tmp
cd /tmp
# pwd
pwd
/data/tmp
# ls -l /tmp
lrwxrwxrwx root root 2011-04-09 14:47 tmp -> /data/tmp
I'll happily help with the script, i know tons of linux and got my Atrix ready to be bricked
Click to expand...
Click to collapse
That's just a symlinked directory. I won't make a difference if you call either.
Yes, just replied to the previous question
Why is the /tmp directory in /data ? That would certainly cause every script to fail.
I'll look at this some more tonight.
Click to expand...
Click to collapse
However, why doesn't the scripts run as wanted...?
# cat /tmp/shell/02.sh
cat /tmp/shell/02.sh
#!/bin/sh
/system/bin/su
/bin/rm /data/ubuntu.disk > /dev/null 2>&1 && echo PASS#
# ls -l /tmp/shell/02.sh
ls -l /tmp/shell/02.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
# /tmp/shell/02.sh
/tmp/shell/02.sh
/tmp/shell/02.sh: not found
flybob said:
Yes, just replied to the previous question
However, why doesn't the scripts run as wanted...?
# cat /tmp/shell/02.sh
cat /tmp/shell/02.sh
#!/bin/sh
/system/bin/su
/bin/rm /data/ubuntu.disk > /dev/null 2>&1 && echo PASS#
# ls -l /tmp/shell/02.sh
ls -l /tmp/shell/02.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
# /tmp/shell/02.sh
/tmp/shell/02.sh
/tmp/shell/02.sh: not found
Click to expand...
Click to collapse
Ah ok my mistake, you didn't quote anything I didn't realize that's what you were responding too
Likely noexec flag causing that issue.
Also, you can't invoke su from inside a shell script. It just doesn't work with this su binary.
yeah, I guess not. I hadn't realized that it wasn't a real 'su' before making this... too bad.
If anyone figures out how to get around that we'll be in business Unfortunately that's way beyond my expertise.
Okay, after fiddling a little bit and talking to a friend I may have solved some of the problems, mainly with the scripts executing and su working.
I will have to rewrite a bunch of things but should report back tonight.
the2dcour said:
Okay, after fiddling a little bit and talking to a friend I may have solved some of the problems, mainly with the scripts executing and su working.
I will have to rewrite a bunch of things but should report back tonight.
Click to expand...
Click to collapse
su -c "command"
You'll have to allow superuser on the phone for every single command.
PM'd you my error. I tried manually editing the permissions, but that didn't work.
Running on GladAtrix2 v3
USB debugging on; USB set to none
Checking device state...
Obtaining temporary root access...pushing shell scripts
-------------------------
EXECUTION FAILED
Unable to chmod scripts.
-------------------------
Press any key to continue . . .
Changed /sdcard-ext to /sdcard in script. Got this error
Checking device state...
Obtaining temporary root access...pushing shell scripts
-------------------------
EXECUTION FAILED
Unable to chmod scripts.
-------------------------
* server not running *
Press any key to continue . . .
Running BETA_ubuntu-1.0.6.4.zip. File extracts to BETA_ubuntu-1.0.6.2 directory. Ran ubuntu-1.5.7.bat
Moved BETA_ubuntu-1.0.6.2 to C:\ Same error
The only easy workaround to that I can see at the moment is to
Code:
adb shell
su
chmod 777 /path-to-scripts/*
ls -l /path-to-scripts/*
make sure all the files are executable (should say rwxrwxrwx)
then remove the bit of code from 1.5.7.bat
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/bin/chmod 6755 /mnt/sdcard-ext/shell/* > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
If anyone can help me fix this problem I should be able to automate the chmod process using ririal's suggestion of su -c. The problem is that there are too many nested quotation marks in this section of the batch file, and I can't for the life of me figure out how to escape quotes so they pass through to adb:
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/system/bin/su -c [U]'/bin/chmod 6755 /mnt/sdcard-ext/shell/*'[/U] > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
The underlined bit is where I need to escape either single or double quotes.
the2dcour said:
The only easy workaround to that I can see at the moment is to
Code:
adb shell
su
chmod 777 /path-to-scripts/*
ls -l /path-to-scripts/*
make sure all the files are executable (should say rwxrwxrwx)
then remove the bit of code from 1.5.7.bat
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/bin/chmod 6755 /mnt/sdcard-ext/shell/* > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
If anyone can help me fix this problem I should be able to automate the chmod process using ririal's suggestion of su -c. The problem is that there are too many nested quotation marks in this section of the batch file, and I can't for the life of me figure out how to escape quotes so they pass through to adb:
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/system/bin/su -c [U]'/bin/chmod 6755 /mnt/sdcard-ext/shell/*'[/U] > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
The underlined bit is where I need to escape either single or double quotes.
Click to expand...
Click to collapse
^ escapes batch, \ escapes shell. Hope this helps. If you zip up and send me the whole process in a single .sh file I can wrap it up in CWM for you.

[MOD] Full Linux (Debian) inside WebTop! v0.2.7 [2012/01/18] [11.30 GMT+2:00]

[size=+4]Take back WebTop![/size]​
Use anythings you can imagine! LibreOffice, Java, Firefox 4, ecc...
[size=+2]WHAT THIS MOD DOES:[/size]
Installing WebTopMOD your awm dock will be populated with 3 new icons: leafpad, lxterminal and a penguin.
Leafpad and lxterminal works inside WebTop but clicking on the penguin you get a Debian menu chrooted http://en.wikipedia.org/wiki/Chroot in a Debian enviroment. In xterm you can use synaptic and apt-get to install anything in this new enviroment.
For example I need gimp:
Code:
# apt-get update //refresh packages list from internet
# apt-get install gimp
# gimp //
Clicking another time on the penguin open another xterm IN THE SAME ENVIROMENT so I can start another program
Code:
# oo-writer //openoffice writer
NOTE: Debian disk contain a Debian stable (squeeze) release, some software could be "outdated", if you would live on the edge change stable to unstable in /etc/apt/sources.list IN CHROOT ENVIRONMENT. DO NOT TRY TO CHANGE REPOSITORY IN ORIGINAL WEBTOP ROOT
Look here (http://www.debian.org/releases/) to understand what differ between Debian branches
For example LibreOffice is not yet in stable branch, so you can install OpenOffice or switch repo to testing or unstable
Firefox is renamed Iceweasel and the latest version in unstable is 3.5 and from experimental 4.0.
REMEMBER THAT 0.x VERSION MEAN THAT THIS SOFTWARE CAN BE BUGGED AND I CONSIDER IT IN ALPHA TESTING
[size=+2]PREREQUISITES:[/size]
- A rooted Atrix
- At least 2GB free in internal memory (could be more or less with the customized installation)
- A little bit terminal knowledge and willpower
- Brain
- Liquorice mojito
[size=+2]INSTALLATION:[/size]
[size=+1][1st way - EASY METHOD][/size]
Prerequisite for this method is:
On your phone: CWM installed
0) Download Debian disk - http://droid.makrit.net/WebTopMOD/WebTopMOD-20110707.7z
1) Unpack in your internal or external storage (path should be /sdcard(-ext)/WebTopMOD/linuxdisk)
Please don't use "adb push" it corrupt big files
2) Download easy-signed.zip - http://www.multiupload.com/C5GEIHDEM0, MIRROR
3) Install using CWM, reboot and enter in WebTop!
Uninstaller for version >=0.2.7 http://www.multiupload.com/18H5OHND90, MIRROR
Uninstaller for version <= 0.2.2 http://www.multiupload.com/W37DT6HJ7X
Uninstaller for version 0.2.1 http://www.multiupload.com/TO6W9X7CBU
Uninstaller for version >= 0.2 http://www.multiupload.com/GLKUZA2KP9
[size=+1][2nd way - CUSTOM METHOD][/size]
Temporary deprecated
Code:
Prerequisite for this method is:
On your computer: have a Debian installation or a Debian live cd or download this file ([url]http://www.multiupload.com/403F0OQEDA[/url] -> 2GB disk in 66MB), unpack it and skip to step 8
On your phone: install a "complete" busybox thought any free market apps and be connected to internet with a wireless network.
[b][On your phone][/b]
0) Start WebTop and leave it opened
[b][On your computer][/b]
1) Create a file with the dimensions that fit your needs using dd (I used this command to create the 2GB file: dd bs=1024 count=1 seek=$((1024*1024*2-1)) if=/dev/zero of=debian)
2) Format the new "disk" using ext3 (mkfs.ext3 debian)
3) Create a folder to mount the disk (mkdir temp)
4) Mount the disk (sudo mount -t ext3 -o loop debian temp)
5) Debootstrap! (sudo debootstrap --foreign --arch armel stable temp [url]http://ftp.debian.org/debian[/url])
6) Wait...
7) Unmount disk (sudo umount temp) and remove temp directory (rmdir temp)
8) Copy debian in your internal storage inside a folder called "DEBIAN" (uppercase without quotes)
[b][On your computer if you are using adb (recommended) or on your phone using terminal emulator, connectbot, ecc)][/b]
9) Open a terminal and type:
Get superuser permissions
[code]
# su
edit sudoers
Code:
# vi /etc/sudoers
You should add "%admin ALL=NOPASSWD: ALL" after the line containing "%admin ALL=(ALL) ALL". You can try typing this:
Please note that if you are using a terminal emulator on your phone escape is bad interpreted by Android using a physical keyboard, you have to send the escape key in another way.
Code:
GkyyPjwwwld3wi
NOPASSWD: [with a space]
[Escape]
:wq!
Now we enter in a more complete and privileged bash
Code:
# /usr/bin/sudo -H -u adas bash
Enable AWM to launch anything
Search→Go To… line 1317
Take this line:
use_profile 3
and turn it into:
use_profile 2
Code:
sudo leafpad /etc/tomoyo/domain_policy.conf
Now you can add any launcher to your AWM, look in easy-signed.zip (/usr/share/applications and /home/michele/easy/home/adas/.gconf/apps/avant-window-navigator)
Mount debian disk:
Code:
# cd /sdcard/DEBIAN
# mkdir root
# sudo mount -t ext3 -o loop=/dev/block/loop7 debian root
Debootstrap! (second stage)
Code:
# sudo chroot root /debootstrap/debootstrap --second-stage
Disable X ACL (in WebTop)
Code:
# export DISPLAY=:0
# xhost +
Enter in the new system
Code:
# sudo cp /etc/hosts /sdcard/DEBIAN/root/etc/hosts
# sudo cp /etc/fstab /sdcard/DEBIAN/root/etc/fstab
# sudo cp /etc/resolv.conf /sdcard/DEBIAN/root/etc/resolv.conf
# sudo mount -o bind /proc /sdcard/DEBIAN/root/proc
# sudo mount -o bind /dev /sdcard/DEBIAN/root/dev
# sudo mount -o bind /dev/pts /sdcard/DEBIAN/root/dev/pts
# sudo mount -o bind /dev/shm /sdcard/DEBIAN/root/dev/shm
# sudo mount -o bind /sys /sdcard/DEBIAN/root/sys
# sudo mount -o bind /var/run/dbus/ /sdcard/DEBIAN/root/var/run/dbus/
# sudo chroot /sdcard/DEBIAN/root /bin/bash
Export X display (in chroot)
Code:
# export DISPLAY=:0
Add Debian main repository
Code:
# echo "deb http://ftp.debian.org/debian/ stable main non-free contrib" > /etc/apt/sources.list
Finish debian installation
Code:
# apt-get update ; apt-get install dbus dialog locales
Configure your locale
Code:
# dpkg-reconfigure locales
Install xterm
Code:
# apt-get install xterm
Run xterm!
Code:
# xterm
Now you can install anything simply using "apt-get install PROGRAM_NAME" or installing synaptic
Before unplug HDMI cable you should exit form chroot environment and unmount the chroot:
Code:
# exit
# sudo umount /sdcard/DEBIAN/root/proc
# sudo umount /sdcard/DEBIAN/root/dev
# sudo umount /sdcard/DEBIAN/root/dev/pts
# sudo umount /sdcard/DEBIAN/root/dev/shm
# sudo umount /sdcard/DEBIAN/root/sys
# sudo umount /sdcard/DEBIAN/root/var/run/dbus
# sudo umount /sdcard/DEBIAN/root
[size=+2]USE:[/size] (ONLY FOR CUSTOM METHOD)
[On your computer if you are using adb or on your phone using terminal emulator, connectbot, ecc)]
9) Open a terminal and type:
Get superuser permissions
Code:
# su
Now we enter in a more complete and privileged bash
Code:
# /usr/bin/sudo -H -u adas bash
Mount debian disk:
Code:
# cd /sdcard/DEBIAN
# sudo mount -t ext3 -o loop=/dev/block/loop7 debian root
Disable X ACL (in WebTop)
Code:
# export DISPLAY=:0
# xhost +
Enter in the new system
Code:
# sudo cp /etc/hosts /sdcard/DEBIAN/root/etc/hosts
# sudo cp /etc/fstab /sdcard/DEBIAN/root/etc/fstab
# sudo cp /etc/resolv.conf /sdcard/DEBIAN/root/etc/resolv.conf
# sudo mount -o bind /proc /sdcard/DEBIAN/root/proc
# sudo mount -o bind /dev /sdcard/DEBIAN/root/dev
# sudo mount -o bind /dev/pts /sdcard/DEBIAN/root/dev/pts
# sudo mount -o bind /dev/shm /sdcard/DEBIAN/root/dev/shm
# sudo mount -o bind /sys /sdcard/DEBIAN/root/sys
# sudo chroot /sdcard/DEBIAN/root /bin/bash
Export X display (in chroot)
Code:
# export DISPLAY=:0
Run xterm!
Code:
# xterm
Before unplug HDMI cable you should exit form chroot environment and unmount the chroot:
Code:
# exit
# sudo umount /sdcard/DEBIAN/root/proc
# sudo umount /sdcard/DEBIAN/root/dev
# sudo umount /sdcard/DEBIAN/root/dev/pts
# sudo umount /sdcard/DEBIAN/root/dev/shm
# sudo umount /sdcard/DEBIAN/root/sys
# sudo umount /sdcard/DEBIAN/root
[/code]
[size=+2]THANKS TO:[/size]
Sogarth - for http://forum.xda-developers.com/showthread.php?t=983208
kennethpenn - for motoblur remove tool! many many thanks!
Chainfire - for Gingerbreak
makr8100 - for http://droid.makrit.net/ mirror
and many other users that works actively to hack this phone!
[size=+2]NOTE:[/size]
- exporting library you can start a lot of programs without starting chroot (obviously mounting the loop device), for example you can use xterm inside WebTop launching
Code:
# LD_LIBRARY_PATH=.:/sdcard/DEBIAN/root/usr/lib /sdcard/DEBIAN/root/usr/bin/xterm
- you can use sd-card replacing /sdcard/DEBIAN to /sdcard-ext/DEBIAN
If you would like to support my work click the this droid
[size=+2]MANY THANKS FOR CONTRIBUTOR:[/size]
Francisco Bravo
Robert Johnson
[size=+2]CHANGELOG:[/size]
v0.2.7 [2012/01/18] [11.30 GMT+2:00]
easy-signed: http://www.multiupload.com/C5GEIHDEM0
uninstaller: http://www.multiupload.com/18H5OHND90
EASY:
- Disabled Tomoyo (no more firefox issues between different webtop versions)
- New uninstaller
v0.2.6 [2011/07/07] [14.15 GMT+2:00]
Debian disk: http://droid.makrit.net/WebTopMOD/WebTopMOD-20110707.7z
easy-signed: http://droid.makrit.net/software/atrix/easy_v0.2.6.zip-signed.zip
EASY:
- binded in chroot tmp folders
- correct typo in missing disk message
- changed umount function (should works fine now!)
- added linuxdisk check (0 size, is a file)
- 2.3.4 compatibility
- cleaned mount function
LINUXDISK:
- added pdmenu and menu
- added device etc mountpoint in /mnt/DEVICE/etc
- dynamic change of resolv.conf (thanks to krkeegan)
- linuxdisk now is ~4gb (4095MB)
- added device etc mountpoint in /mnt/DEVICE/usr
- added plugins folder symlink to use flash player or other plugins between browser (inside and outside chroot) (FLASH DOESN'T WORK YET)
v0.2.5.1b [2011/07/07] [10.15 GMT+2:00]
Debian disk: unmodified
easy-signed: http://www.multiupload.com/ZAPZW2XX45
EASY:
- removed firmware check
- using a newer version of update-binary
v0.2.5 [2011/05/27] [9.30 GMT+2:00]
Debian disk: unmodified
easy-signed: http://www.multiupload.com/F68D73KF26
EASY:
- fixed unmount function
- removed motorola links
- fixed leafpad icon
v0.2.4 [2011/05/26] [20.30 GMT+2:00]
Debian disk: unmodified
easy-signed: http://www.multiupload.com/VI4JEFWLI6
EASY:
- corrected calls to loopdevice function (thanks Cryofix)
- check awm folders existence and fully reset permissions
- set different permissions to linux script, xmessage, lxterminal and WebTopMOD folder
v0.2.3 [2011/05/26] [15.45 GMT+2:00]
Debian disk: unmodified
easy-signed: http://www.multiupload.com/2JAO6F42Z4
EASY:
- corrected typo (remember..) in installation
- make new loop device (avoid conflict)
- renfoced unmount function
- fix permission for linux.desktop (awm launcher)
v0.2.2 [2011/05/25] [22.00 GMT+2:00]
Debian disk: http://www.multiupload.com/DVF6BJGJR3
easy-signed: http://www.multiupload.com/NKSFL81ODW
EASY:
- removed /mnt/androidroot (doesn't work)
- added /mnt/sdcard and /mnt/sdcard-ext
- code clean
- corrected lxterm policy
- replaced backup script
- corrected sudoers replace
- replaced debian with a more generic linux notation
- added check disk existence
- disk can be in sdcard or sdcard-ext
CUSTOM:
- Temporary deprecated (I've no time to update it today)
v0.2.1 [2011/05/25] [10.30]
DebianEnabler: http://www.multiupload.com/F8TMHY8VQA
Images: 2gb: http://www.multiupload.com/A1B6LG9YYF
easy-signed.zip: http://www.multiupload.com/HPA820KCKR
EASY:
- replaced xterm with native lxterminal
- introduced backup original files
- added uninstaller for version >= 0.2 http://www.multiupload.com/GLKUZA2KP9
- added uninstaller for version <= 0.2.1 http://www.multiupload.com/TO6W9X7CBU
v0.2 [2011/05/24] [17.30]
EASY:
DebianEnabler: http://www.multiupload.com/F8TMHY8VQA
Images: 2gb: http://www.multiupload.com/A1B6LG9YYF
easy-signed.zip: http://www.multiupload.com/NHJGJD7E3E
- easy method!
- symbolic link in /mnt/androidroot to real root
- added image already configured with dbus, locales and dialog
- added launcher for debian chroot and xterm in awm
CUSTOM:
- added instruction to make custom launcher in awm
- added instruction to configure locales, dbus and dialog
- corrected chroot adding /var/run/dbus
v0.1 [2011/05/24]
- initial release
Pro. This looks like the real deal (no compromises). I will be waiting for the noob version though
Sent from my MB860 using XDA Premium App
What versions does this work with? 1.8.3, 1.5.7, 1.2.6 ?
XxKILLx3RxX said:
What versions does this work with? 1.8.3, 1.5.7, 1.2.6 ?
Click to expand...
Click to collapse
I used an ATT Atrix with 1.8.3 firmware.
However this guide should be applicable to any atrix (att, bell, ecc) with any firmware...
Can i use ubuntu as the debian system on the pc to do the image, secondly how do i make a 4 or even 6 gb image, thirdly is this similar to the chroot modes?
crnkoj said:
Can i use ubuntu as the debian system on the pc to do the image, secondly how do i make a 4 or even 6 gb image, thirdly is this similar to the chroot modes?
Click to expand...
Click to collapse
6gb:
Code:
dd bs=1024 count=1 seek=$((1024*1024*6-1)) if=/dev/zero of=debian
5gb:
Code:
dd bs=1024 count=1 seek=$((1024*1024*5-1)) if=/dev/zero of=debian
4gb:
Code:
dd bs=1024 count=1 seek=$((1024*1024*4-1)) if=/dev/zero of=debian
3gb:
Code:
dd bs=1024 count=1 seek=$((1024*1024*3-1)) if=/dev/zero of=debian
1gb:
Code:
dd bs=1024 count=1 seek=$((1024*1024*1-1)) if=/dev/zero of=debian
debootstrap from ubuntu
Code:
sudo apt-get install debootstrap
sudo debootstrap --foreign --arch armel squeeze temp http://ftp.debian.org/debian
Thanks man, ill go and try it out within the next few hours. Btw i already have lxterminal working in the webtop, can i use that instead of adb/ terminal emulator to enter those commands?
crnkoj said:
Thanks man, ill go and try it out within the next few hours. Btw i already have lxterminal working in the webtop, can i use that instead of adb/ terminal emulator to enter those commands?
Click to expand...
Click to collapse
Sure! I assumed that on 1.8.3 terminal is not available...
SystemR89 said:
Sure! I assumed that on 1.8.3 terminal is not available...
Click to expand...
Click to collapse
ye thats true, i copied it over from an old /osh dump and it seems to work fine, if you want/need it i can send it to you (only the lxterminal or the whole /osh dump) just started the procedures to get it on.
SystemR89 said:
6gb:
Code:
dd if=/dev/zero of=/data/6GB.swap bs=1024 count=6144000
4gb:
Code:
dd if=/dev/zero of=/data/6GB.swap bs=1024 count=4096000
debootstrap from ubuntu
Code:
sudo apt-get install debootstrap
sudo debootstrap --foreign --arch armel squeeze temp http://ftp.debian.org/debian
Click to expand...
Click to collapse
those commands returned the error:
dd: opening '/data/6GB/swap': No such file or directory
hmm in your first post the one for dding a 2gb file is different as these two.
AWESOME!!
You beat me to it!! I just ordered a Atrix and it's enroute to me over here in Japan... I was thinking I would try to build Gentoo on the webtop somehow.
I have experience there doing the whole bootstrapping thing, but then it hit me-- "How will I compile the programs?" since everything gets made from source and not from RPMs or DEBs in that distro.
Now I am totally chomping at the bit for my Atrix to get here; I am going to experiment using it as my ONLY computer at work, and out and about. I tend to use cloud-based apps even when creating content (I'm a teacher/photographer/web developer) and I feel uneasy about taking my loaded-to-the-gills Macbook on crowded Tokyo trains with me everyday.
Now with your find, I can still manage to do some light graphics work at times in GIMP too maybe?
crnkoj said:
those commands returned the error:
dd: opening '/data/6GB/swap': No such file or directory
hmm in your first post the one for dding a 2gb file is different as these two.
Click to expand...
Click to collapse
ops.. you are right.. corrected!
starrwulfe said:
Now with your find, I can still manage to do some light graphics work at times in GIMP too maybe?
Click to expand...
Click to collapse
I've not tried gimp, but it should works, we have 1gB of ram!
I was thinking how great gentoo would be too. kholk said once he manages to get kexec and a custom kernel to work he will start work for on gentoo to replace the webtop, that ought to be awesome than
Cannot wait to give this a shot! I just need to order a blue tooth mouse and keyboard.
SystemR89 said:
ops.. you are right.. corrected!
Click to expand...
Click to collapse
ya thought so to just change to debian, btw why do you say if in ubuntu you use the squeeze tag and if just debian you use the stable tag when doing the debootstrap?
crnkoj said:
ya thought so to just change to debian, btw why do you say if in ubuntu you use the squeeze tag and if just debian you use the stable tag when doing the debootstrap?
Click to expand...
Click to collapse
I'm not sure that stable tag works with ubuntu..
Wow amazing I will try when I can, will be funny or nice if we can connect the display to a chinese tablet xD so we can get a portable display xD
.......................................................
Sent from my loved atrix ;D
update.zip, multiple size disk and terminal-less installation and usage will be ready in the next hours!
Stay tuned!

Ubuntu on Ideos X6

There are threads on this site and elsewhere showing the steps to boot ubuntu on android phones. Our Ideos X6 comes with a powerful hardware so i believe we can run ubuntu on it. But it seems that the kernel must support loop devices. Can anyone make a custom kernel supporting loop devices.
Or has anyone successful in running Ubuntu on Ideos X6.
Our kernel have support for loop device. Take this little instruction how install ubuntu oneiric, also the same process for debian just write distribution name and correct url in debootstrap.
1. this stage you must complete on your linux pc.
Code:
#debootstrap part on PC
sudo apt-get install debootstrap
sudo dd if=/dev/zero of=ubuntu.img seek=838860800 bs=1 count=1
sudo mke2fs -F ubuntu.img
sudo mkdir ubuntu
sudo mount -o loop ubuntu.img ubuntu/
sudo debootstrap --arch armel --foreign oneiric ubuntu http:/ports.ubuntu.com/ubuntu-ports/
sudo umount ubuntu
sudo rm -r ubuntu
2. push this ubuntu.img to sdcard on your phone.
Code:
adb push ubuntu.img /sdcard/ubuntu.img
3. create this script as ubuntu.sh on your sdcard too
Code:
echo "Setting some stuff up.."
export bin=/system/bin
export img=/mnt/sdcard/ubuntu.img
export mnt=/data/local/ubuntu
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
mkdir $mnt
echo "Mounting the Linux Image"
busybox losetup /dev/block/loop7 $img
mount -t ext2 -o noatime,nodiratime /dev/block/loop7 $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
echo "Setting Up Networking"
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "Mounting sdcard in /mnt"
mkdir $mnt/mnt/sdcard
busybox mount --bind /mnt/sdcard/ $mnt/mnt/sdcard
echo "Entering CHROOT "
echo " "
busybox chroot $mnt /bin/bash
echo " "
echo "Shutting down CHROOT"
umount $mnt/mnt/emmc
umount $mnt/mnt/sdcard
busybox sysctl -w net.ipv4.ip_forward=0
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
busybox losetup -d /dev/block/loop7
4. So now we connect to device, run superuser permission, and chroot to ubuntu
Code:
sudo adb shell
su
sh /sdcard/ubuntu.sh
5.run continue deboostrap
Code:
/debootstrap/debootsrap --second-stage
6. setup apt
Code:
echo 'deb http:/ports.ubuntu.com/ubuntu-ports/ oneiric main' >/etc/apt/sources.list
apt-get clean
apt-get update
7. add root password
Code:
passwd root
8. exit from ubuntu shell with 'exit' and run it again sh /sdcard/ubuntu.sh from terminal emulator on your device or via adb shell.
So, now ubuntu install successfully on your phone and you may install openssh and vnc server.
P.S. http:/ correct it with two //, I can't push correct link to forum. its denied post urls.
Error
I followed your steps exactly as given and changed / to // in http i am getting the following output when i ran ubuntu.sh. kindly help
# sh ubuntu.sh
Setting some stuff up..
mkdir failed for /data/local/ubuntu, File exists
Mounting the Linux Image
losetup: /dev/block/loop7
mount: Device or resource busy
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
Setting Up Networking
net.ipv4.ip_forward = 1
ubuntu.sh: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
ubuntu.sh: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
ubuntu.sh: cannot create /data/local/ubuntu/etc/hosts: directory nonexistent
Mounting sdcard in /mnt
mkdir failed for /data/local/ubuntu/mnt/sdcard, No such file or directory
mount: mounting /mnt/sdcard/ on /data/local/ubuntu/mnt/sdcard failed: No such file or directory
Entering CHROOT
chroot: can't execute '/bin/bash': No such file or directory
Shutting down CHROOT
failed.
failed.
net.ipv4.ip_forward = 0
failed.
failed.
failed.
failed.
losetup: /dev/block/loop7: Device or resource busy
Possbile what loop7 device already busy on your phone.
ry this command to see it
Code:
busybox losetup
And try manual steps which in script to see which step is failed.
When I type
Code:
#busybox losetup
nothing happens
when i type
Code:
#busybox losetup /dev/block/loop7 /mnt/sdcard/ubuntu.img
losetup: /dev/block/loop7
Code:
#mount -t ext2 -o noatime,nodiratime /dev/block/loop7 /data/local/ubuntu
mount: Device or resource busy
the second line is the outputfrom the command.
Do you phone have block devices in /dev/block/ ?
just checked using root explorer. there are many loop# files in /dev/block folder
You may try with UC kernel, or try with ext3 file system. I suppose what your kernel without support ext2.
i tried with UC v5. It supports ext2,ext3 and ext4. Still getting same error.
Should i convert my android filesystem to ext2,3,0r 4. If yes how to do it?
No, you don't need do converting. Problem with loop device or mount, try to see busybox losetup after mount image to block device, it's must show what image mounted to block device. If it's ok, try different option for mount.
I don't have anymore ideas why it doesn't work.
This scenario successful work on my phone.
Can you tell me what ROM you are using
Sent from my CSL-MI410 using XDA App
Last rom from wellcom (2.3-V318E)
now it works. Installed ubuntu. But i am now unable to install any package. when i try to install tightvncserver i get error message
E: Unable to locate package tightvncserver
actally i am not able to install any package
i have checked the /etc/apt/sourcels.list and it contains the required entry and i also did
apt-get clean
apt-get update
and it updates without any error
You need add another repositories to /etc/sources.list such as universe, multiverse, restricted with the same path.

[Q] Odex Script For User (/data/app) Apps :)

Dear bros and members here,
I want some script for using dexopt-wrapper to some location
Example: if there is file in (/sdcard/app)
then the script should prompt two request:
the first is the apk file name
and the other is the odex file name and should execute
dexopt-wrapper /sdcard/app/name.of.the.apk /sdcard/app/name.of.the.odex
Please, I want this in shell script
Here you are:
Code:
#!/system/bin/sh
# In the name of Allah
tmp=/data/local/tmp
mkdir $tmp > /dev/null 2>&1
BCP="`cat /init.rc | grep BOOTCLASSPATH`"
echo $BCP>$tmp/fbcp.txt
sed -e 's/export BOOTCLASSPATH //g' $tmp/fbcp.txt>$tmp/bcp.txt
BCP="`cat $tmp/bcp.txt`"
rm $tmp/fbcp.txt
rm $tmp/bcp.txt
echo "Please enter the name of app to odex:"
echo "Example: Browser"
echo "--->"
read APP
if [ ! -f /sdcard/app/${APP}.apk ]; then
echo "Requested app not found."
echo "Please check the app name again."
else
dexopt-wrapper /sdcard/app/${APP}.apk /sdcard/app/${APP}.odex ${BCP}
zip -d /sdcard/app/${APP}.apk classes.dex
echo "Done!"
fi;
Sent from my E15i using Tapatalk 2
Ahmad.H said:
Here you are:
Code:
#!/system/bin/sh
# In the name of Allah
tmp=/data/local/tmp
mkdir $tmp > /dev/null 2>&1
BCP="`cat /init.rc | grep BOOTCLASSPATH`"
echo $BCP>$tmp/fbcp.txt
sed -e 's/export BOOTCLASSPATH //g' $tmp/fbcp.txt>$tmp/bcp.txt
BCP="`cat $tmp/bcp.txt`"
rm $tmp/fbcp.txt
rm $tmp/bcp.txt
echo "Please enter the name of app to odex:"
echo "Example: Browser"
echo "--->"
read APP
if [ ! -f /sdcard/app/${APP}.apk ]; then
echo "Requested app not found."
echo "Please check the app name again."
else
dexopt-wrapper /sdcard/app/${APP}.apk /sdcard/app/${APP}.odex ${BCP}
zip -d /sdcard/app/${APP}.apk classes.dex
echo "Done!"
fi;
Sent from my E15i using Tapatalk 2
Click to expand...
Click to collapse
Thanks a lot bro!
There's a syntax error.
I type in the terminal and output is looked like this
/sdcard/odex.sh: 4: Syntax error: Bad fd number
anyway, I fix it to
line 4: mkdir $tmp > /dev/null 2&>1
but it still doesn't work..
Many errors in shell script.. Please test it and correct something.. Please bro..
I really like your script if it would be executable because it has classes.dex delete function..
Thanks

Categories

Resources