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

"WIP" Create auto-cpufreq-sysvinit #599

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

AmerXz
Copy link

@AmerXz AmerXz commented Nov 12, 2023

Run Script (Could be replaceable by auto-cpufreq-r6 runscript )

And a sysvinit daemon for auto-cpufreq generated THANKS TO :-

https://github.com/yunginnanet/sysvinit-service-generator fork of https://github.com/wyhasany/sysvinit-service-generator

It should be inside /etc/init.d/

A sysvinit daemon for auto-cpufreq generated THANKS TO :- 

https://github.com/yunginnanet/sysvinit-service-generator fork of https://github.com/wyhasany/sysvinit-service-generator

It should be inside /etc/init.d/
@AmerXz AmerXz marked this pull request as ready for review November 12, 2023 13:50
Run script For auto-cpufreq That can make sysvinit recognise auto-cpufreq 

Note You can Also use the runscript inside  auto-cpufreq/scripts/auto-cpufreq-s6 By @AnasR7





/run
Copy link
Author

@AmerXz AmerXz left a comment

Choose a reason for hiding this comment

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

Run script For auto-cpufreq That can make sysvinit recognise auto-cpufreq

Note You can Also use the runscript inside auto-cpufreq/scripts/auto-cpufreq-s6 By @AnasR7

@AdnanHodzic
Copy link
Owner

LGTM, but the part which I'm missing is how will the auto-cpufreq-installer detect if system user is running on is running on systemv and it's not refering to install script anywhre?

Or was there other you were envisioning of working?

Copy link
Collaborator

@shadeyg56 shadeyg56 left a comment

Choose a reason for hiding this comment

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

Thanks for this pr.

I do agree we should remove the auto-cpufreq-run since we already have the runfile in auto-cpufreq/scripts/auto-cpufreq-s6 to avoid redundancy and bloat

Also to repeat what Adnan suggested, the daemon installer script should be updated to include this new sysvinit service. The problem I see is what we already support openrc which uses sysvinit by default, so they both use the init process name for PID 1, so we need a way to distinguish the difference.

Something like this could work:

# snippet
elif [ "$(ps h -o comm 1)" = "init" ];then
    # Check if /etc/inittab file exists
    if [ -e "/etc/inittab" ]; then
       # sysvinit command here
    else
        # openrc stuff moved here
    fi

Additionally, the same change should be made to the daemon removal script. If that doesn't make sense, please let me know and also feel free to comment if you have any alternative ideas since I am not as familiar with openrc or sysvinit :)

@@ -0,0 +1,3 @@
!#/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this file since we already have one like it

Copy link
Author

Choose a reason for hiding this comment

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

It's deleted

@AmerXz
Copy link
Author

AmerXz commented Nov 15, 2023

It's deleted

@AdnanHodzic
Copy link
Owner

It's deleted

👍, but this part is still missing:

Also to repeat what Adnan suggested, the daemon installer script should be updated to include this new sysvinit service. The problem I see is what we already support openrc which uses sysvinit by default, so they both use the init process name for PID 1, so we need a way to distinguish the difference.

Something like this could work:

# snippet
elif [ "$(ps h -o comm 1)" = "init" ];then
    # Check if /etc/inittab file exists
    if [ -e "/etc/inittab" ]; then
       # sysvinit command here
    else
        # openrc stuff moved here
    fi

Additionally, the same change should be made to the daemon removal script. If that doesn't make sense, please let me know and also feel free to comment if you have any alternative ideas since I am not as familiar with openrc or sysvinit :)

For reference see how in daemon installer script it was done for # Install script for openrc or # Install script for systemd and refer to @shadeyg56 comment above.

@AmerXz
Copy link
Author

AmerXz commented Nov 18, 2023

Sorry if I was late I want to take some time until I finish some few important things to do these days and I need to organize myself a little bit.

I will test my fork repository and will give you what happens then .

also thanks for these suggestions.

@AdnanHodzic
Copy link
Owner

No worries and take your time

@AmerXz
Copy link
Author

AmerXz commented Nov 22, 2023

# Install script for openrc / sysvinit
elif [ "$(ps h -o comm 1)" = "init" ];then
   mkdir /etc/inittab
    if [ -e "/etc/inittab" ]; then 
        echo -e "\n* Deploy auto-cpufreq sysvinit unit file"
        cp /usr/local/share/auto-cpufreq/scripts/auto-cpufreq-sysvinit /etc/init.d/auto-cpufreq
	
        echo -e "\n* "Reloading sysvinit manager configuration"
	service auto-cpufreq reload
 
        echo -e "\n* "Starting auto-cpufreq daemon (sysvinit) service"
        service auto-cpufreq start
        
        echo -e "\n* "Enabling auto-cpufreq daemon (sysvinit) service at boot"
	chkconfig auto-cpufreq-sysvinit on
      else
        echo -e "\n* Deploy auto-cpufreq openrc unit file"
        cp /usr/local/share/auto-cpufreq/scripts/auto-cpufreq-openrc /etc/init.d/auto-cpufreq
	echo -e "\n* "Starting auto-cpufreq daemon (openrc) service"
	rc-service auto-cpufreq start

	echo -e "\n* Enabling auto-cpufreq daemon (openrc) service at boot"
	rc-update add auto-cpufreqlocal/share/auto-cpufreq/scripts/auto-cpufreq-openrc /etc/init.d/auto-cpufreq

