mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Set a MySQL password at moulinette installation
This commit is contained in:
parent
784a5f34d7
commit
f285a5edce
1 changed files with 16 additions and 0 deletions
|
@ -13,8 +13,24 @@ function safe_copy () {
|
|||
fi
|
||||
}
|
||||
|
||||
function randpass () {
|
||||
[ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
|
||||
cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
|
||||
echo
|
||||
}
|
||||
|
||||
cd /usr/share/yunohost/templates/mysql
|
||||
|
||||
if [[ "$(safe_copy my.cnf /etc/mysql/my.cnf)" == "True" ]]; then
|
||||
sudo service mysql restart
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/yunohost/mysql ]; then
|
||||
[[ $(/bin/ps aux | grep mysqld | grep -vc "grep") == "0" ]] \
|
||||
&& sudo service mysql start
|
||||
|
||||
mysql_password=$(randpass 10 0)
|
||||
sudo mysqladmin -u root -pyunohost password $mysql_password
|
||||
echo $mysql_password | sudo tee /etc/yunohost/mysql
|
||||
sudo chmod 400 /etc/yunohost/mysql
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue