elementary OSの終了時と、起動時にシェルを実行する方法。

システム終了時(再起動時)に、シェルを自動実行する方法は、下記のように設定する。
[crayon]

# vi /etc/init.d/rc
——————————————————————————————
#! /bin/sh
#
# rc
#
# Starts/stops services on runlevel changes.
#
# Optimization: A start script is not run when the service was already
# configured to run in the previous runlevel.  A stop script is not run
# when the the service was already configured not to run in the previous
# runlevel.
#
# Authors:
#       Miquel van Smoorenburg <miquels@cistron.nl>
#       Bruce Perens <Bruce@Pixar.com>
##################################################
# 下記の例のように、このシェルの頭のところあたりに、下記の三行を追加する。
if test x$RUNLEVEL = x0 -o x$RUNLEVEL = x6 ; then
su -c “/root/stop-reboot.sh”
fi
##################################################
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

# Un-comment the following for interactive debugging. Do not un-comment
….
….
….
[/crayon]
システム起動時に、シェルを自動実行する方法は、下記のように設定する。

[crayon]

# vi /etc/rc.local
——————————————————————————————

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
##############################################
# 下記の”exit 0″の前に、シェルなどを書き足せばおk。
su -c “/root/start.sh”
##############################################
exit 0
[/crayon]

参照:http://wikiwiki.jp/disklessfun/?exec-cmd