Debian Codegraph @

scripts/mariadb-service-convert

raw
1 #!/bin/bash
2 # Copyright (c) 2015, Daniel Black. All rights reserved.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
16 #
17 # PURPOSE:
18 #
19 # Used to generate a mariadb.service file based on the current mysql/mariadb settings
20 #
21 # This is to assist distro maintainers in migrating to systemd service definations from
22 # a user mysqld_safe settings in the my.cnf files.
23 #
24 # Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
25
26 tz_old=$TZ
27
28 . /usr/bin/mariadbd-safe --dry-run
29
30 echo "# converted using $0"
31 echo "#"
32 echo
33
34 echo '[Service]'
35
36 echo
37
38
39 if [[ ( ! -z "$user" && "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then
40 echo User=$user
41 fi
42
43
44 [ -n "${open_files}" ] && echo LimitNOFILE=$open_files
45 [ -n "${core_file_size}" ] && echo LimitCORE=$core_file_size
46 [[ "${niceness}" -gt 0 ]] && echo Nice=$niceness
47 [ "${TZ}" != "${tz_old}" ] && echo Environment=\"TZ=${TZ}\"
48
49 if [ -n "$mysqld_ld_preload" ]; then
50 new_text="$mysqld_ld_preload"
51 [ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD"
52 echo Environment=\"LD_PRELOAD=`shell_quote_string "$new_text"`\"
53 fi
54
55 if [ -n "$mysqld_ld_library_path" ]; then
56 new_text="$mysqld_ld_library_path"
57 [ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH"
58 echo Environment=\"LD_LIBRARY_PATH=`shell_quote_string "$new_text"`\"
59 fi
60
61 if [[ $want_syslog -eq 1 ]]; then
62 echo StandardOutput=syslog
63 echo StandardError=syslog
64 echo SyslogFacility=daemon
65 echo SyslogLevel=err
66 echo SyslogIdentifier=${syslog_tag_mysqld}
67 fi
68
69 if [[ "${flush_caches}" -gt 0 ]]; then
70 echo ExecStartPre=/usr/bin/sync
71 echo ExecStartPre=/usr/sbin/sysctl -q -w vm.drop_caches=3
72 fi
73
74 if [[ "${numa_interleave}" -gt 0 ]]; then
75 echo
76 echo ExecStart=/usr/bin/numactl --interleave=all ${cmd} '${MYSQLD_OPTS}'
77 echo
78 fi
79
80 if [ -n "${CRASH_SCRIPT}" ]; then
81 echo FailureAction=${CRASH_SCRIPT}
82 fi