Created
April 15, 2012 16:52
-
-
Save queeup/2393819 to your computer and use it in GitHub Desktop.
Modify OpenELEC SYSTEM squashfs filesytem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! $@ ]; then | |
echo "Need OpenELEC archive file. Exiting!" | |
exit 0 | |
fi | |
if [ ! `which mksquashfs` ]; then | |
echo "Your system doesn't seem to have squashfs-tools installed" | |
echo "You can install this package with:" | |
echo "sudo apt-get install squashfs-tools" | |
exit 1 | |
fi | |
FILE=${@%%.tar.bz2} | |
if [ ! -d /tmp/${FILE}_modified ]; then | |
echo "==============================================================" | |
echo "### extracting SYSTEM & KERNEL file from OpenELEC archive file" | |
tar -xjf $@ -C /tmp $FILE/target/SYSTEM | |
tar -xjf $@ -C /tmp $FILE/target/KERNEL | |
mv /tmp/$FILE/target/KERNEL /tmp/${FILE}_modified.kernel | |
echo " Done!" | |
echo "### mount OpenELEC SYSTEM squashfs filesystem" | |
sudo mkdir /mnt/$FILE | |
sudo mount /tmp/$FILE/target/SYSTEM /mnt/$FILE -t squashfs -o loop | |
echo " Done!" | |
echo "### copy squashfs filesystem to tmp folder" | |
sudo rsync -a /mnt/$FILE/ /tmp/${FILE}_modified/ | |
echo "### umount OpenELEC squashfs filesystem and clean tmp files." | |
sudo umount /mnt/$FILE | |
sudo rmdir /mnt/$FILE | |
rm -rf /tmp/$FILE | |
echo " Done!" | |
else | |
echo "!!!" | |
echo "/tmp/${FILE}_modified directory exist. Skipping squashfs extract/mount/clone." | |
echo "If you want new modify directory please write \"Clean\" and hit Enter for" | |
echo "erase /tmp/${FILE}_modified directory then rerun this script!" | |
echo "!!!" | |
fi | |
echo | |
echo "You can modify your extracted OpenELEC squashfs filesystem before make new squashfs!" | |
echo | |
echo "After you finish, write \"Done\" and press Enter for create new modifed squashfs filesystem!" | |
echo "Or just write \"exit\" for stop and cancel before creating new squashfs image!" | |
echo "For cleaning everthing and start over, write \"Clean\" and hit Enter" | |
echo "!!!NOTE: All command case sensitive and write it without quote(\")!!!" | |
while : | |
do | |
read INPUT_STRING | |
case $INPUT_STRING in | |
Done) | |
echo "### creating new OpenELEC squashfs filesystem" | |
sudo mksquashfs /tmp/${FILE}_modified /tmp/${FILE}_modified.system -noappend -comp gzip | |
sudo chown user:user /tmp/${FILE}_modified.system | |
chmod 0644 /tmp/${FILE}_modified.system | |
md5sum -t ${FILE}_modified.system > ${FILE}_modified.system.md5 | |
md5sum -t ${FILE}_modified.kernel > ${FILE}_modified.kernel.md5 | |
echo "### Finished!" | |
echo "new squashfs: /tmp/${FILE}_modified.system" | |
echo "==============================================================" | |
exit 0 | |
;; | |
Clean) | |
echo "### Cleaning everthing for starting over!" | |
sudo rm -rf /tmp/${FILE}_modified* | |
echo "### Exiting!" | |
echo "==============================================================" | |
exit 0 | |
;; | |
exit) | |
echo "### Exiting!" | |
echo "==============================================================" | |
exit 0 | |
;; | |
*) | |
echo "### Exiting!" | |
echo "==============================================================" | |
exit 0 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment