
Originally Posted by
JuanGil
well I decided to give a try and did this one. :
#!/bin/bash
cd /system/sd
mkdir cache
cd /system/sd/cache
mkdir files
(snip nearly identical lines)
dont know if is working yet
You don't need to cd to a directory to make a symbolic link; you can say "ln -s /some/dir/somewhere /new/dir/elsewhere"
Additionally you have a lot of repeated commands. A nicer idea would be to wrap those commands in a function:
Code:
function relocateCache()
{
OLD_CACHE_DIR=$1
NEW_CACHE_DIR=$2
mkdir $NEW_CACHE_DIR
cp -R $OLD_CACHE_DIR $NEW_CACHE_DIR
rm -rf $OLD_CACHE_DIR
ln -s $NEW_CACHE_DIR $OLD_CACHE_DIR
}
You can then say something like:
Code:
#!/system/bin/sh
...
relocateCache /data/data/com.myspace.android /system/sd/cache/files/myspace
...
edit: An even nicer idea would be sanity checks in the relocateCache function to make sure the OLD_CACHE_DIR exists before operating on it and the path to the NEW_CACHE_DIR exists.
Bookmarks