Skip to content

Commit e59dd13

Browse files
committed
feat[android-interface]: dynamic-ify self update paths
Signed-off-by: shrihanDev <[email protected]>
1 parent 9c3a87d commit e59dd13

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

android-interface.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
shopt -s extglob
44

55
SCR_NAME_EXEC=$0
6+
SCR_NAME_EXEC_FP=$(realpath $0)
67
SCR_NAME=$(basename $SCR_NAME_EXEC)
78
SCR_NAME=${SCR_NAME%.*}
89
RVB_DIR=$HOME/revanced-builder
@@ -172,7 +173,6 @@ update_builder() {
172173
log "Updating revanced-builder..."
173174
cd $RVB_DIR
174175
dload_and_install n
175-
cd $HOME
176176
run_self_update
177177
}
178178

@@ -181,16 +181,16 @@ run_self_update() {
181181

182182
# Download new version
183183
log "Downloading latest version..."
184-
if ! curl -sLo $SCR_NAME_EXEC.tmp https://raw.githubusercontent.com/reisxd/revanced-builder/main/android-interface.sh ; then
184+
if ! curl -sLo $SCR_NAME_EXEC_FP.tmp https://raw.githubusercontent.com/reisxd/revanced-builder/main/android-interface.sh ; then
185185
log "Failed: Error while trying to download new version!"
186186
log "File requested: https://raw.githubusercontent.com/reisxd/revanced-builder/main/android-interface.sh"
187187
exit 1
188188
fi
189189
log "Done."
190190

191191
# Copy over modes from old version
192-
OCTAL_MODE=$(stat -c '%a' $SCR_NAME_EXEC)
193-
if ! chmod $OCTAL_MODE "$SCR_NAME_EXEC.tmp" ; then
192+
OCTAL_MODE=$(stat -c '%a' $SCR_NAME_EXEC_FP)
193+
if ! chmod $OCTAL_MODE "$SCR_NAME_EXEC_FP.tmp" ; then
194194
log "Failed: Error while trying to set mode on $SCR_NAME_EXEC.tmp."
195195
exit 1
196196
fi
@@ -200,8 +200,8 @@ run_self_update() {
200200
#!/bin/bash
201201
202202
# Overwrite old file with new
203-
if mv "$0.tmp" "$0"; then
204-
echo -e "[$SCR_NAME] Done. Execute '$0 run' to launch the builder."
203+
if mv "$SCR_NAME_EXEC_FP.tmp" "$SCR_NAME_EXEC_FP"; then
204+
echo -e "[$SCR_NAME] Done. Execute '$SCR_NAME_EXEC run' to launch the builder."
205205
rm \$0
206206
else
207207
echo "[$SCR_NAME] Failed!"

0 commit comments

Comments
 (0)