LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch
User Name
Password
Arch This Forum is for the discussion of Arch Linux.

Notices


Reply
  Search this Thread
Old 09-27-2013, 07:36 AM   #1
jeanclaude
LQ Newbie
 
Registered: Sep 2013
Posts: 5

Rep: Reputation: Disabled
Systemd arch linux howto make a simple initscript ?[SOLVED]


Hi!

i am glade that Arch has his section on LinuxQuestions, my question may not be relevant to this forum but when I asked people often asked my distro.

I want to make this simple script :

#!/bin/bash

echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo

being execute on startup, the simplest way using systemd with sysv compatibility.

I get really confuse when I m trying to understand bashscript and sysv or systemd startup configuration. I really just need this simple line to be executed without option like "enable, disable, start, stop"

I activated sysv-compatibility.service in systemd and try to past in /etc/profile.d/ my script but it doesnt work.

I would like a good example of what I need to do please.

Last edited by jeanclaude; 09-27-2013 at 04:26 PM. Reason: fixed
 
Old 09-27-2013, 09:06 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
The script looks good. Its just the wrong place to put it. /etc/profile.d/ files get executed when you start a shell and it must be bash as far as I know.
You have to check out the /etc/init.d directory. Or if present on arch /etc/rc.local. You can just put the shell code here.

If using /etc/init.d you have to make sure there is sylink to it from the appropiate runlevel /etc/rc#.d directory.

To get your runlevel fire up a shell and type followed by enter
Code:
runlevel
cd /etc/rc#.d # subtitude first # with the number from the output of runlevel
ln -s ../init.d/scriptname ./S30scriptname
 
Old 09-27-2013, 01:18 PM   #3
jeanclaude
LQ Newbie
 
Registered: Sep 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi,

thanks for your answer,


However I stil dont really know what to do because i have only a folder called rc.d/ in /etc/ and no rc1.d/ rc2.d/ etc... and it s the same with init.d/ i dont have such a folder or file called like that in my /etc/ folder. It s a fresh arch install that runned only with systemd.

And I m not familiar at all with systemd, maybe do you have a udev rule that would execute my script or something like that ?
 
Old 09-27-2013, 03:02 PM   #4
nomasteryoda
LQ Newbie
 
Registered: Sep 2008
Posts: 10

Rep: Reputation: 0
Make a systemd rule

This example assumes you want your script to start up when the target multi-user is launched. Issue a chmod 755 to your script to enable execute permissions
Since your are using a shell script, make sure you have #!/bin/sh in the first line of the script.

Now for the part that is new:

Create your systemd service file below /etc/systemd/system. In your case you could call it /etc/systemd/system/noturbo.service then add the following contents:

Quote:
[Unit]
Description=No Turbo

[Service]
ExecStart=/usr/bin/noturbo.sh

[Install]
WantedBy=multi-user.target
Then:

# systemctl enable noturbo.service

You can start the service:

# systemctl start noturbo.service

Reboot to verify it does what you need and tweak as required. The ArchLinux wiki is a great resource (LQ is great too, but this is a bit more direct).


shamelessly derived from https://wiki.archlinux.org/index.php...oot_process.3F

Last edited by nomasteryoda; 09-27-2013 at 03:03 PM.
 
Old 09-27-2013, 03:38 PM   #5
jeanclaude
LQ Newbie
 
Registered: Sep 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks a lot !! It works perfectly !! Now everything works great on a Macbook pro 8.1 late 2011 13". It should be added to the macbook pro install arch wiki since macbooks pro are heating up very fast due to the bad cooling system from Apple in lastest linux 3.9 + kernels.

It feels amazing to have the power of a Mac with a such powerfull distro like Arch. I love Arch and I love the Arch community thank you for having made me complete a full supported macbook pro arch custom kernel install.

BTW systemd seems so easy when I see such a good example like yours.

Regards

Last edited by jeanclaude; 09-27-2013 at 04:27 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Is there a SIMPLE howto for basic systemd tweaking such as changing targets? jtwdyp Sabayon 19 06-16-2013 12:00 PM
LXer: Arch Linux switches to systemd LXer Syndicated Linux News 0 10-08-2012 08:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration