-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathss-perms-mysql-config.txt
115 lines (84 loc) · 5.68 KB
/
ss-perms-mysql-config.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
####################################################################################################
#### author: SlickStack ############################################################################
#### link: https://slickstack.io ###################################################################
#### mirror: littlebizzy/slickstack/blob/master/bash/ss-perms-mysql-config.txt #####################
#### path: /var/www/ss-perms-mysql-config ##########################################################
#### destination: n/a (not a boilerplate) ##########################################################
#### purpose: Resets file and user permissions for MySQL module configuration files ################
#### module version: MySQL 8.0.x ###################################################################
#### sourced by: ss-install-mysql-config, ss-perms #################################################
#### bash aliases: ss perms mysql config ###########################################################
####################################################################################################
## source ss-config ##
source /var/www/ss-config
## source ss-functions ##
source /var/www/ss-functions
## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS
####################################################################################################
#### TABLE OF CONTENTS (SS-Perms-MySQL-Config) #####################################################
####################################################################################################
## this is a brief summary of the different code snippets you will find in this script ##
## each section should be commented so you understand what is being accomplished ##
## A. Touch Timestamp File
## B. Message (Begin Script)
## C. Reset Permissions (MySQL Config)
####################################################################################################
#### A. SS-Perms-MySQL-Config: Touch Timestamp File ################################################
####################################################################################################
## this is a dummy timestamp file that will remember the last time this script was run ##
## it can be useful for developer reference and is sometimes used by SlickStack ##
ss_touch "${TIMESTAMP_SS_PERMS_MYSQL_CONFIG}"
####################################################################################################
#### B. SS-Perms-MySQL-Config: Message (Begin Script) ##############################################
####################################################################################################
## this is a simple message that announces to the shell the purpose of this bash script ##
## it will only be seen by sudo users who manually run this script in the shell ##
ss_echo "${COLOR_INFO}Running ss-perms-mysql-config... ${COLOR_RESET}"
####################################################################################################
#### C. SS-Perms-MySQL-Config: Reset Permissions (MySQL Config) ####################################
####################################################################################################
## ADD IF STATEMENT to reset perms for mysql client instead of mysql server when ss remote database is true
if [[ "${DB_REMOTE}" != "true" ]]; then
# ss_mkdir /var/run/mysqld
# chmod -R 0775 /var/run/mysqld
# chown mysql:mysql /var/lib/mysql ## drwx------
# chown mysql:mysql /var/lib/mysql-files ## drwx------
# chown mysql:mysql /var/lib/mysql-keyring ## drwx------
# chown root:root /var/lib/mysql-upgrade ## must be root:root ## drwxr-xr-x
## create MySQL log files if they do not exist ##
if [ ! -f "/var/www/logs/mysql-gen.log" ]; then ss_touch "/var/www/logs/mysql-gen.log"; fi
if [ ! -f "/var/www/logs/mysql-error.log" ]; then ss_touch "/var/www/logs/mysql-error.log"; fi
if [ ! -f "/var/www/logs/mysql-slow.log" ]; then ss_touch "/var/www/logs/mysql-slow.log"; fi
ss_mkdir /var/run/mysqld
## reset MySQL permissions ##
chown mysql:mysql /var/run/mysqld
chown root:root /etc/mysql/my.cnf ## symlink to /etc/alternatives/my.cnf
chown root:root /etc/mysql/mysql.cnf
chown root:root /etc/mysql/mysql.conf.d/mysqld.cnf
chmod 0755 /etc/mysql/my.cnf
chown mysql:mysql /var/www/logs/mysql*.log*
chmod 0644 /var/www/logs/*.log ## 6755 should also work
## SAFE MODE reset permissions ##
# ss_mkdir /var/run/mysqld
# chmod -R 775 /var/run/mysqld
fi
####################################################################################################
#### SlickStack: Reset Permissions (SlickStack Scripts) ############################################
####################################################################################################
## we include this permissions reset in all cron jobs and bash scripts for redundancy ##
## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ##
## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS
## SNIPPET: ss bash scripts, ss cron jobs
## UPDATED: 02JUL2022
chown root:root /var/www/ss* ## must be root:root
chown root:root /var/www/crons/*cron* ## must be root:root
chown root:root /var/www/crons/custom/*cron* ## must be root:root
chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute
####################################################################################################
#### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ###############
####################################################################################################
## Ref:
## SS_EOF