feat: Bash script to setup automatically - #244
Conversation
|
If running the script inside the current already cloned directory, the Example:
|
|
I forgot to precise what I tested. OS-agnostic:
Arch-based OS (cachyOS) |
Fedora-based OS (Nobara Linux) |
Fedora-based OS |
Debian-based OS |
|
| # Make wemod python script executable | ||
| chmod +x "$WEMOD_DIR/wemod" | ||
| # Add a txt file to always have the launch command at hand | ||
| "$WEMOD_DIR %command%" > $WEMOD_DIR/launch-command.txt |
There was a problem hiding this comment.
Since this is based on where the laucher is located, this i probaly not that benifical.
If we where to have something like this that probaly just have a seperate bash script that allways gives you the current and therefore up to date command based on the folder.
At least tgat is what i think right now.
There was a problem hiding this comment.
That's an interesting standpoint.
We can also probably update (fetch, hard reset, pull) the repo (new script?), the real question is how to not make it ugly on the repo's files (too much scripts is not clear).
We can have all scripts in:
- root like now, or.
- A
scriptsfolder
For example in the scripts we can have:
setup.bash→install.bash, to git clone and check/install dependencies.update.bashto clean update (warning to user if unstashed diff with confirmation before action, then chmodwemodpython script).launch-command.bashto give only the current launch command.wemod.batI guess it makes sense to move all scripts in this folder. Maybe not.
Anyway, there are some questions here so I'll wait for an answer before changing things.
There was a problem hiding this comment.
I'm not comfortable with multiple scripts. It also shouldn't really be .bash, as that's not very conventional in Linux scripting.
If we're going to do multiple things, we should use getopt to parse the arguments to one script.
I am however OK with creating a folder of sourceable files for modularising functionality.
There was a problem hiding this comment.
Ok.
I am however OK with creating a folder of sourceable files for modularising functionality.
I am not sure to follow, what do you mean by sourceable files ?
There was a problem hiding this comment.
@PonyLucky By sourceable files, I mean including shell files into the main script from a hidden directory.
Something like this: https://linuxcommand.org/lc3_man_pages/sourceh.html
There was a problem hiding this comment.
I think it makes sense to make this PR a minimally viable product (MVP) implementation, and we can iterate upon it in future. Too much in one PR is hard to review.
There was a problem hiding this comment.
We can, let me think of something
There was a problem hiding this comment.
I tried this:
f30d99b
What do you think?
The only downside I see is that if the user doesn't have git installed it will fail right away if the repo already locally present.
|
This PR is currently a draft, but before being moved to ready, the commits should be squashed to two or less. |
| # 1. Detects when `### Setup Automatically` starts | ||
| # 2. Stops when `### Setup Manually` is reached | ||
| # 3. Begins printing only after `#### Next`: | ||
| awk ' | ||
| /^### Setup Automatically/ {in_auto=1; next} | ||
| /^### Setup Manually/ {in_auto=0} | ||
| in_auto && /^#### Next:/ {in_next=1} | ||
| in_auto && in_next | ||
| ' readme.md | ||
|
|
There was a problem hiding this comment.
I think this isn't clear what the purpose of it is.
Do we need to do this? Why are we doing this?
There was a problem hiding this comment.
I'm just not clear on why we need to extract content from the README.
It limits future edits of the README, and would likely be quite fragile due to the way Awk works.
Can we not hardcode this into the script, or an external file if we need to?
There was a problem hiding this comment.
The idea was to have only one file to have all the info one would need. But I understand what you mean, later it could break easily.
As you said we can hardcode in the bash script or move in a separate .md file.
What are you the most confortable with for future use ?
There was a problem hiding this comment.
I think maybe a USAGE.md file would be OK.
| read -rp "Enter installation path (leave empty to clone here): " install_path | ||
| if [ -z "$install_path" ]; then | ||
| echo "Cloning repository into current directory..." | ||
| git clone "$REPO_URL" |
There was a problem hiding this comment.
I think we should first clone into $XDG_CACHE_HOME, check everything's there, then move to the home directory. We could also use mktemp -d.
Network failures could happen, or disk I/O failures, meaning we want to do this in an ephemeral directory.
There was a problem hiding this comment.
I didn't know you could do that this way. It's a first to me.
Does it work this way ?
- create the tmp directory
mkdir -p "$XDG_CACHE_HOME/wemod-launcher"; - update the clone command to point this directory ;
- verify the hash of the local repo with GitHub (i don't know how to do it if this is the right way) ;
- if successful, move to intended path and cleanup cache ;
- continue the rest of the script.
There was a problem hiding this comment.
Yes, but you should use something like ${XDG_CACHE_HOME:-$HOME/.cache/wemod-launcher} to fallback if the XDG vars aren't defined.
But otherwise, yes.
|
@PonyLucky A significant change has been made to the codebase in terms of structure, so I rebased your branch against upstream. Please run |
Thanks, I'll likely do that in 2 days, tomorrow I need to go to the capital for work. |
Supports: - Arch-based OS (`pacman` only) - Fedora-based OS (`rpm-ostree` and `dnf`) - Debian-based OS (`apt` only)
Ask kindly the user to review the script before running instead of directly running something from internet.
`setup.bash` will now extract the content directly from the readme.
To follow convention
|
@PonyLucky I've mentioned your script in the Wand Discord, and there is some interest in a simpler way to setup this launcher. Just thought I'd let you know your efforts are appreciated! Thanks :D |
Thank you for this message (and tool), this week I didn't have much time to spend. For personal reasons I had to take a lawyer, it's been quite tense... I'll continue likely this weekend. |
|
Since we use the subfolder struture now this will have to move into a folder, may be just a folder called scripts or helpers. |
A |
You prefer a hidden folder? There may be some usefull scripts later in the scripts folder. |
setup script is now in the 'scripts' directory. The next steps are now in the USAGE.md instead of inside the readme.md, thus preventing potential extract fail.
For sourcing installation scripts, I don't think it should be a visible folder. |
I pushed commits with a visible directory. Because you might want to run launch-command script more than once if you forget the actual command I think a visible directory is the best choice. What I mean is that those scripts are sourcable but also meaningful as standalone. Thus justifying the visibility of the directory. That is my point of view, I won't fight over it. I invite you both to debate and find what's the best for the project, I will do the change if needed. Then there is the temporary directory side and I think we will have a strong feature ready to be squashed into one commit to the official repo. |
The reason I don't want the install scripts to be visible is because I can see users running them by mistake. An alternative is that I create a new repo specifically for hosting scripts to install, and people download from there. That solution solves a lot of problems. |
Mabey print x allready istalled. users running them by mistake is not realy that problematic, in that case (if script correctly checks for install). The thing is i do not mind if this script was to be hidden (via hidden folder) but if i (or others) ever add more scripts some of wich user may find usefull i would like the folder it to be visible. And a rename of that folder in the future, it just would not be that consistent, that is mostly why i prefer the visible folder aproach. |
|
We could have a hidden folder called |
Or just hide the script by renaming the install script to ".setup", then only that one file is hidden. |
|
Right, it's just that we're splitting the install script into sourceable modular files, so having it its own hidden directory is logical. I'd just rather the sourceable files weren't visible to the user post-installation. I'm happy for the main entrypoint script however, to be visible. |
Now i think i get it, what you mean the subscripts (so basicly the install dependecys file). So you think place it in a hidden folder. This commit only add 3 files, so i assume this is the gist, or did you mean it in a other way. |
|
@shymega would you explain what you have in mind, for sourceble files, just the one did i understand correctly or not? |
|
How do you feel about something like this then: Or what do you have in mind. Would also work to have a single script in scripts that runs what is requested via arguments, just a possibility, i like to know what you say |
I like this concept, plus the idea of a "main script" with arguments (optionally TUI) is good too. As depending on the answer I would have to do different things, I'll wait until the debate result to one solution. |
|
@PonyLucky could you move your bash scripts to ".hidden-scripts" and lets have one new script in the "scripts" folder, will call it sothing like "w-script" that will just be a general script that can call the 2 main hidden scripts users may want to run. |
Supports:
pacmanonly)rpm-ostreeanddnf)aptonly)Note:
In the readme.md, the url for the script is directly for the main branch. Less work for the approver.
P.S.: For Fedora-based OS,
rpm-ostreetakes priority overdnf, this safeguard shouldn't be needed as Bazzite shouldn't have dnf. Still future-proof.Related to: #243