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

[Suggestion] adding shell scripting capabilities will bring PM2 to the next level #441

Closed
robang74 opened this issue Jun 23, 2023 · 5 comments
Assignees
Labels
feature request feature requests, suggestions, ideas etc. #invalid something is not right at all

Comments

@robang74
Copy link

robang74 commented Jun 23, 2023

DESCRIPTION

Reading the description of this patch, we clearly realise that adding shell script capabilies will bring PM2 to the next level. In order to achieve this there are some type of specific scripts to keep in consideration:

  • pre-install script: pre-install.sh
  • post-install script: post-install.sh
  • pre-remove script: pre-remove.sh
  • post-remove script: post-remove.sh

Which are the same types that are allowed into any kind of package (rpm, deb, etc.). Obviously, these scripts should be executed with root privileges and possibly in a decently set enviroment. Possibly a $PATCH_PATH or $PATCH_DIR (with or without the underscore) could be set in order to refer to folder in which the patch archive is extracted. In this way, more files can be added to be parsed by the scripts or copied into the system.

ADDITIONAL INFORMATION

This feature can be implemented in two different ways:

  • allow to add four scripts for each of that task with .sh extension
  • allow to add a single text file with .shell extension which contains 4 sections.

In the last case, something like that:

[pre-install]
rm -f /etc/resolv.conf

#[post-install]
#[pre-remove]

[post-remove]
ln -sf /run/connman/resolv.conf /etc/resolv.conf

One or another way is indifferent and It is a matter of taste. In .sh case the files do not need to be executable to run but just being interpretable. However, the .sh approach avoid to have a parser to split the .shell single file and moreover, it clears the possible misunderstanding about the chance that every single line will be executed by a different shell instance:

/bin/ash pre-install.sh

instead of

/bin/ash -c "first line"
...
/bin/ash -c "last line"

It is suggested to use /bin/ash as default interpreter which is enough powerful in terms of scripting even if does not implement the full set of bashism. This because the scripts relying on /bin/ash can run on /bin/bash as well but in some system /bin/bash could be optional.

@robang74 robang74 added the feature request feature requests, suggestions, ideas etc. label Jun 23, 2023
@Olf0
Copy link
Contributor

Olf0 commented Jun 23, 2023

This is already present functionality. As this section of Patchmanager's README denotes:

Patches can be too complex for Patchmanager's Web Catalog. In this case the developer may package the Patch as an RPM and upload it at https://openrepos.net/ or another user-accessible package repository. OpenRepos provides a category "Patches" and a tag "Patch" for this, which both should be used.

Please carry on reading there by yourself.

TL;DR: RPM scriptlets provide all you are asking for and more.

@Olf0 Olf0 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
@Olf0 Olf0 self-assigned this Jun 23, 2023
@Olf0 Olf0 added #invalid something is not right at all feature request feature requests, suggestions, ideas etc. and removed feature request feature requests, suggestions, ideas etc. labels Jun 23, 2023
@robang74
Copy link
Author

robang74 commented Jun 26, 2023

There is an intermediate layer of complexity between a RPM which offer a lot of features (full feature) at the cost of having to deal with its specific syntax (which is quite complex because it should deal with all the dependencies of the all the packages in the repository and with the installed ones) and executing shell scripts during a Patch Manager installation. Web Catalog is not the problem because it has to deal with a compressed archive (e.g. pippo.tar.gz) while the Patch Manager have just to execute 4 simple operations as far as all four scripts files exist. There is a HUGE gap between applying a patch (diff -pruN) and preparing a RPM, in this HUGE gap, Patch Manager shell scripting capability has its own place.

@nephros
Copy link
Contributor

nephros commented Jun 26, 2023

There will be no feature allowing to run random shell scripts as root in Patchmanager.

That would be wrong on so many counts it's not even funny.

@robang74
Copy link
Author

robang74 commented Jun 27, 2023

Strange to ear because patch executes with root privilegs in order to apply .patch to system files.

Anyway take a look here to just to have a glimpse how tar (new enought version) and gz can do:

https://forum.sailfishos.org/t/rfc-adding-shell-scripting-capabilities-will-bring-pm2-to-the-next-level/15987/16

About reconfiguring SailFish OS at system level.

@Olf0
Copy link
Contributor

Olf0 commented Jul 1, 2023

Patchmananger's principal purpose has been, is and will stay to alter proprietary text files, specifically the QML files which Lipstick, Silica and some SailfishOS applications (e.g., the settings app) are comprised of, because no elements from these SailfishOS components can be forked and redeployed.

Patchmanager may be used to alter any text file, but will not employ any specific provisions for other special text files (e.g., systemd units) than proprietary ones, because any software under a FLOSS license can be forked and redeployed as an RPM package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature requests, suggestions, ideas etc. #invalid something is not right at all
Projects
None yet
Development

No branches or pull requests

3 participants