概要
立ち上げた環境にchkconfigがなかったので対応のメモ
事象
chkconfigを叩いたら無いって言われた
$ sudo chkconfig apache2 on
sudo: chkconfig: command not found
環境
vagrantで構築したubuntu
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.6 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.6 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
対応
以下のコマンドで代用
サービスの状態確認
サービスの状態を調べる子tマン度は無いのでlsで確認する
$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc6.d/K09apache2 -> ../init.d/apache2
上記ではランレベル2,3,4,5で起動、0,1,6で停止
指定したランレベルでの停止
$ sudo update-rc.d apache2 disable 2 3 4 5
update-rc.d: warning: start runlevel arguments (none) do not match apache2 Default-Start values (2 3 4 5)
update-rc.d: warning: stop runlevel arguments (none) do not match apache2 Default-Stop values (0 1 6)
Disabling system startup links for /etc/init.d/apache2 ...
Removing any system startup links for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2
/etc/rc1.d/K09apache2
/etc/rc2.d/S91apache2
/etc/rc3.d/S91apache2
/etc/rc4.d/S91apache2
/etc/rc5.d/S91apache2
/etc/rc6.d/K09apache2
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2 -> ../init.d/apache2
/etc/rc1.d/K09apache2 -> ../init.d/apache2
/etc/rc6.d/K09apache2 -> ../init.d/apache2
/etc/rc2.d/K09apache2 -> ../init.d/apache2
/etc/rc3.d/K09apache2 -> ../init.d/apache2
/etc/rc4.d/K09apache2 -> ../init.d/apache2
/etc/rc5.d/K09apache2 -> ../init.d/apache2
# 確認
$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc2.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc3.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc4.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc5.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc6.d/K09apache2 -> ../init.d/apache2
指定したランレベルでの起動
$ sudo update-rc.d apache2 enable 2 3 4 5
update-rc.d: warning: start runlevel arguments (none) do not match apache2 Default-Start values (2 3 4 5)
update-rc.d: warning: stop runlevel arguments (none) do not match apache2 Default-Stop values (0 1 6)
Enabling system startup links for /etc/init.d/apache2 ...
Removing any system startup links for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2
/etc/rc1.d/K09apache2
/etc/rc2.d/K09apache2
/etc/rc3.d/K09apache2
/etc/rc4.d/K09apache2
/etc/rc5.d/K09apache2
/etc/rc6.d/K09apache2
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2 -> ../init.d/apache2
/etc/rc1.d/K09apache2 -> ../init.d/apache2
/etc/rc6.d/K09apache2 -> ../init.d/apache2
/etc/rc2.d/S91apache2 -> ../init.d/apache2
/etc/rc3.d/S91apache2 -> ../init.d/apache2
/etc/rc4.d/S91apache2 -> ../init.d/apache2
/etc/rc5.d/S91apache2 -> ../init.d/apache2
# 確認
$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc6.d/K09apache2 -> ../init.d/apache2
参考
https://gist.github.com/koudaiii/dae08d3cb9c861a1d4b3
https://server-setting.info/debian/debian-like-chkconfig.html