Skip to content

Instantly share code, notes, and snippets.

@toshi3221
Last active January 9, 2018 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshi3221/e98c23247a05a02abe6aa25ec0677fc3 to your computer and use it in GitHub Desktop.
Save toshi3221/e98c23247a05a02abe6aa25ec0677fc3 to your computer and use it in GitHub Desktop.
init.d向けinspircdサービス設定ファイル

サービスに登録する手順

#!/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