Skip to content

Commit b91c34f

Browse files
committed
fix: avoid temporary extraction step into /tmp
1 parent c2c6be3 commit b91c34f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

update.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,18 @@ else
138138
# download it
139139
wget "$SELECTED_URL" -O /tmp/companion-update.tar.gz -q --show-progress
140140

141-
# extract download
141+
# extract only what we need directly to destination
142142
echo "Extracting..."
143-
rm -R -f /tmp/companion-update
144-
mkdir /tmp/companion-update
145-
tar -xzf /tmp/companion-update.tar.gz --strip-components=1 -C /tmp/companion-update
146-
rm /tmp/companion-update.tar.gz
147-
148-
# copy across the useful files
149143
rm -R -f /opt/companion
150-
mv /tmp/companion-update/resources /opt/companion
151-
mv /tmp/companion-update/*.rules /opt/companion/ 2>/dev/null || true
152-
rm -R /tmp/companion-update
144+
mkdir -p /opt/companion
145+
146+
# Extract resources directory
147+
tar -xzf /tmp/companion-update.tar.gz --strip-components=2 -C /opt/companion --wildcards '*/resources'
148+
149+
# Extract .rules files if they exist
150+
tar -xzf /tmp/companion-update.tar.gz --strip-components=1 -C /opt/companion --wildcards '*/*.rules' 2>/dev/null || true
151+
152+
rm /tmp/companion-update.tar.gz
153153

154154
echo "Finishing"
155155
else

0 commit comments

Comments
 (0)