/etc/rc.d/init.d/functionsとは

2015-04-04
memo
functions

分からないことを調べてみるシリーズ。

CentOSで、自前で起動スクリプトを作ることが、何回か続いた。
既存のhttpdとかの起動スクリプトを元にして作るが、以下の記述が気になった。

. /etc/rc.d/init.d/functions

つまり、functionsというスクリプトを読み込んでいるのだが、これは、一体何をするものだろう??

中身を見る。

実際に、中を見てみると、一目瞭然でした。
起動スクリプトで使える便利な関数が満載でした。

便利な関数が一杯・・・つまりfunctionsということですね。
どんな関数があるかを下記に列挙してみました。 確かに、起動スクリプト内で使われていました。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fstab_decode_str()
checkpid()
__readlink()
__fgrep()
__umount_loop()
__umount_loopback_loop()
__pids_var_run()
__pids_pidof()
daemon()
killproc()
pidfileofproc()
pidofproc()
status()
echo_success()
echo_failure()
echo_passed()
echo_warning()
update_boot_stage()
success()
failure()
passed()
warning()
action()
strstr()
confirm()
get_numeric_dev()
is_ignored_file()
is_true()
is_false()
apply_sysctl()
key_is_random()
find_crypto_mount_point()
init_crypto()

※CentOS release 6.5です。