HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //usr/syno/sbin/synosharesnaptree_reconstruct.sh
#!/bin/bash

SNAPTREE_TOOL="/usr/syno/sbin/synosharesnaptree"
EADIR="/@eaDir"
SNAPTREE_BIN_FILE=$EADIR"/snaptree.bin"
SYNOFSTOOL="/usr/syno/sbin/synofstool"
VOLUMETAB="/run/synostorage/volumetab"
BROKEN_SNAPTREE_SUFFIX=".broken"

_get_fs_type()
{
	$SYNOFSTOOL --get-fs-type "$1"
}

reconstruct_snaptree()
{
	[ -e $VOLUMETAB ] || exit 0
	awk '{print $2}' < $VOLUMETAB | while read volume
	do
		if [ "$(_get_fs_type "$volume")" == "btrfs" ]; then
			if [ -e "$volume$EADIR" ]; then
				if [ -e "$volume$SNAPTREE_BIN_FILE" ] && [ ! -f "$volume$SNAPTREE_BIN_FILE$BROKEN_SNAPTREE_SUFFIX" ]; then
					continue
				fi
				if $SNAPTREE_TOOL -x "$volume"; then
					rm -f $volume$SNAPTREE_BIN_FILE$BROKEN_SNAPTREE_SUFFIX
				fi
			fi
		fi
	done
}

reconstruct_snaptree