{"id":41,"date":"2008-01-26T13:18:24","date_gmt":"2008-01-26T18:18:24","guid":{"rendered":"http:\/\/yourlinuxguy.com\/?p=41"},"modified":"2008-03-14T08:54:09","modified_gmt":"2008-03-14T13:54:09","slug":"how-do-i-specify-service-start-order-in-suse","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=41","title":{"rendered":"How do I specify service start-order in Suse?"},"content":{"rendered":"<p><font color=\"#808080\"><em>This item inspired by Ken. And in order to keep this answer relatively short, I have to skip a bunch of pre-reqs. I&#8217;m going to assume that you understand service startup and run-levels in Linux, and maybe have tried specifying start-order in RedHat&#8230; This is where my thinking went when answering the question for Ken, so that&#8217;s what you get here. Anyway, back to the question at hand&#8230;<\/em><\/font><\/p>\n<p>You don&#8217;t. \ud83d\ude09 Just kidding&#8230; *kinda*&#8230;<\/p>\n<p>So you already know how to cause services to start and stop at various runlevels using the <code>chkconfig<\/code> tool on RedHat (and the RedHat derivatives, which I just refer to as RedHat) and Suse, or the <code>insserv<\/code> tool on Suse. But *now* what you want to do is enforce the service load sequence by number.<\/p>\n<p>&#8220;Ah-hah!&#8221;, you say, because you are an old-school Unix guy (yes, Your Linux Guy knows about you and your ways \ud83d\ude09 ), and you know that all you have to do is hand-write a script, and throw it (or a symlink) into the appropriate <code>rc[?].d<\/code> directory, right? Wrong. Well, you *could* do that, but as soon as you run <code>chkconfig<\/code> on Suse, it will re-order your service based on some other criteria&#8230; more on that in a moment.<\/p>\n<p>First some background on RedHat&#8230;<\/p>\n<p>Many of you are used to the tool <code>chkconfig<\/code>. In order to specify load order in RedHat, you make sure that one important line similar to the following exists in the start script in the <code>\/etc\/rc.d\/init.d<\/code> directory:<\/p>\n<p><code># chkconfig: 35 98 01<\/code><\/p>\n<p>&#8230;note that the leading pound\/hash symbol indicates that it is a comment; this is important. Then, after the <code>chkconfig:<\/code>, the next items are as follows: runlevels in which to start (3 and 5), start sequence number (98, which is very late in the order), and stop\/kill sequence number (01). Yours, of course, will vary. And &#8212; very important here, folks &#8212; you need to run <code>chkconfig<\/code> after your modifications for it to take effect; it goes through and reads all those comments and places things in the appropriate place.<\/p>\n<p>Now, on to the Suse <code>insserv<\/code> method&#8230;<\/p>\n<p>Suse uses a similar philosophy to RedHat&#8217;s <code>chkconfig<\/code> with <code>insserv<\/code> only insofar as there are a certain set of comments in the start script required to enforce start order. However, instead of you having the luxury of being able to specify *the exact number* for the startup script, you only get to specify things that should be started *before* or *after* your script. This will effectively do the same thing with the arrangement, though you might not get the pretty number <code>S98<\/code> you were hoping for.<\/p>\n<p>So, specifically, here is an example comment block with just a reasonable minimum, for a fake application called <code>myapp<\/code>:<\/p>\n<p><code>### BEGIN INIT INFO<br \/>\n# Provides:          myapp<br \/>\n# Required-Start:    $ALL<br \/>\n# Default-Start:     3 5<br \/>\n# Default-Stop:     0 1 2 4 6<br \/>\n# Description:       My App is cool<br \/>\n# Short-Description: My App<br \/>\n### END INIT INFO<\/code><\/p>\n<p>&#8230;this example will cause <code>myapp<\/code> to be one of the last things loaded (the <code>$ALL<\/code> is a special value, see below), in <code>runlevel<\/code> 3 or 5, and will stop at all other levels. On my machine, it puts <code>myapp<\/code> at <code>S21<\/code>, right before <code>S21SuSEfirewall2_setup<\/code>, which is numerically equal, but alphabetically later. And &#8212; just like with RedHat &#8212; you must run <code>chkconfig<\/code> or the Suse tool <code>insserv<\/code> for the scripts to be re-arranged and placed, ready to run. Its important to remember that on Suse, <code>chkconfig<\/code> is just a child to <code>insserv<\/code>, it is not the same exact tool as on RedHat. But like on RedHat, it will parse the comments fields and place the script in the appropriate places.<\/p>\n<p>Now here&#8217;s how that actually works on Suse&#8230;<br \/>\nFor Suse, the &#8220;Provides:&#8221; item in the script creates something called a &#8220;facility&#8221;. So in my example above, I&#8217;ve created a facility called &#8220;<code>myapp<\/code>&#8220;. Then, others scripts can reference that facility in specifying whether they should load before or after. For example, the <code>sshd<\/code> startup script provides a &#8220;<code>sshd<\/code>&#8221; facility (it does not have to be the same name as the daemon), so I could have put the following in my <code>myapp<\/code> script:<\/p>\n<p><code># Required-Start:    $sshd<\/code><\/p>\n<p>&#8230;and then <code>myapp<\/code> would have been placed to start right after <code>sshd<\/code> in the appropriate <code>\/etc\/init.d\/rc[?].d<\/code> directory. On my machine, <code>sshd<\/code> is at <code>S12<\/code>&#8230; so if I did that, <code>myapp<\/code> would likely be at <code>S13<\/code> (the next higher number). Note that the facility is prefixed by a dollar-sign when it referenced\/called, but not when it is created in the &#8220;<code>Provides:<\/code>&#8221; line. Also, the <code>$ALL<\/code> is a special all-inclusive facility value that means &#8220;all facilities&#8221;, and when used, it causes your script to be loaded after all others.<\/p>\n<p>Warning: Some of the startup scripts in Suse have the RedHat <code>chkconfig<\/code> syntax in them. Why? To mess with you. No, not really, but that&#8217;s what it did to me when I was first figuring this stuff out. Especially since Suse has the <code>chkconfig<\/code> binary (which works on Suse to a lesser extent than on RedHat) for your convenience&#8230; and confusion&#8230;<\/p>\n<p>Phew! Got it? Good.<\/p>\n<p>Make sure to let me know if I missed something&#8230;<\/p>\n<p>\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This item inspired by Ken. And in order to keep this answer relatively short, I have to skip a bunch of pre-reqs. I&#8217;m going to assume that you understand service startup and run-levels in Linux, and maybe have tried specifying&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=41\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12,25,15],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-advanced","category-redhat","category-suse"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-F","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":1,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}