- /etc/init.d/inspircdを作成 * (CentOS6まで)自作のサービスをchkconfigで登録するを参考にchkconfigに登録出来るようにサービス設定を書いておく必要がある
- chkconfigに登録
- sudo chkconfig --add inspircd
- 自動起動を有効にする
- sudo chkconfig inspircd on
Last active
January 9, 2018 03:39
-
-
Save toshi3221/e98c23247a05a02abe6aa25ec0677fc3 to your computer and use it in GitHub Desktop.
init.d向けinspircdサービス設定ファイル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# chkconfig: 2345 85 15 | |
# description: Inspircd | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
prog="inspircd" | |
path="/usr/local/inspircd-2.0.13/run/bin" | |
cmd="sudo -u rsi ./inspircd start" | |
stop_cmd="sudo -u rsi ./inspircd stop" | |
grep="[i]nspircd" | |
start() { | |
echo -n $"Starting $prog: " | |
cd $path | |
$cmd && success || failure | |
retval=$? | |
echo | |
return $retval | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
$stop_cmd && success || failure | |
retval=$? | |
echo | |
return $retval | |
} | |
restart() { | |
stop | |
start | |
} | |
status() { | |
pid=$(pgrep -f "$grep") | |
if [[ "$pid" =~ [0-9] ]]; then | |
echo "$prog is running..." | |
else | |
echo "$prog is stopped." | |
return 1 | |
fi | |
return 0 | |
} | |
case "$1" in | |
start) | |
status > /dev/null && status && exit 0 | |
$1 | |
;; | |
stop) | |
status > /dev/null || status || exit 0 | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
status) | |
$1 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|status}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment