Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # The last version of this script is available at https://pastebin.com/Wm0yDd6x
- # Create two ext partitions with OPT1, OPT2 labels first, fix URL below if necessary
- #URL=http://bin.entware.net/mipselsf-k3.4/installer/mipsel-installer.tar.gz
- URL=http://bin.entware.net/aarch64-k3.10/installer/aarch64-installer.tar.gz
- echo -n '[1/5] Checking for OPT1 and OPT2 partitions... '
- OPT1=$(readlink /tmp/mnt/OPT1) && OPT2=$(readlink /tmp/mnt/OPT2)
- if [ $? -ne 0 ] ; then
- echo "I presume I've got two partitions labeled as OPT1 and OPT2."
- echo 'See you next time!'
- exit 1
- else
- echo 'done.'
- fi
- echo -n '[2/5] Detecting current /opt partition... '
- OPT_MPOINT=$(mount | grep ' /opt type ' | cut -d' ' -f1)
- OPT=$(mount | grep $OPT_MPOINT | grep ' on /tmp/mnt/' | cut -d' ' -f 3 | cut -d'/' -f 4)
- if [ -z "$OPT_MPOINT" ] || [ -z "$OPT" ]; then
- echo "Can't detect current /opt mountpoint. I'm too stupid for that, sorry."
- exit 1
- fi
- if [ "$OPT" = "$OPT1" ]; then
- echo 'done. Migrating from OPT1 to OPT2'
- SRC=$OPT1
- DST=$OPT2
- else
- echo 'done. Migrating from OPT2 to OPT1'
- SRC=$OPT2
- DST=$OPT1
- fi
- echo '[3/5] Cleaning up target partition... '
- rm -fr /tmp/mnt/$DST/*
- mkdir /tmp/mnt/$DST/root
- if [ $? -ne 0 ] ; then
- echo "Can't create destination folder, exiting."
- exit 1
- fi
- echo '[4/5] Saving installed packages list...'
- #tar cf /tmp/mnt/$DST/root/opt.tar /opt
- opkg list_installed | cut -d ' ' -f 1 > /tmp/mnt/$DST/root/installed_packages.txt
- cp $0 /tmp/mnt/$DST/root
- echo '[5/5] Downloading installation archive...'
- mkdir /tmp/mnt/$DST/install
- wget -qO /tmp/mnt/$DST/install/installer.tgz $URL
- echo 'Done! You may switch OPKG partition from WebUI.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement