a2server/fix/fix.txt
Ivan X 14f5ef66be alternate URL for precompiled binaries with A2SERVER_BINARY_URL
self-hosted external dependency fallback; or default via A2SERVER_NO_EXTERNAL=1
a2serverrc sets default A2SERVER_SCRIPT_URL and A2SERVER_BINARY_URL
64-bit Debian precompiled binary support
support for reorganized files subdirectory
better information re unsupported OS at start of install
info about netboot at end of install
no longer deletes ~/GNUstep
install libdb5.1 and libssl1.0.0 by default instead of older versions
small tweaks and fixes regarding Debian detection, case insensitive fs, etc
updated source code path for The Unarchiver
this is internal version 1.2.8; see "release" notes about external dependencies
2015-12-24 13:02:17 +09:00

115 lines
5.0 KiB
Bash

#!/bin/bash
echo
echo "A2SERVER fix: This utility will make a Raspberry Pi SD card boot if it"
echo "kernel panics (crashes) on startup after updating its operating system"
echo "while A2SERVER is installed."
echo
echo -n "Continue? "
read
doFix=
if [[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]]; then
while true; do
echo
echo "If attached, remove the Raspberry Pi's SD card from this computer."
echo -n "Press return to continue..."; read; echo
ls -1 /dev/sd? > /tmp/sd1 2> /dev/null
echo "Insert the Raspberry Pi's SD card into this computer, using a USB"
echo "reader if you don't have an SD slot. If this is a virtual machine,"
echo "make sure you select the reader or SD slot from its USB menu."
echo -n "Press return to continue..."; read; echo
ls -1 /dev/sd? > /tmp/sd2 2> /dev/null
# if exactly one drive has been inserted, exit loop
if { ! diff /tmp/sd1 /tmp/sd2 &> /dev/null; }; then
# files are different, get dev name
if [[ $(wc -c /tmp/sd1 | cut -f 1 -d ' ') -eq 0 ]]; then
if [[ $(wc -l /tmp/sd2 | cut -f 1 -d ' ') -eq 1 ]]; then
devName=$(cat /tmp/sd2)
break
else
echo "More than one volume seems to have appeared. Trying again..."
echo
fi
else
devName=$(grep -v "$(cat /tmp/sd1)" /tmp/sd2)
if [[ $(wc -l <<< $devName) -eq 1 ]]; then
break
else
echo "More than one volume seems to have appeared. Trying again..."
echo
fi
fi
else
echo "No SD card found. Trying again..."
echo
fi
done
mkdir -p /tmp/sd
sudo mount ${devName}6 /tmp/sd
raspbianDate=$(date -d "$(zcat /tmp/sd/usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | grep -m 1 ' --' | rev | cut -f 1-6 -d ' ' | rev)" +%s)
doFix=
if [[ $raspbianDate -lt 1403204265 ]]; then
echo "This doesn't appear to be a version of Raspbian that requires fixing."
echo -n "Are you sure you want to continue? "
read
if [[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]]; then
doFix=1
fi
else
doFix=1
fi
if [[ $doFix ]]; then
while read kernelRelease; do
kernelReplaced=
kernelMajorRelease=$(cut -d '.' -f 1 <<< $kernelRelease)
kernelMinorRelease=$(cut -d '.' -f 2 <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/')
kernelPatchRelease=$(cut -d '.' -f 3- <<< $kernelRelease | sed 's/\(^[0-9]*\)[^0-9].*$/\1/')
# if kernel 3.12 below 3.12.25+, delete defective AppleTalk kernel
if [[ $kernelMajorRelease -eq 3 && $kernelMinorRelease -eq 12 && $kernelPatchRelease -lt 25 ]]; then
if [[ -f /tmp/sd/lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ]]; then
if [[ $(sha1sum /tmp/sd/lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d ' ') != "ecb239fc084c36de93f6926e7749b80f6024f269" ]]; then
echo "Removing defective AppleTalk module from kernel $kernelRelease..."
sudo rm -rf /tmp/sd/lib/modules/$kernelRelease/kernel/net/appletalk 2> /dev/null
wget -qO /tmp/appletalk.ko.gz ${A2SERVER_SCRIPT_URL}files/appletalk-$kernelRelease.ko.gz
if [[ $? -eq 0 ]]; then
# if we found a prebuilt one on a2server site, so install it
gunzip -f /tmp/appletalk.ko.gz
sudo mkdir -p /tmp/sd/lib/modules/$kernelRelease/kernel/net/appletalk
sudo mv /tmp/appletalk.ko /tmp/sd/lib/modules/$kernelRelease/kernel/net/appletalk
echo "Installed fixed AppleTalk module for kernel $kernelRelease."
kernelReplaced=1
fi
fi
fi
fi
done <<< "$(ls -1 /tmp/sd/lib/modules | sort -V)"
sudo umount /tmp/sd
echo kern:$kernelReplaced
if [[ $kernelReplaced ]]; then
echo
echo "All set. Remove your SD card, put it back in your Pi, and boot it."
echo
echo "You should be able to connect from your Apple II, but if you can't,"
echo "log in to your Pi and type 'a2server-setup' to complete the fix."
else
echo
echo "Okey doke. Half done. Remove your SD card, and put it back in your Pi."
echo "After it boots, log in and type 'a2server-setup' to complete the fix."
fi
echo "See the A2SERVER web site at http://ivanx.com/a2server for more help."
echo "(You can type 'sudo shutdown -h now' if you're done on this machine.)"
echo
fi
fi
rm fix &> /dev/null