maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   miroroot.sh a script to clear rootfs has ruined my phone !! :( (https://talk.maemo.org/showthread.php?t=87383)

Ammar Hamdan 2012-10-13 09:16

miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
1 Attachment(s)
I found this ((((sh)))) script on a website, has codded to clear rootfs, but after using it ... I've noticed some widgets were disappeared .. and there are many bugs !!!

ps: this script made a folder called miroroot in this directory & contains two folders (var,usr) :

home/user/miroroot/


so what should I do to solve this problem :confused: :( :confused: :(

Dragoss91 2012-10-13 09:43

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
So what's the problem ?

1. That script deleted some system files ?
or
2. That script didn't delete all system files ?

Ammar Hamdan 2012-10-13 10:07

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
actually I think the script has deleted some unimportant system files & moved large files to this directory :

Code:

home/user/miroroot/

reinob 2012-10-13 13:52

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
@Ammar Hamdan,

You can either undo what the script has done (can be hard, but it is doable) OR completely reflash.

In view of your willingness to execute some script you found somewhere, I'd recommend the latter.

sifo 2012-10-13 16:03

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
1 Attachment(s)
This script edited by Amr.fayz you can find him here in Meecolay thread, anyway this is his script :
Code:

#!/bin/sh
# Miroroot script to safely free space on rootfs
# by Amr.fayz

if test "`id -u`" -ne 0; then
    echo "Error: This script must be run as root!"
    echo "Please make sure that the package rootsh from extras is installed"
    echo "and execute \"sudo gainroot\" and then \"$0\" in Terminal"
    exit 1
fi

echo rootfs before:
df -h /
chmod +x /home/Miroroot
chmod 775 /home/Miroroot
# move root stuff to /home/Miroroot
dirs="usr/share/icons usr/share/nokia-maps usr/share/fonts usr/share/locale usr/share/microb-engine usr/share/tutorial-applet usr/share/cherry usr/local/lib /usr/include usr/lib/locale usr/lib/microb-engine usr/lib/skyhost /usr/lib/browser/plugins usr/lib/pyshared/python2.5 usr/lib/python2.5/site-packages usr/lib/qt4/imports usr/lib/qt4/plugins usr/lib/debug/usr var/lib/dpkg var/lib/apt"
#optional: usr/share/themes  var/lib/dpkg
if test -d /home/var/cache/apt; then
  # keep existing apt cache
  rm -rf /var/cache/apt
  ln -s /home/var/cache/apt /var/cache/apt
else
  dirs="$dirs var/cache/apt"
fi
(cd / && du -sc $dirs)
for d in $dirs; do
    test -L /$d && continue
    echo moving /$d
    rm -rf /home/Miroroot/$d
    mkdir -p /home/Miroroot/$d
    cp -a /$d /home/Miroroot/$d/..
    mv /$d /$d.old
    ln -s /home/Miroroot/$d /$d
    rm -rf /$d.old
done
sync
echo "success"
echo "rootfs after (after a reboot the actual free space will be shown):"
df -h /

And here is the original copy of the script and i safely used it before (copyrights belongs to Thomas Tanner )
Code:

#!/bin/sh
# N900 script to safely free space on rootfs
# (c) 2010 by Thomas Tanner <maemo@tannerlab.com>
# licensed under GPLv3
# version 0.5 (16. May 2010)

if test "`id -u`" -ne 0; then
    echo "Error: This script must be run as root!"
    echo "Please make sure that the package rootsh from extras is installed"
    echo "and execute \"sudo gainroot\" and then \"$0\" in Terminal"
    exit 1
fi

echo rootfs before:
df -h /
# move root stuff to /home
dirs="usr/share/icons usr/share/nokia-maps usr/share/fonts usr/share/locale usr/lib/locale var/lib/apt"
#optional: usr/share/themes  var/lib/dpkg
if test -d /home/var/cache/apt; then
  # keep existing apt cache
  rm -rf /var/cache/apt
  ln -s /home/var/cache/apt /var/cache/apt
else
  dirs="$dirs var/cache/apt"
fi
(cd / && du -sc $dirs)
for d in $dirs; do
    test -L /$d && continue
    echo moving /$d
    rm -rf /home/$d
    mkdir -p /home/$d
    cp -a /$d /home/$d/..
    mv /$d /$d.old
    ln -s /home/$d /$d
    rm -rf /$d.old
done
sync
echo "success"
echo "rootfs after (after a reboot the actual free space will be shown):"
df -h /
#!/bin/sh
# N900 script to safely free space on rootfs
# (c) 2010 by Thomas Tanner <maemo@tannerlab.com>
# licensed under GPLv3
# version 0.5 (16. May 2010)

if test "`id -u`" -ne 0; then
    echo "Error: This script must be run as root!"
    echo "Please make sure that the package rootsh from extras is installed"
    echo "and execute \"sudo gainroot\" and then \"$0\" in Terminal"
    exit 1
fi

echo rootfs before:
df -h /
# move root stuff to /home
dirs="usr/share/icons usr/share/nokia-maps usr/share/fonts usr/share/locale usr/lib/locale var/lib/apt"
#optional: usr/share/themes  var/lib/dpkg
if test -d /home/var/cache/apt; then
  # keep existing apt cache
  rm -rf /var/cache/apt
  ln -s /home/var/cache/apt /var/cache/apt
else
  dirs="$dirs var/cache/apt"
fi
(cd / && du -sc $dirs)
for d in $dirs; do
    test -L /$d && continue
    echo moving /$d
    rm -rf /home/$d
    mkdir -p /home/$d
    cp -a /$d /home/$d/..
    mv /$d /$d.old
    ln -s /home/$d /$d
    rm -rf /$d.old
done
sync
echo "success"
echo "rootfs after (after a reboot the actual free space will be shown):"
df -h /

?

./sifo

reinob 2012-10-13 16:55

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
Quote:

Originally Posted by sifo (Post 1280098)
This script edited by Amr.fayz you can find him here in Meecolay thread, anyway this is his script :

The first script (the one by Amr.fayz) moves and symlinks a lot of directories that are not handled in the original script. That may be the cause of the problem.

Plus, the "Miroroot" folder is not created at the beginning of the script but the first time mkdir -p is used.

Nevertheless, the script does chmod +x and chmod 755 (which in itself makes me seriously doubt of the skills of this Amr.fayz) on that folder, before it is even created.

Don't want to blame anybody without being 100% but looking at the script my first thought would be "HANDS OFF", and *I* can read and write shell scripts and know my way around Unix. An inexperienced user should think "HANDS OFF" before even looking at the script.

Obviously the damage is reversible. By definition. But at least *I* will not do the hard work of reversing that. So either the original author of the script (Amr.fayz) comes to the rescue, or the OP does a complete reflash.

Ammar Hamdan 2012-10-15 15:04

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
thank u all 4 replies ... I doubt the author is alive to come to rescue :D ... I think he knew his script has bugs & cant find a solution or he's working on a solution to fix the bugs & need some time ... so there is no way except flashing my phone :(

J4ZZ 2012-10-16 06:59

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
I would sort everything via WinSCP.
Delete created symlinks and move all folders from home/user/miroroot/ (if it's actually present) back to /
Like reinob said the original script uses /home/ as destination (which is a system folder and already present) but the customized script wants to put everything into home/user/miroroot/ but forgot to create this folder.


;)

Ammar Hamdan 2012-10-16 12:35

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
@J4ZZ

I have a noob question :D :

how to delete created symlinks ??

pichlo 2012-10-17 11:56

Re: miroroot.sh a script to clear rootfs has ruined my phone !! :(
 
Quote:

Originally Posted by Ammar Hamdan (Post 1281209)
how to delete created symlinks ??

Symlinks are just like ordinary files, you delete them with rm.

For example, your script did (amongst others)(expanded and simplified from parsing the script):

Code:

mv /usr/share/icons /home/Miroroot/usr/share/icons
ln -s /home/Miroroot/usr/share/icons /usr/share/icons

What that did was move usr/share/icons from root to /home/Miroroot and then replacing the original with a symlink to the new location. To reverse the change, you need to remove the symlink first and then move the folder back to the original location, like this:

Code:

rm /usr/share/icons
mv /home/Miroroot/usr/share/icons /usr/share/icons

Doing it for the rest of the moved folders is left as an exercise :)

Do not be tempted to use rm -r though. That will delete not just the symlink but also recursively all the files and folders the symlink points to, thus screwing up your phone irreversibly with a reflash the only way back.

Before embaring on any of this, I strongly suggest to check the folders actually exist under /home/Miroroot. Both J4ZZ and reinob have already warned you about that.


All times are GMT. The time now is 02:09.

vBulletin® Version 3.8.8