Skip to content

Commit

Permalink
feat: Support install from local PAT file (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese committed May 12, 2024
1 parent abd30b9 commit 3da564d
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ if [ -n "$URL" ]; then
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
fi
if [[ "${URL,,}" != "http"* ]]; then
if [ -s "$STORAGE/$BASE.pat" ]; then
URL="file://$STORAGE/$BASE.pat"
else
error "File $STORAGE/$BASE.pat does not exist!" && exit 65
fi
fi
fi

if [[ -s "$STORAGE/$BASE.boot.img" ]] && [[ -s "$STORAGE/$BASE.system.img" ]]; then
Expand Down Expand Up @@ -109,22 +116,34 @@ fi
# Download the required files from the Synology website

ROOT="Y"
RD="$TMP/rd.gz"
RDC="$STORAGE/dsm.rd"

if [ ! -s "$RDC" ] && [[ "$URL" == "file://"* ]] && [[ "${URL,,}" == *"_42218.pat" ]]; then

rm -f "$RD"
rm -f "$RDC"

tar --extract --file="${URL:7}" --directory="$(dirname "$RD")"/. "$(basename "$RD")"
cp "$RD" "$RDC"

fi

if [ ! -s "$RDC" ]; then

rm -f "$RD"
rm -f "$RDC"

MSG="Downloading installer..."
PRG="Downloading installer ([P])..."
info "Install: $MSG" && html "$MSG"

RD="$TMP/rd.gz"
SIZE=5394188
POS="65627648-71021835"
VERIFY="b4215a4b213ff5154db0488f92c87864"
LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
[[ "${URL,,}" == *"_42218.pat" ]] && LOC="$URL"

rm -f "$RD"
rm -f "$RDC"
/run/progress.sh "$RD" "$SIZE" "$PRG" &
{ curl -r "$POS" -sfk --connect-timeout 10 -S -o "$RD" "$LOC"; rc=$?; } || :

Expand Down Expand Up @@ -211,15 +230,16 @@ html "$MSG"
PAT="/$BASE.pat"
rm -f "$PAT"

SIZE=0
[[ "$URL" == *"DSM_VirtualDSM_69057.pat" ]] && SIZE=363837333

if [[ "$URL" == "file://"* ]]; then

cp "${URL:7}" "$PAT"

else

SIZE=0
[[ "${URL,,}" == *"_69057.pat" ]] && SIZE=363837333
[[ "${URL,,}" == *"_42218.pat" ]] && SIZE=379637760

/run/progress.sh "$PAT" "$SIZE" "$PRG" &

{ wget "$URL" -O "$PAT" -q --no-check-certificate --timeout=10 --show-progress "$PROGRESS"; rc=$?; } || :
Expand Down

0 comments on commit 3da564d

Please sign in to comment.