I Edited openrc script to be like that and I used this fedora resource in this link that helped me find sysvinit commands https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet

For now I didn't test the code

tell me for any suggestions if needed

I'll see you guys next time

@shadeyg56
Copy link
Collaborator

I will test in a VM with both init systems

@nixon87
Copy link

nixon87 commented Jan 6, 2024

I am testing this right now on MX linux 23 Fluxbox 64 bit edition (non systemd) and would like to post my observations from discord (sry for the ad-hoc writing style):

Mh, it seems to work, installation went good, when i started in monitor mode it reminded me to de-install tlp, I did that restarted, now I'm running in live mode, the temperatures are the same with a different monitoring tool, unplugging the power supply gets detected, the setting to use governor is the same like in cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor from another terminal. The testing laptop is fairly old: Not setting EPP (Not supported by system) Warning: CPU turbo is not available seem plausible.

However, I get "System has not been booted with systemd as init system (PID 1 ). Can't operate. Failed to connect to bus: PC is not active .... " when starting live or monitor mode, but I ignored that for now.

I see, I have to check if I get it installed permanently.

There seems to be a problem in line 84 at the auto-cpufreq-install script:

echo -e "\n* "Enabling auto-cpufreq daemon (sysvinit) service at boot"
chkconfig auto-cpufreq-sysvinit on

when running

sudo auto-cpufreq -- install

  • Turn off bluetooth on boot

  • Deploy auto-cpufreq install script

* Deplo auto-cpufreq*remove script

There was a problem, couldn't determine GNOME Power Profiles Daemon

-----------------Running auto-cpufreq daemon install script -------------------------
/usr/local/bin/auto-cpufreq-install: line 84: syntax error near unexpected token >> ( <<
/usr/local/bin/auto-cpufreq-install: line 84: echo -e "\n* "Enabling auto-cpufreq daemon (sysvinit) service at boot" '

--------------------- auto-cpufreq daemon installed and runnin--------------------------

....
I wrote the above by hand from another pc.

Thank you for your work on non-systemd compatibility . :)

@nixon87
Copy link

nixon87 commented Jan 8, 2024

Further investigating: there seems to be at least some trouble with the additional (") after "\n
from line 78 - 89

    echo -e "\n* "Reloading sysvinit manager configuration"
service auto-cpufreq reload

    echo -e "\n* "Starting auto-cpufreq daemon (sysvinit) service"
    service auto-cpufreq start

    echo -e "\n* "Enabling auto-cpufreq daemon (sysvinit) service at boot"
chkconfig auto-cpufreq-sysvinit on

and

      echo -e "\n* "Starting auto-cpufreq daemon (openrc) service"

@nixon87
Copy link

nixon87 commented Jan 8, 2024

After deleting the additional " the terminal output says it doesn't know chkconfig which doesn't seem to be used by mx linux fluxbox (not installed).

@AmerXz
Copy link
Author

AmerXz commented Jan 8, 2024

I'm downloding mx linux on a vm and test the code again , I'm sorry for not giving much time to this pull request .

@AmerXz
Copy link
Author

AmerXz commented Jan 10, 2024

Ok it seems that chkconfig command is deprecated years ago and we should use insteasd sysv-rc-conf it can be found in debian repos https://packages.debian.org/bookworm/sysv-rc-conf

source https://askubuntu.com/questions/221293/why-is-chkconfig-no-longer-available-in-ubuntu/277732#277732

@nixon87
Copy link

nixon87 commented Jan 10, 2024

Alrighty, there are some errors I want to post here besides chkconfig, you might have come across them in your virtual machine:

when running auto-cpufreq --install (with the changes from above)

I also get these three errors:

mkdir: cannot create folder : "/etc/inittab": file exists already

  • Reloading sysvinit manager configuration
    auto-cpufreq: unrecognized service

  • starting auto-cpufreq daemon (ssvinit) service
    auto-cpufreq: unrecognized service

Again, thanks for your work :)

applied some suggested fixes and replace (mkdir) command with (ls) and also replaced deprecated (chkconfig) command with (sysv-rc-conf)

last but not least I need to have auto-cpufreq-sysvinit inside '/usr/local/share/auto-cpufreq/scripts/'

for testing I tried to copy auto-cpufreq-sysvinit file to '/usr/local/share/auto-cpufreq/scripts/' manually to check if the  install script will work and I had the output below

