Created
June 23, 2018 22:17
-
-
Save someburner/3f4806096c94ad5e01e513487435c170 to your computer and use it in GitHub Desktop.
Tomatoware upgrade
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/bash | |
############ SETTINGS ############ | |
pfx="mmc" | |
backup_prefix="/mnt/sda2" | |
#DISTNAME="arm-soft-$pfx-master" | |
DISTNAME="arm-soft-$pfx-mini" | |
################################## | |
if ! [[ -f $backup_prefix/dist/$DISTNAME.tgz ]]; then | |
echo "distribution not found: \"$DISTNAME.tgz\""; | |
exit 1 | |
fi | |
if ! [[ -d /$pfx ]]; then | |
echo "mountpoint $pfx not present?"; | |
exit 1; | |
fi | |
if [[ -d /$pfx/home ]]; then | |
echo "moving home folder from $pfx to $backup_prefix"; | |
#[[ -d $backup_prefix/home ]] && echo "$backup_prefix/home exists, remove or rename it" && exit 1; | |
cp -rf /$pfx/home $backup_prefix/home | |
fi | |
if [[ -d /$pfx/bin/go ]]; then | |
echo "moving bin/go from $pfx to $backup_prefix"; | |
[[ -d $backup_prefix/$pfx-go ]] && echo "$backup_prefix/$pfx-go exists, remove or rename it" && exit 1; | |
mv /$pfx/bin/go $backup_prefix/$pfx-go | |
fi | |
if [[ -d /$pfx/go ]]; then | |
echo "moving go workdir from $pfx to $backup_prefix"; | |
mv /$pfx/go $backup_prefix/$pfx-gowork | |
fi | |
echo "Removing all files/folders in $pfx"; | |
cd / | |
rm -rf /$pfx/* | |
rm -f /$pfx/.* | |
echo "Extracting $DISTNAME.tgz to /$pfx" | |
cd $backup_prefix/dist | |
/bin/tar -xf $DISTNAME.tgz -C /$pfx | |
sleep 1; | |
if [[ -d $backup_prefix/home ]]; then | |
echo "Putting home folder back"; | |
mv $backup_prefix/home /$pfx/home | |
echo "Done" | |
fi | |
if [[ -f $backup_prefix/profile ]]; then | |
echo "Restoring profile"; | |
cp -f $backup_prefix/profile /$pfx/etc/profile | |
fi | |
if [[ -d $backup_prefix/$pfx-go ]]; then | |
echo "Restoring go install"; | |
mv $backup_prefix/$pfx-go /$pfx/bin/go | |
fi | |
if [[ -d $backup_prefix/$pfx-gowork ]]; then | |
echo "Restoring go work directory"; | |
mv $backup_prefix/$pfx-gowork /$pfx/go | |
fi | |
#cp -f $backup_prefix/profile profile | |
cd /opt/etc | |
mv profile profile.opt | |
! [[ $? -eq 0 ]] && echo "profile DNE?" && exit 1; | |
if ! [[ -f profile ]]; then | |
ln -s /mmc/etc/profile profile | |
else | |
echo "/opt/etc/profile could not be moved"; | |
exit 1; | |
fi | |
#cd /opt/etc | |
#mv profile profile.opt | |
#ln -s /$pfx/etc/profile profile | |
echo; echo; | |
echo 'All done!'; | |
echo; echo; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment