Browse Source

Run irssi as a daemon

Bob Mottram 11 years ago
parent
commit
abe166a492
4 changed files with 199 additions and 1 deletions
  1. 199
    1
      beaglebone.txt
  2. BIN
      images/logo.png
  3. BIN
      images/logo120.png
  4. BIN
      images/logo60.png

+ 199
- 1
beaglebone.txt View File

2092
 service hybserv start
2092
 service hybserv start
2093
 #+END_SRC
2093
 #+END_SRC
2094
 
2094
 
2095
-*** Usage
2095
+*** Usage with Irssi
2096
 
2096
 
2097
 On another computer (not the BBB).
2097
 On another computer (not the BBB).
2098
 
2098
 
2141
 
2141
 
2142
 If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
2142
 If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
2143
 
2143
 
2144
+*** Usage with XChat
2145
+TODO
2146
+*** Install Irssi as a daemon
2147
+
2148
+If you wish to be able to log into the BBB via ssh and access IRC that way then you can create an Irssi deamon.  Note that this is only really appropriate for a single administrator user, not for a situation in which there are multiple users on the BBB.
2149
+
2150
+Install some prerequisites.
2151
+
2152
+#+BEGIN_SRC: bash
2153
+apt-get install irssi screen
2154
+#+END_SRC
2155
+
2156
+Create an initialisation script.
2157
+
2158
+#+BEGIN_SRC: bash
2159
+emacs /etc/init.d/irssid
2160
+#+END_SRC
2161
+
2162
+Add the following:
2163
+
2164
+#+BEGIN_SRC: bash
2165
+#!/bin/bash
2166
+
2167
+### BEGIN INIT INFO
2168
+# Provides:          irssid
2169
+# Required-Start:    $network
2170
+# Required-Stop:     $network
2171
+# Default-Start:     2 3 4 5
2172
+# Default-Stop:      0 1 6
2173
+# Short-Description: Start irssi daemon within screen session at boot time
2174
+# Description:       This init script will start an irssi session under screen using the settings provided in /etc/irssid.conf
2175
+### END INIT INFO
2176
+
2177
+# Include the LSB library functions
2178
+. /lib/lsb/init-functions
2179
+
2180
+# Setup static variables
2181
+configFile='/etc/irssid.conf'
2182
+daemonExec='/usr/bin/screen'
2183
+daemonArgs='-D -m'
2184
+daemonName="$(basename "$daemonExec")"
2185
+pidFile='/var/run/irssid.pid'
2186
+
2187
+#
2188
+# Checks if the environment is capable of running the script (such as
2189
+# availability of programs etc).
2190
+#
2191
+# Return: 0 if the environmnt is properly setup for execution of init script, 1
2192
+#         if not all conditions have been met.
2193
+#
2194
+function checkEnvironment() {
2195
+    # Verify that the necessary binaries are available for execution.
2196
+    local binaries=(irssi screen)
2197
+
2198
+    for bin in "${binaries[@]}"; do
2199
+        if ! which "$bin" > /dev/null; then
2200
+            log_failure_msg "Binary '$bin' is not available. Please install \
2201
+package containing it."
2202
+            exit 5
2203
+        fi
2204
+    done
2205
+}
2206
+
2207
+#
2208
+# Checks if the configuration files are available and properly setup.
2209
+#
2210
+# Return: 0 if irssid if properly configured, 1 otherwise.
2211
+#
2212
+function checkConfig() {
2213
+    # Make sure the configuration file has been created
2214
+    if ! [[ -f $configFile ]]; then
2215
+        log_failure_msg "Please populate the configuration file '$configFile' \
2216
+before running."
2217
+        exit 6
2218
+    fi
2219
+
2220
+    # Make sure the required options have been set
2221
+    local reqOptions=(user group session)
2222
+    for option in "${reqOptions[@]}"; do
2223
+        if ! grep -q -e "^[[:blank:]]*$option=" "$configFile"; then
2224
+            log_failure_msg "Mandatory option '$option' was not specified in \
2225
+'$configFile'"
2226
+            exit 6
2227
+        fi
2228
+    done
2229
+}
2230
+
2231
+#
2232
+# Loads the configuration file and performs any additional configuration steps.
2233
+#
2234
+function configure() {
2235
+    . "$configFile"
2236
+    daemonArgs="$daemonArgs -S $session irssi"
2237
+    [[ -n $args ]] && daemonArgs="$daemonArgs $args"
2238
+    daemonCommand="$daemonExec $daemonArgs"
2239
+}
2240
+
2241
+#
2242
+# Starts the daemon.
2243
+#
2244
+# Return: LSB-compliant code.
2245
+#
2246
+function start() {
2247
+    start-stop-daemon --start --quiet --oknodo --pidfile "$pidFile" \
2248
+        --make-pidfile --chuid "$user:$group" --background \
2249
+        --exec "$daemonExec" -- $daemonArgs
2250
+}
2251
+
2252
+#
2253
+# Stops the daemon.
2254
+#
2255
+# Return: LSB-compliant code.
2256
+#
2257
+function stop() {
2258
+    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "$pidFile" \
2259
+        --chuid "$user:$group" --exec "$daemonExec" -- $daemonArgs
2260
+}
2261
+
2262
+checkEnvironment
2263
+checkConfig
2264
+configure
2265
+
2266
+case "$1" in
2267
+    start)
2268
+        log_daemon_msg "Starting daemon" "irssid"
2269
+        start && log_end_msg 0 || log_end_msg $?
2270
+        ;;
2271
+    stop)
2272
+        log_daemon_msg "Stopping daemon" "irssid"
2273
+        stop && log_end_msg 0 || log_end_msg $?
2274
+        ;;
2275
+    restart)
2276
+        log_daemon_msg "Restarting daemon" "irssid"
2277
+        stop
2278
+        start && log_end_msg 0 || log_end_msg $?
2279
+        ;;
2280
+    force-reload)
2281
+        log_daemon_msg "Restarting daemon" "irssid"
2282
+        stop
2283
+        start && log_end_msg 0 || log_end_msg $?
2284
+        ;;
2285
+    status)
2286
+        status_of_proc -p "$pidFile" "$daemonExec" screen && exit 0 || exit $?
2287
+        ;;
2288
+    *)
2289
+        echo "irssid (start|stop|restart|force-reload|status|help)"
2290
+        ;;
2291
+esac
2292
+#+END_SRC
2293
+
2294
+Save and exit.
2295
+
2296
+#+BEGIN_SRC: bash
2297
+chmod +x /etc/init.d/irssid
2298
+#+END_SRC
2299
+
2300
+Create a configuration file, replacing /myusername/ with your username.
2301
+
2302
+#+BEGIN_SRC: bash
2303
+emacs /etc/irssid.conf
2304
+#+END_SRC
2305
+
2306
+#+BEGIN_SRC: bash
2307
+#
2308
+# Configuration file for irssid init script
2309
+#
2310
+# Mandatory options:
2311
+#
2312
+#    user    - Specify user for running irssi.
2313
+#    group   - Specify group for running irssi.
2314
+#    session - Specify screen session name to be used for irssi.
2315
+#
2316
+# Non-mandatory options:
2317
+#
2318
+#    args    - Pass additional arguments to irssi.
2319
+#
2320
+
2321
+user='myusername'
2322
+group='irssi'
2323
+session='irssi'
2324
+args='--config /home/myusername/.irssi/config'
2325
+#+END_SRC
2326
+
2327
+Save and exit.  Then add your user to the irssi group and start the daemon.
2328
+
2329
+#+BEGIN_SRC: bash
2330
+groupadd irssi
2331
+usermod -aG irssi myusername
2332
+update-rc.d irssid defaults
2333
+service irssid start
2334
+#+END_SRC
2335
+
2336
+Then to subsequently access irssi log into the BBB using ssh and type:
2337
+
2338
+#+BEGIN_SRC: bash
2339
+screen -t irssi irssi
2340
+#+END_SRC
2341
+
2144
 ** Install a Jabber/XMPP server
2342
 ** Install a Jabber/XMPP server
2145
 
2343
 
2146
 #+BEGIN_VERSE
2344
 #+BEGIN_VERSE

BIN
images/logo.png View File


BIN
images/logo120.png View File


BIN
images/logo60.png View File