'''
/etc/inittab

* Deploy auto-cpufreq sysvinit unit file

* Starting auto-cpufreq daemon (sysvinit) service

* Enabling auto-cpufreq daemon (sysvinit) service at boot
'''

echo -e "\n* "Reloading sysvinit manager configuration"
service auto-cpufreq reload
cp /usr/local/share/auto-cpufreq/scripts/auto-cpufreq-sysvinit /etc/init.d/auto-cpufreq

Copy link

@nixon87 nixon87 Jan 11, 2024

Choose a reason for hiding this comment

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

I think you need a
chmod +x /etc/init.d/auto-cpufreq
here
The copying to /etc/init.d works on my system but the script is not executable.
Maybe the same later for openrc.

@nixon87
Copy link

nixon87 commented Jan 12, 2024

Just for a heads up: as written in the review the copying when running auto-cpufreq --install seems to work now. When adding chmod +x /etc/init.d/auto-cpufreq and restart the os the shell script runs as a system service at reboot. But when running auto-cpufreq --stats the daemon doesn't seem to be active. I think it's close to working but sadly I am no expert at all. I guess the sysvinit script needs some revisit and maybe the things pointed out by shadeyg56 regarding the daemon removal script. Maybe shadeyg56 can take a look at the state right now?

@AdnanHodzic
Copy link
Owner

@shadeyg56 could you please take a final look and confirm if it's all working, if it's let's merge this. Thanks!

@nixon87
Copy link

nixon87 commented Jan 21, 2024

As written above I think it's not quite there yet, at least on my machine the auto-cpufreq daemon isn't active. The init system script gets started however (after the suggested changes).

@shadeyg56
Copy link
Collaborator

Haven't been able to test in a VM since sudo auto-cpufreq --install does not work in VMs so the OS would need to be installed natively. @AmerXz have you tested the changes?

change SCRIPT to use runfile inside "/usr/local/share/auto-cpufreq/scripts/auto-cpufreq-s6/"
I forget that (sysvinit-service-generator I used earlier) had some small tutorial at the end of running script to make the service work so I replaced sysvinit daemon install section with commands inspired from that script and added commands to make the service and the run script inside auto-cpufreq-s6 to run as executables
 sysvinit-service-generator script aslo helped me know how to uninstall sysvinit service 

I added the commands that are inspired by these scripts  

I have to thank @wyhasany for making the script and @yunginnanet for his fork with the needed fixes otherwise I wouldn't be able to get auto-cpufreq-sysvinit to work
small Fix for small mistake
Copy link
Author

@AmerXz AmerXz left a comment

Choose a reason for hiding this comment

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

line 92 has extra "local/share/auto-cpufreq/scripts/auto-cpufreq-openrc /etc/init.d/auto-cpufreq" added there by mistake

This is fixed in the more updated commit

Copy link
Author

Choose a reason for hiding this comment

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

I have to thank @wyhasany for making the script and @yunginnanet for his fork with the needed fixes otherwise I wouldn't be able to get auto-cpufreq-sysvinit to work

Copy link
Owner

Choose a reason for hiding this comment

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

I suggest you prepend "WIP" (work in progress) to title of this PR, and then please remove WIP part & announce it when it's ready for review.

Thanks!

@AmerXz AmerXz changed the title Create auto-cpufreq-sysvinit "WIP" Create auto-cpufreq-sysvinit Feb 23, 2024
@AmerXz
Copy link
Author

AmerXz commented Mar 31, 2024

I did some test to the code and it ran perfectly fine on mx-linux with sysvinit even after reboot , But I couldn't test it in openrc distro .

I tried to install artix with openrc but the installation was broken so I need another distro or maybe other iso version .

@rakshasha-medhi
Copy link

I did some test to the code and it ran perfectly fine on mx-linux with sysvinit even after reboot , But I couldn't test it in openrc distro .

I tried to install artix with openrc but the installation was broken so I need another distro or maybe other iso version .

Hi, I'm looking to use auto-cpufreq with MX-Linux as well but I still got the same error message in your earlier posts:
*System has not been booted with systemd as init system (PID 1). Can't operate.

how did you manage to get it work with MX-Linux and sysvinit system? would love to learn more to get this working.
or is this still undergoing tests? I notice the status is WIP.
Thanks for the great tool !

@AmerXz
Copy link
Author

AmerXz commented Jun 8, 2024

Did you clone from patch-2 branch in my fork repo ?

@AdnanHodzic
Copy link
Owner

IIRC @Angel-Karasu recently made some changes to make auto-cpufreq work with MX Linux?

Regardless, @AmerXz if this is anywhere close to merging (if it works) maybe it's good idea to start the review/merge process?

@AmerXz
Copy link
Author

AmerXz commented Jun 19, 2024

It works on mx-linux but I didn't test it on openrc distro

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.

5 participants