after login into KDE or after/during the boot process (I’m not well versed with init levels. So, excuse me). I’m tired of supplying admin password after every login, so I want to get it over with, once and for all. Below are the things I’ve tried so far and they didn’t give desired result.
create a startup script and launch it with KDE auto start. (Didn’t work because it needs root password.)
To begin with, when you try to do this from any init/systemd script at boot, the command should of course not be sudo. Those things are run as root already.
In the .service file you call /battery_optimisation, but the script apparently is named /battery_optimisation.sh.
Maybe that’s the reason why it doesn’t work?
Oh, and “sudo systemctl status powertop.service” should hint at that or other problems…
You could have avoided my comment by showing what you have in that file instead of suggesting. Copy/paste the prompt, the command (a cat statemrnt in this case I presume), the output and the next prompt. The we can all see exactly what you have without you having to add more story telling then needed.
Oh, sorry. I’ve actually hyperlinked to susepaste in my original post ;). But anyway here’s the file contents.
#! /bin/sh
#
# Copyright (c) 2010 SuSE LINUX Products GmbH, Germany. All rights reserved.
#
# Author: Werner Fink, 2010
#
# /etc/init.d/after.local
#
# script with local commands to be executed from init after all scripts
# of a runlevel have been executed.
#
# Here you should add things, that should happen directly after
# runlevel has been reached. Common environment
# variables for this are:
# RUNLEVEL -- The current system runlevel.
# PREVLEVEL -- The previous runlevel (useful after a runlevel switch).
#
/battery_optimisation
/usr/sbin/powertop --auto-tune
exit 0
#!/bin/bash
#
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany. All rights reserved.
#
# Author: Werner Fink, 1996
# Burchard Steinbild, 1996
#
# /etc/init.d/boot.local
#
# script with local commands to be executed from init on system startup
#
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#
/battery_optimisation.sh
/usr/sbin/powertop --auto-tune
exit 0
So it has been started.
As it is no daemon that keeps running in the background (it’s just a simple shell script after all that sets some values and exits), it is “inactive (dead)” now.
So have you verified that starting it manually (“sudo systemctl start powertop.service”) does set those things as you want to?
Probably it gets started too soon then? systemd tries to start every service as soon as possible.
Try to add some “After=” to the .service file, maybe “After=localfs.service”.
PS: to start your script as root without having to enter the root password, you might make it owned by root and set the “s” permission bit.
Probably it gets started too soon then? systemd tries to start every service as soon as possible.
Try to add some “After=” to the .service file, maybe “After=localfs.service”.
I edited powertop.service. Now, this is how it looks like.
Yep SUID bit is not allowed on scripts, the Linux kernel does not allow it because it is exploitable and yes in an init script the default should be root user unless specified other wise.