]> pere.pagekite.me Git - homepage.git/blob - blog/archive/2013/11/11.rss
Generated.
[homepage.git] / blog / archive / 2013 / 11 / 11.rss
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries from November 2013</title>
5 <description>Entries from November 2013</description>
6 <link>http://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>Debian init.d boot script example for rsyslog</title>
11 <link>http://people.skolelinux.org/pere/blog/Debian_init_d_boot_script_example_for_rsyslog.html</link>
12 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Debian_init_d_boot_script_example_for_rsyslog.html</guid>
13 <pubDate>Sat, 2 Nov 2013 22:40:00 +0100</pubDate>
14 <description>&lt;p&gt;If one of the points of switching to a new init system in Debian is
15 &lt;a href=&quot;http://thomas.goirand.fr/blog/?p=147&quot;&gt;to get rid of huge
16 init.d scripts&lt;/a&gt;, I doubt we need to switch away from sysvinit and
17 init.d scripts at all. Here is an example init.d script, ie a rewrite
18 of /etc/init.d/rsyslog:&lt;/p&gt;
19
20 &lt;p&gt;&lt;pre&gt;
21 #!/lib/init/init-d-script
22 ### BEGIN INIT INFO
23 # Provides: rsyslog
24 # Required-Start: $remote_fs $time
25 # Required-Stop: umountnfs $time
26 # X-Stop-After: sendsigs
27 # Default-Start: 2 3 4 5
28 # Default-Stop: 0 1 6
29 # Short-Description: enhanced syslogd
30 # Description: Rsyslog is an enhanced multi-threaded syslogd.
31 # It is quite compatible to stock sysklogd and can be
32 # used as a drop-in replacement.
33 ### END INIT INFO
34 DESC=&quot;enhanced syslogd&quot;
35 DAEMON=/usr/sbin/rsyslogd
36 &lt;/pre&gt;&lt;/p&gt;
37
38 &lt;p&gt;Pretty minimalistic to me... For the record, the original sysv-rc
39 script was 137 lines, and the above is just 15 lines, most of the meta
40 info/comments.&lt;/p&gt;
41
42 &lt;p&gt;How to do this, you ask? Well, one create a new script
43 /lib/init/init-d-script looking something like this:
44
45 &lt;p&gt;&lt;pre&gt;
46 #!/bin/sh
47
48 # Define LSB log_* functions.
49 # Depend on lsb-base (&gt;= 3.2-14) to ensure that this file is present
50 # and status_of_proc is working.
51 . /lib/lsb/init-functions
52
53 #
54 # Function that starts the daemon/service
55
56 #
57 do_start()
58 {
59 # Return
60 # 0 if daemon has been started
61 # 1 if daemon was already running
62 # 2 if daemon could not be started
63 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test &gt; /dev/null \
64 || return 1
65 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
66 $DAEMON_ARGS \
67 || return 2
68 # Add code here, if necessary, that waits for the process to be ready
69 # to handle requests from services started subsequently which depend
70 # on this one. As a last resort, sleep for some time.
71 }
72
73 #
74 # Function that stops the daemon/service
75 #
76 do_stop()
77 {
78 # Return
79 # 0 if daemon has been stopped
80 # 1 if daemon was already stopped
81 # 2 if daemon could not be stopped
82 # other if a failure occurred
83 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
84 RETVAL=&quot;$?&quot;
85 [ &quot;$RETVAL&quot; = 2 ] &amp;&amp; return 2
86 # Wait for children to finish too if this is a daemon that forks
87 # and if the daemon is only ever run from this initscript.
88 # If the above conditions are not satisfied then add some other code
89 # that waits for the process to drop all resources that could be
90 # needed by services started subsequently. A last resort is to
91 # sleep for some time.
92 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
93 [ &quot;$?&quot; = 2 ] &amp;&amp; return 2
94 # Many daemons don&#39;t delete their pidfiles when they exit.
95 rm -f $PIDFILE
96 return &quot;$RETVAL&quot;
97 }
98
99 #
100 # Function that sends a SIGHUP to the daemon/service
101 #
102 do_reload() {
103 #
104 # If the daemon can reload its configuration without
105 # restarting (for example, when it is sent a SIGHUP),
106 # then implement that here.
107 #
108 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
109 return 0
110 }
111
112 SCRIPTNAME=$1
113 scriptbasename=&quot;$(basename $1)&quot;
114 echo &quot;SN: $scriptbasename&quot;
115 if [ &quot;$scriptbasename&quot; != &quot;init-d-library&quot; ] ; then
116 script=&quot;$1&quot;
117 shift
118 . $script
119 else
120 exit 0
121 fi
122
123 NAME=$(basename $DAEMON)
124 PIDFILE=/var/run/$NAME.pid
125
126 # Exit if the package is not installed
127 #[ -x &quot;$DAEMON&quot; ] || exit 0
128
129 # Read configuration variable file if it is present
130 [ -r /etc/default/$NAME ] &amp;&amp; . /etc/default/$NAME
131
132 # Load the VERBOSE setting and other rcS variables
133 . /lib/init/vars.sh
134
135 case &quot;$1&quot; in
136 start)
137 [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Starting $DESC&quot; &quot;$NAME&quot;
138 do_start
139 case &quot;$?&quot; in
140 0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;
141 2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;
142 esac
143 ;;
144 stop)
145 [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Stopping $DESC&quot; &quot;$NAME&quot;
146 do_stop
147 case &quot;$?&quot; in
148 0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;
149 2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;
150 esac
151 ;;
152 status)
153 status_of_proc &quot;$DAEMON&quot; &quot;$NAME&quot; &amp;&amp; exit 0 || exit $?
154 ;;
155 #reload|force-reload)
156 #
157 # If do_reload() is not implemented then leave this commented out
158 # and leave &#39;force-reload&#39; as an alias for &#39;restart&#39;.
159 #
160 #log_daemon_msg &quot;Reloading $DESC&quot; &quot;$NAME&quot;
161 #do_reload
162 #log_end_msg $?
163 #;;
164 restart|force-reload)
165 #
166 # If the &quot;reload&quot; option is implemented then remove the
167 # &#39;force-reload&#39; alias
168 #
169 log_daemon_msg &quot;Restarting $DESC&quot; &quot;$NAME&quot;
170 do_stop
171 case &quot;$?&quot; in
172 0|1)
173 do_start
174 case &quot;$?&quot; in
175 0) log_end_msg 0 ;;
176 1) log_end_msg 1 ;; # Old process is still running
177 *) log_end_msg 1 ;; # Failed to start
178 esac
179 ;;
180 *)
181 # Failed to stop
182 log_end_msg 1
183 ;;
184 esac
185 ;;
186 *)
187 echo &quot;Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}&quot; &gt;&amp;2
188 exit 3
189 ;;
190 esac
191
192 :
193 &lt;/pre&gt;&lt;/p&gt;
194
195 &lt;p&gt;It is based on /etc/init.d/skeleton, and could be improved quite a
196 lot. I did not really polish the approach, so it might not always
197 work out of the box, but you get the idea. I did not try very hard to
198 optimize it nor make it more robust either.&lt;/p&gt;
199
200 &lt;p&gt;A better argument for switching init system in Debian than reducing
201 the size of init scripts (which is a good thing to do anyway), is to
202 get boot system that is able to handle the kernel events sensibly and
203 robustly, and do not depend on the boot to run sequentially. The boot
204 and the kernel have not behaved sequentially in year.&lt;/p&gt;
205 </description>
206 </item>
207
208 <item>
209 <title>Browser plugin for SPICE (spice-xpi) uploaded to Debian</title>
210 <link>http://people.skolelinux.org/pere/blog/Browser_plugin_for_SPICE__spice_xpi__uploaded_to_Debian.html</link>
211 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Browser_plugin_for_SPICE__spice_xpi__uploaded_to_Debian.html</guid>
212 <pubDate>Fri, 1 Nov 2013 11:00:00 +0100</pubDate>
213 <description>&lt;p&gt;&lt;a href=&quot;http://www.spice-space.org/&quot;&gt;The SPICE protocol&lt;/a&gt; for
214 remote display access is the preferred solution with oVirt and RedHat
215 Enterprise Virtualization, and I was sad to discover the other day
216 that the browser plugin needed to use these systems seamlessly was
217 missing in Debian. The &lt;a href=&quot;http://bugs.debian.org/668284&quot;&gt;request
218 for a package&lt;/a&gt; was from 2012-04-10 with no progress since
219 2013-04-01, so I decided to wrap up a package based on the great work
220 from Cajus Pollmeier and put it in a collab-maint maintained git
221 repository to get a package I could use. I would very much like
222 others to help me maintain the package (or just take over, I do not
223 mind), but as no-one had volunteered so far, I just uploaded it to
224 NEW. I hope it will be available in Debian in a few days.&lt;/p&gt;
225
226 &lt;p&gt;The source is now available from
227 &lt;a href=&quot;http://anonscm.debian.org/gitweb/?p=collab-maint/spice-xpi.git;a=summary&quot;&gt;http://anonscm.debian.org/gitweb/?p=collab-maint/spice-xpi.git;a=summary&lt;/a&gt;.&lt;/p&gt;
228 </description>
229 </item>
230
231 </channel>
232 </rss>