Last active
February 1, 2021 16:27
-
-
Save bartclone/199cbe50c4191e510926d8a348401624 to your computer and use it in GitHub Desktop.
fixsynoboot.sh
This file contains 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/ash | |
# https://bit.ly/3ja5CGi | |
# read https://xpenology.com/forum/topic/28183-running-623-on-esxi-synoboot-is-broken-fix-available/ | |
# *Problem* | |
# - In a VM that you want to upgrade to 6.2.3 | |
# - You get unexplained checsum-errors | |
# *Solution* | |
# copy this script (FixSynoboot.sh) to /usr/local/etc/rc.d | |
# chmod 0755 /usr/local/etc/rc.d/FixSynoboot.sh | |
# | |
# FixSynoboot() extracted from Jun 1.04b loader | |
# added hotplug-out event to gracefully clean up esata volumes 2020-Apr-18 | |
# cleaned up share references in message log and root folder 2020-May-16 | |
FixSynoboot() | |
{ | |
if [ ! -e /dev/synoboot ]; then | |
tail -n+3 /proc/partitions | while read major minor sz name | |
do | |
if echo $name | grep -q "^sd[[:alpha:]]*$";then | |
basename=$name | |
minor0=$minor | |
synoboot1="" | |
synoboot2="" | |
continue | |
fi | |
if [ $name = "${basename}1" -a $sz -le 512000 ]; then | |
synoboot1="$name" | |
minor1=$minor | |
elif [ $name = "${basename}2" -a $sz -le 512000 ]; then | |
synoboot2="$name" | |
minor2=$minor | |
else | |
continue | |
fi | |
if [ -n "$synoboot1" -a -n "$synoboot2" ]; then | |
# begin hotplug event added | |
if [ -e /sys/class/block/$basename ]; then | |
port=$(synodiskport -portcheck $basename) | |
df | grep "^/dev/$basename." | while read share; do | |
share=$(echo $share | awk '{print $1,$NF}') | |
sharedir=$(echo $share | awk '{print $2}') | |
sharebase=$(echo $sharedir | awk -F\/ '{print $2}') | |
sharedir=$(echo $sharedir | awk -F\/ '{print $3}') | |
if ( synocheckshare --vol-unmounting $port $share ); then | |
umount $(echo $share | awk '{print $1}') | |
grep -v "^$share" /run/synostorage/volumetab >/tmp/volumetab | |
mv /tmp/volumetab /run/synostorage/volumetab | |
rm "/$sharebase/@eaDir/$sharedir/[email protected]" | |
find "/$sharebase" -empty -type d -delete 2>/dev/null | |
fi | |
done | |
echo "remove" >/sys/class/block/$basename/uevent | |
fi | |
# end | |
rm "/dev/$basename" | |
rm "/dev/$synoboot1" | |
rm "/dev/$synoboot2" | |
rm "/dev/${basename}3" | |
mknod /dev/synoboot b $major $minor0 | |
mknod /dev/synoboot1 b $major $minor1 | |
mknod /dev/synoboot2 b $major $minor2 | |
break | |
fi | |
done | |
fi | |
} | |
RUNAS="root" | |
case $1 in | |
start) | |
FixSynoboot | |
exit 0 | |
;; | |
stop) | |
exit 0 | |
;; | |
status) | |
exit 0 | |
;; | |
log) | |
exit 1 | |
;; | |
*) | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment