Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: linux update script improvements #978

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

rolznz
Copy link
Contributor

@rolznz rolznz commented Jan 12, 2025

  • add missing newlines
  • use pwd to get current absolute directory, remove /albyhub suffix
  • add file check to test if user is running in correct directory

- add missing newlines
- use pwd to get current absolute directory, remove /albyhub suffix
- add file check to test if user is running in correct directory
@rolznz rolznz requested a review from bumi January 12, 2025 05:14
Copy link
Contributor

@bumi bumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would need to be changed in the other install scripts, too.

@@ -28,10 +29,17 @@ then
pkill -f albyhub
fi

SCRIPT_DIR=$(dirname "$0")
read -p "Absolute install directory path (default: $SCRIPT_DIR/albyhub): " USER_INSTALL_DIR
SCRIPT_DIR=$(pwd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. pwd gives you the current directory. so for example:

I am in /home/foo (cd /home/foo) the update.sh is in /home/bar/update.sh.
If I now run /home/bar/update.sh the /home/foo directory will be used. which is wrong.

you need to have the directory of the script here.

maybe we can also remove this and always expect that update.sh is in the install directory. (as we write it also during installation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, thanks. I was wrong, and your SCRIPT_DIR change works in all console environments I tested.

So:

  1. change SCRIPT_DIR to SCRIPT_DIR=$(dirname "$(readlink -f "$0")");
  2. keep removal of /albyhub in INSTALL_DIR (to me it seems wrong it is appended)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I can follow.

it needs to be in sync with what we do here: https://github.com/getAlby/hub/blob/master/scripts/linux-x86_64/install.sh

Copy link
Contributor Author

@rolznz rolznz Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any changes need to be made in the install script.

We just need to make sure the update script runs in the correct folder.

  1. The SCRIPT_DIR change above ensures that it picks the folder of the executing update script, as an absolute path rather than a relative one: SCRIPT_DIR=$(dirname "$(readlink -f "$0")");
  2. I think the /albyhub suffix has always been a bug and is just ignores that it cannot CD into a non-existent albyhub folder.

+ we have the small addition to check if we are in the right folder before proceeding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will apply the fix only to this install script for now. The other 2 install scripts are at least specified for RPI (which I do not this is right, at least the arm64 one) and expect the script is run from within the albyhub directory.

I will make a new issue to review that and reference this PR.

@rolznz rolznz merged commit 39a0fce into master Jan 17, 2025
5 of 10 checks passed
@rolznz rolznz deleted the chore/linux-update-script-improvements branch January 17, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants