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

Notices


Reply
  Search this Thread
Old 10-12-2016, 09:07 PM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
how to write script to start daemon


I installed thermald I know I need/should write a script called rc.thermald then add it to rc.local in /etc/rc.d and per-instructions from slackbuilds
Code:
Since this is a daemon, it can be started at boot via /etc/rc.d/rc.local:
  /usr/sbin/thermald

It might be necessary to create /var/run/thermald/ first (depending on your local system setup)

An entry could be added to /etc/rc.d/rc.local_shutdown as well:
  killall thermald

CONFIG_X86_MSR is listed as an (optional) dependency, msr-tools
can be installed from http://01.org/msr-tools via src2pkg (www.src2pkg.net/)
If you installed a previous version of thermald, you may need to uninstall
it and then install this one instead of using upgradepkg.
add a shut down in /etc/rc.d/rc.local_shutdown just adding that line killall thermald???

but I am not even sure what format/syntax to use having cat a few of the rc.xxx files to try and get an idea. it confused me instead. In Void Linux all I got a do is just add a soft link from /etc/sv/daemonName to /var/service and that is it, next reboot it starts, or issue #sv u daemon name and start it right then as well. done deal.

I issued #thermald start to see what I'd see
Code:
bash-4.4# thermald start
Ready to serve requests: Daemonizing.. 1
bash-4.4# ps -aux | grep thermald
root     10382  0.0  0.0 122524  5904 ?        Ssl  20:49   0:00 thermald start
root     10406  0.0  0.0   9644  1852 pts/1    S+   20:49   0:00 grep thermald
but I don't think it actually started

and what is this
Code:
It might be necessary to create /var/run/thermald/ first (depending on your local system setup)
my /var/run states this

Code:
bash-4.4# ls /var/run/thermald
thermald.pid
bash-4.4# cat  /var/run/thermald/thermald.pid
bash-4.4#
it is empty ..

so this being the first time I've actually setup this services in Slackware. well here I am dropping down to newbe status.


Code:
if [ -x /sbin/thermald ] ; then
thermald start
fi
that looks to weak ...

Code:
bash-4.4# ps -aux | grep thermald
root     10382  0.0  0.0 122524  5904 ?        Ssl  20:49   0:00 thermald start
root     11715  0.0  0.0   9644  1816 pts/0    S+   21:17   0:00 grep thermald
bash-4.4# thermald stop
Ready to serve requests: Daemonizing.. 1
bash-4.4# 
bash-4.4# ps -aux | grep thermald
root     10382  0.0  0.0 122524  5904 ?        Ssl  20:49   0:00 thermald start
root     11717  0.3  0.0 122524  5828 ?        Ssl  21:18   0:00 thermald stop
root     11720  0.0  0.0   9644  1820 pts/0    S+   21:18   0:00 grep thermald
bash-4.4# killall thermald
bash-4.4# ps -aux | grep thermald
root     11725  0.0  0.0   9644  1832 pts/0    S+   21:18   0:00 grep thermald
that was just doing to see what I'd see..

Code:
bash-4.4# thermald
Ready to serve requests: Daemonizing.. 1
bash-4.4# 
bash-4.4# ps -aux | grep thermald
root     11859  0.0  0.0 122524  6064 ?        Ssl  21:21   0:00 thermald
root     11886  0.0  0.0   9644  1792 pts/0    S+   21:21   0:00 grep thermald
looks like all I have to do is that bit of code without the start command in it, put it in a rc.thermal script

Code:
if [ -x /sbin/thermald ] ; then
 thermald
fi
then in rc.local
Code:
if [ -x /etc/rc.d/rc.scriptname ]; then
    /etc/rc.d/rc.scriptname start
fi
?????
or just put that if statement in rc.local (which maybe bad pratice)?



a lot of help please.

Last edited by BW-userx; 10-12-2016 at 09:24 PM.
 
Old 10-12-2016, 11:09 PM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Well, normally someone would write an /etc/rc.d/rc.thermald script that has "start" and "stop" options. Sometimes there will be "restart" and/or "status" methods.

The "restart" method will normally just call the start and stop functions. Any "status" method will look for a pid file and see if that pid matches a running version of the service.


Here's an example (/etc/rc.d/rc.messagebus)...

Code:
#!/bin/sh
#
# messagebus:   The D-BUS systemwide message bus
#
# description:  This is a daemon which broadcasts notifications of system events \
#               and other messages. See http://www.freedesktop.org/software/dbus/
#
# processname: dbus-daemon

# This is a modified version of the rc.messagebus script distributed with the
# dbus sources.  Thanks to Don Tanner of the GWare <http://gware.org> Project
# for most of the work involved      --Robby Workman <rworkman@slackware.com>


PIDFILE=/var/run/dbus/dbus.pid

