forked from guysoft/CustomPiOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_chroot_script
More file actions
39 lines (28 loc) · 978 Bytes
/
start_chroot_script
File metadata and controls
39 lines (28 loc) · 978 Bytes
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
#!/usr/bin/env bash
# mysql
# Provides mysql database via mariadb
# Written by Guy Sheffer <guysoft at gmail dot com>
# GPL V3
########
set -x
set -e
source /common.sh
install_cleanup_trap
apt-get update --allow-relreaseinfo-change
apt-get install -y mariadb-server expect
mysqld_safe &
echo "waiting for sql server to go online"
sleep 10
mysql --user=root -e "CREATE USER '"${MYSQL_USER}"'@'localhost' IDENTIFIED BY '${MYSQL_USER_PASSWORD}';"
mysql --user=root -e "GRANT ALL PRIVILEGES ON *.* to 'pi'@'localhost' WITH GRANT OPTION;"
# Debug
# mysql --user=root -e "select user, host, password, plugin, authentication_string from mysql.user;"
# mysql --user=root -e "show grants for '"${MYSQL_USER}"'@'localhost';"
mysqladmin shutdown
# Example to create a new DB
# mysqld_safe &
# echo "waiting for sql server to go online"
# sleep 10
# su pi -c 'mysql --user=pi --password=raspberry -e "CREATE DATABASE dbname;"'
# mysqladmin shutdown
echo "Done installing mysql"