My phone’s bash.profile

Here is some automation that I put into my bash.profile. It’s all done with aliases, since with regular shell scripts, I would first have to remount /mnt/sdcard without ‘noexec’. Like this, I just need to open a ConnectBot “Local” connection, type the alias, and press enter(*).

(*) For this to work, the ‘post login automation’ entry of the ConnectBot “Local” profile needs to have
bash --rcfile /sdcard/bash.profile
in it.

Here is what I have in there:

alias bb="busybox"
alias top="bb top"
alias df="bb df"

alias ll="ls -l"
alias n="su -c \"netstat -ntupl\""

alias backupdata="su -c \"rsync -rP --delete --numeric-ids --chmod=u+rwX --exclude Music /sdcard/ pat@192.168.0.2:/data/pat/g2sd/\""

alias postflash="echo \"Mounting /system read-write\" && su -c \"mount -o rw,remount /system\" && echo \"Copying modified keyboard layout files...\" && su -c \"cp /sdcard/vision-keypad-wwe.kcm.bin /system/usr/keychars/\" && su -c \"cp /sdcard/vision-keypad-wwe.kl /system/usr/keylayout/\" && echo \"Deleting awful camera click sound...\" && su -c \"rm /system/media/audio/ui/camera_click.ogg\" && sync && echo \"All done. Please reboot now.\""

clear
uptime
echo

The first couple of aliases should be self-explanatory.
backupdata is, as the name suggests, to get my SD card’s content to my home server.
postflash is for after flashing a new ROM (usually a CyanogenMod nightly build). It gets my modified keyboard layout into place, and deletes the terrible sound file that gets played when I take a photo with the phone’s camera.

2 thoughts on “My phone’s bash.profile”

  1. Spiffy

    How would you use bash via cron (cron4phone) to poll sdcard mount and set back to R/W when it slides into R/O for indeterminate reasons…

    1. Hi,

      I don’t know whether it’s possible – and I’d probably try to track down the real issue – the drop to read-only mount. Maybe try another SD card? Or format it once, maybe it contains some uncorrectable filesystem errors. Check the logs whether you can find something, shortly after it happens.

      Patrick.

Leave a Reply

Your email address will not be published. Required fields are marked *