start() {
  mkdir -p $(dirname $PIDFILE)
  if ! ps -u messagebus -c | grep -wq dbus-daemon; then
    rm -f $(dirname $PIDFILE)/*
    if [ -x /usr/bin/dbus-uuidgen -a -x /usr/bin/dbus-daemon ] ; then
      echo "Starting system message bus:  /usr/bin/dbus-uuidgen --ensure ; /usr/bin/dbus-daemon --system"
      /usr/bin/dbus-uuidgen --ensure
      /usr/bin/dbus-daemon --system 1> /dev/null
    fi
  fi
}

stop() {
  if [ -e "$PIDFILE" ]; then
    echo "Stopping system message bus..."
    pid=$(cat $PIDFILE)
    kill $pid 1> /dev/null 2> /dev/null
    # Just in case:
    killall dbus-daemon 1> /dev/null 2> /dev/null
    rm -f $PIDFILE
  fi
}

reload() {
  echo "Reloading system message bus configuration..."
  if [ -e "$PIDFILE" ]; then
    pid=$(cat $PIDFILE)
    kill -HUP $pid
  else
    killall -HUP dbus-daemon
  fi
}

status() {
  if ps -u messagebus -c | grep -wq dbus-daemon; then
    echo "System dbus-daemon is running."
  else
    echo "System dbus-daemon is stopped."
  fi
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    echo "You may need to restart your Window Manager to reconnect to the system dbus."
    ;;
  reload)
    reload
    ;;
  status)
    status
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|reload|status}"
    ;;
esac
 
1 members found this post helpful.
Old 10-12-2016, 11:57 PM   #3
Contrak
LQ Newbie
 
Registered: Mar 2014
Posts: 26

Rep: Reputation: Disabled
I haven't installed thermald before, but I think you should just do what it says.
Quote:
Since this is a daemon, it can be started at boot via /etc/rc.d/rc.local:
/usr/sbin/thermald
Adding /usr/sbin/thermald in rc.local starts the program.
Its like starting a program on the command line.

Quote:
An entry could be added to /etc/rc.d/rc.local_shutdown as well:
killall thermald
Adding killall thermald kills the program at shutdown.
Like on the command line, killall thermald would quit the program.

Overthinking it, maybe?
 
1 members found this post helpful.
Old 10-13-2016, 06:21 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Contrak View Post
I haven't installed thermald before, but I think you should just do what it says.

Adding /usr/sbin/thermald in rc.local starts the program.
Its like starting a program on the command line.


Adding killall thermald kills the program at shutdown.
Like on the command line, killall thermald would quit the program.

Overthinking it, maybe?
yeah perhaps I am over thinking it out of not actually knowing the the simplicity of it. looking at all of the other scripts with case statements and if statements and such to check for everything well, conformity is a word that comes to mind. Seeing how thermald is a no hassle daemon. I got it installed on my other OS, Void and when I am pushing my CPU it works rather nicely.

thanks I think I'll try the simplistic approach first and see what happens.
 
Old 10-13-2016, 06:49 AM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Personally, I would drop the rc.thermald. To me, the rc.program files are beneficial when the startup of the program is a bit more complex, or you might want to turn it on or off. Granted, whether to create an rc.program file or just add a line or few into your rc.local is a personal preference, but based on the simplicity of this program, I'd just add the /usr/sbin/thermald line into your rc.local and be done with it. I don't think you need to worry about checking if it's executable unless you intend to manually change the permissions of the file itself. And unless this program might have issues if shutdown improperly, I don't think you need to worry about an entry in rc.local_shutdown (which doesn't exist until you create it).

KISS approach
 
1 members found this post helpful.
Old 10-13-2016, 07:01 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by bassmadrigal View Post
Personally, I would drop the rc.thermald. To me, the rc.program files are beneficial when the startup of the program is a bit more complex, or you might want to turn it on or off. Granted, whether to create an rc.program file or just add a line or few into your rc.local is a personal preference, but based on the simplicity of this program, I'd just add the /usr/sbin/thermald line into your rc.local and be done with it. I don't think you need to worry about checking if it's executable unless you intend to manually change the permissions of the file itself. And unless this program might have issues if shutdown improperly, I don't think you need to worry about an entry in rc.local_shutdown (which doesn't exist until you create it).

KISS approach
already done, I deleted my rc.thermald file I created, added to rc.local all except I didn't add the absolute path to thermald and reboot to see if that worked, I just started off the command line in root login. using the word thermald so my brain said brain, just thermald should work it did in the terminal, and i created an rc.local_shutdown and chmod 'ed it. it maybe over kill but that shouldn't hurt anything.

changed to /usr/sbin/termald

thanks...

Last edited by BW-userx; 10-13-2016 at 07:03 AM.
 
  


Reply

Tags
services



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
Whats the proper what to terminate a script using start-stop-daemon? dodul Linux - General 1 07-17-2015 10:09 AM
Suse init script: start daemon as different user. possible? BrianK SUSE / openSUSE 1 02-28-2011 02:34 PM
[SOLVED] write a shell script so that it can run as service/daemon deostroll Programming 10 03-08-2010 10:03 AM
Bash script to verify the daemon is working if not, start the daemon kishoreru Linux - Newbie 7 09-23-2009 04:29 AM
start a daemon script at startup haxxor23 Linux - Newbie 2 05-12-2007 07:59 AM

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

All times are GMT -5. The time now is 06:15 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