Gentoo Archives: gentoo-commits

From: "Brian Evans (grknight)" <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-db/mysql-init-scripts/files: log-s6 init.d-s6 run-s6
Date: Wed, 27 May 2015 17:02:34
Message-Id: 20150527170226.81754A0E@oystercatcher.gentoo.org
1 grknight 15/05/27 17:02:26
2
3 Added: log-s6 init.d-s6 run-s6
4 Log:
5 Add new version with s6 supervisor support
6
7 (Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key D1F781EFF9F4A3B6)
8
9 Revision Changes Path
10 1.1 dev-db/mysql-init-scripts/files/log-s6
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/log-s6?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/log-s6?rev=1.1&content-type=text/plain
14
15 Index: log-s6
16 ===================================================================
17 #!/bin/sh
18 # Copyright 1999-2015 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/log-s6,v 1.1 2015/05/27 17:02:26 grknight Exp $
21
22 SVCNAME=$(cd `dirname $0` && pwd | awk -F/ '{ print $--NF }' )
23 mkdir -p "/var/log/mysql/${SVCNAME}"
24 if [ ${S6_LOG_OPTIONS} ] ; then
25 exec s6-log ${S6_LOG_OPTIONS}
26 else
27 exec s6-log -b n20 S15000000 !"gzip -nq9" "/var/log/mysql/${SVCNAME}"
28 fi
29
30
31
32 1.1 dev-db/mysql-init-scripts/files/init.d-s6
33
34 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/init.d-s6?rev=1.1&view=markup
35 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/init.d-s6?rev=1.1&content-type=text/plain
36
37 Index: init.d-s6
38 ===================================================================
39 #!/sbin/openrc-run
40 # Copyright 1999-2015 Gentoo Foundation
41 # Distributed under the terms of the GNU General Public License v2
42 # $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/init.d-s6,v 1.1 2015/05/27 17:02:26 grknight Exp $
43
44 depend() {
45 use net.lo
46 # localmount needed for $basedir
47 need localmount s6-svscan
48 }
49
50 get_config() {
51 my_print_defaults --config-file="$1" mysqld |
52 sed -n -e "s/^--$2=//p"
53 }
54
55 mysql_svcname() {
56 local ebextra=
57 case "${SVCNAME}" in
58 mysql*) ;;
59 *) ebextra=" (mysql)" ;;
60 esac
61 echo "${SVCNAME}${ebextra}"
62 }
63
64 extra_commands="checkconfig"
65 supervisor=s6
66 name=$(mysql_svcname)
67 s6_service_timeout_stop="$((1000*${STOP_TIMEOUT:-120}))"
68 #s6_svwait_options_start="-U -t $((1000*${STARTUP_EARLY_TIMEOUT:-1000}))"
69
70 start_pre() {
71 # Check the config or die
72 checkconfig || return 1
73
74 MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
75
76 if [ ! -r "${MY_CNF}" ] ; then
77 eerror "Cannot read the configuration file \`${MY_CNF}'"
78 return 1
79 fi
80
81 # tail -n1 is critical as these we only want the last instance of the option
82 local datadir=$(get_config "${MY_CNF}" datadir | tail -n1)
83 local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
84 local socket=$(get_config "${MY_CNF}" socket | tail -n1)
85 local chroot=$(get_config "${MY_CNF}" chroot | tail -n1)
86
87 if [ -n "${chroot}" ] ; then
88 socket="${chroot}/${socket}"
89 pidfile="${chroot}/${pidfile}"
90 fi
91
92 if [ ! -d "${datadir}" ] ; then
93 eerror "MySQL datadir \`${datadir}' is empty or invalid"
94 eerror "Please check your config file \`${MY_CNF}'"
95 return 1
96 fi
97
98 if [ ! -d "${datadir}"/mysql ] ; then
99 # find which package is installed to report an error
100 local EROOT=$(portageq envvar EROOT)
101 local DBPKG_P=$(portageq match ${EROOT} $(portageq expand_virtual ${EROOT} virtual/mysql))
102 if [ -z ${DBPKG_P} ] ; then
103 eerror "You don't appear to have a server package installed yet."
104 else
105 eerror "You don't appear to have the mysql database installed yet."
106 eerror "Please run \`emerge --config =${DBPKG_P}\` to have this done..."
107 fi
108 return 1
109 fi
110
111 local piddir="${pidfile%/*}"
112 checkpath -d --owner mysql:mysql --mode 0755 "$piddir"
113 rc=$?
114 if [ $rc -ne 0 ]; then
115 eerror "Directory $piddir for pidfile does not exist and cannot be created"
116 return 1
117 fi
118 }
119
120 start_post() {
121 local socket=$(get_config "${MY_CNF}" socket | tail -n1)
122 local chroot=$(get_config "${MY_CNF}" chroot | tail -n1)
123 local startup_timeout=${STARTUP_TIMEOUT:-900}
124
125 if [ -n "${chroot}" ] ; then
126 socket="${chroot}/${socket}"
127 fi
128 ewaitfile ${startup_timeout} "${socket}"
129 }
130
131 checkconfig() {
132 local my_cnf="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
133 local basedir=$(get_config "${my_cnf}" basedir | tail -n1)
134 local svc_name=$(mysql_svcname)
135 ebegin "Checking mysqld configuration for ${svc_name}"
136
137 if [ ${RC_CMD} = "checkconfig" ] ; then
138 # We are calling checkconfig specifically. Print warnings regardless.
139 "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null
140 else
141 # Suppress output to check the return value
142 "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null 2>&1
143
144 # If the above command does not return 0,
145 # then there is an error to echo to the user
146 if [ $? -ne 0 ] ; then
147 "${basedir}"/sbin/mysqld --defaults-file="${my_cnf}" --help --verbose > /dev/null
148 fi
149 fi
150
151 eend $? "${svc_name} config check failed"
152 }
153
154 # vim: filetype=gentoo-init-d sw=2 ts=2 sts=2 noet:
155
156
157
158
159 1.1 dev-db/mysql-init-scripts/files/run-s6
160
161 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/run-s6?rev=1.1&view=markup
162 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/mysql-init-scripts/files/run-s6?rev=1.1&content-type=text/plain
163
164 Index: run-s6
165 ===================================================================
166 #!/bin/sh
167 # Copyright 1999-2015 Gentoo Foundation
168 # Distributed under the terms of the GNU General Public License v2
169 # $Header: /var/cvsroot/gentoo-x86/dev-db/mysql-init-scripts/files/run-s6,v 1.1 2015/05/27 17:02:26 grknight Exp $
170
171 get_config() {
172 my_print_defaults --config-file="$1" mysqld |
173 sed -n -e "s/^--$2=//p"
174 }
175
176 SVCNAME=$(cd `dirname $0` && pwd | awk -F/ '{ print $NF }' )
177
178 source "${ROOT:-/}etc/conf.d/${SVCNAME}"
179
180 MY_CNF="${MY_CNF:-/etc/${SVCNAME}/my.cnf}"
181
182 basedir=$(get_config "${MY_CNF}" basedir | tail -n1)
183 exec "${basedir}"/sbin/mysqld --defaults-file="${MY_CNF}" ${MY_ARGS} 2>&1