Skip to content

Instantly share code, notes, and snippets.

@hyunto
Last active March 29, 2019 04:15
Show Gist options
  • Save hyunto/fefda58099ef87793fb8a7d68d8a12e8 to your computer and use it in GitHub Desktop.
Save hyunto/fefda58099ef87793fb8a7d68d8a12e8 to your computer and use it in GitHub Desktop.
미완성
#! /bin/sh
### BEGIN INIT INFO
# Provides: docker
# Required-Start: $network $named $remote_fs $syslog iptables
# Required-Stop: $network $named $remote_fs $syslog iptables
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: dockerd
# Description: Manage docker daemon.
### END INIT INFO
#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="dockerd"
PID_PATH="/var/run/"
PID_FILE="$PID_PATH/docker.pid"
LOG_FILE="/var/log/dockerd.log"
DATA_ROOT="/data/apps/"
CONFIG_PATH="/etc/docker"
CONFIG_FILE="$CONFIG_PATH/daemon.json"
DAEMON="/data/apps/docker/default/dockerd"
DAEMON_OPTS=""
#DAEMON_OPTS+="-H fd:// "
DAEMON_OPTS+="--data-root $DATA_ROOT -p $PID_FILE "
#DAEMON_OPTS+="--config-file $CONFIG_FILE "
start() {
if [ ! -d $DATA_PATH ]; then
echo "$(tput setaf 1)[Error] Directory for storing data does not exist : $DATA_PATH $(tput sgr 0)"
exit 1
fi
if [ ! -d $CONFIG_PATH ]; then
mkdir $CONFIG_PATH
fi
if [ ! -d $PID_PATH ]; then
mkdir $PID_PATH
fi
$DAEMON $DAEMON_OPTS >> $LOG_FILE 2>&1
echo "$DESC started : `date`" >> $LOG_FILE 2>&1
}
stop() {
PID=`cat $PID_FILE`
if [ ! $PID -eq ""]; then
kill TERM -s $PID
rm -rf $PID_FILE
else
echo "$(tput setaf 1)[Error] Docker was not started."
fi
echo "$DESC stoped : `date`" >> $LOG_FILE 2>&1
}
status() {
status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
}
case "$1" in
start)
echo "Starting $DESC"
start
echo $?
;;
stop)
echo "Stopping $DESC"
stop
echo $?
;;
status)
status
;;
restart|force-reload)
echo "Restarting $DESC"
stop
start
echo $?
;;
*)
echo "Usage: $0 {start|stop|status|restart}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment