[Tip] Workaround to get systemctl commands working on TermuxArch
petkar opened this issue · 9 comments
The workaround was this script which replaces /usr/bin/systemctl
and executes systemctl commands without systemd. It worked surprisingly well and got the job of starting and stopping services done, which is exactly what I wanted. The only requirement is python (pacman -S --needed python3
)
Installation instructions:
mv /usr/bin/systemctl /usr/bin/systemctl.old
curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py > /usr/bin/systemctl
chmod +x /usr/bin/systemctl
Although there were some issues I ran into, I think it's a neat a neat fix. I'm not aware of how compatible it is with proot or the issues that it could bring up.
Edit : There's a python2 version too
$ csystemctl.bash
Installing /usr/bin/systemctl replacement:
Already installed /usr/bin/systemctl replacement: DONE
I am testing this replacement version. It is generated by _ADDcsystemctl_
. Do you think this should be added to default setup @petkar?
One of the goals of the project appears to be to improve the usability of proot. It would indeed be a great default addition even if it's just a replacement script because it decrease the general handicap that the proot imposes.
be a great default addition even if it's just a replacement script because it decrease the general handicap that the proot imposes
Agreed; updating and overwriting csystemctl.bash
's work is now abated. It is currently set as default. This is important, as upgrading the Arch Linux system can overwrite the csystemctl.bash
refinement:
How should this script behave in the long run? How can it update itself? Is /etc/pacman.conf
rewritten correctly?
This issue TermuxArch/TermuxArch#21 points out some shortcomings (like backup being saved to the home directory).
At present, the script backs up to both the /usr/bin
and /root
directories. This seems to be redundant and only /usr/bin/systemctl.old
should suffice.
The systemctl-replacement script is copied to both /usr/bin
and /usr/local/bin
, however in ArchLinux proot, the $PATH variable looks like this :
/root/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
It is apparent that /usr/bin
preceeds /usr/local/bin
making the /usr/local/bin/systemctl
redundant and updates still could stop the functioning of the replacement script as of now.
One solution is to change the $PATH variable such that /usr/local/bin
and prepends (comes before) /usr/bin
.
Another possibility is to save the script to $HOME/bin as it prepends everything in $PATH. I have modified it to use ~/bin
here :
petkar/TermuxArch@1a42496
@SDRausty Please review this commit and offer your suggestions. If it seems appropriate, I will submit a pull request.
Edit : Would the $HOME/bin
directory be appropriate to save the script to make it update-proof or do you have a better suggestion in mind?
Edit 2 :
Is /etc/pacman.conf rewritten correctly?
Adding systemctl
to IgnorePkg in /etc/pacman.conf
would not have any effect since it is not a package. Adding systemd
should however stop the updates. But I don't think stopping the updates is a good idea. Instead, the replacement script should be called from a different path while leaving the original intact. This should in effect prevent issues from updates.
Would the $HOME/bin directory be appropriate to save the script to make it update-proof or do you have a better suggestion in mind?
This /var/backups/${INSTALLDIR##*/}
directory is created to place backups. The systemctl
backup is now placed here.
Files in the /root directory are backed up into /var/backups/${INSTALLDIR##*/}/root
.
USER directories backups go into individual /var/backups/${INSTALLDIR##*/}/home/$USER
directories.
The previous comment seems to have arose due to the fact that the $PATH variable got messed up (which also affected makepkg) and I posted that before I realized the root cause of the problem (and can be safely ignored now). Now that it got resolved, package updates should not affect it anymore. Saving backups in /var/backups
seems like a better option than populating them in the home directory.
backups in /var/backups seems like a better option
This commit b7bba52 finalizes backups into /var/backups which now prevents these backup files from populating the home directories with backup files.
Please review this commit and offer your suggestions. If it seems appropriate
From petkar/TermuxArch@1a42496 specifically this https://github.com/petkar/TermuxArch page:
This branch is 1 commit ahead, 16 commits behind TermuxArch:master.
Repository shlibs/maintenance
is installed as a module in .scripts/maintenance/
in this repository. It assists with git
tasks:
- The file
up.sh
helps update forks easily. EDIT: It is set to just one git repository currently. It wants a little further development, - The file
do.sums.bash
assists in creating commits easily, - There are, and can be more.
The repository shlibs/maintenance
can be added as a submodule with the command git submodule add https://github.com/shlibs/maintenance \.scripts/maintenance
(the backslash is important) to git repositories that do not have this module installed.