Newer
Older
nextcloud / generate_password.sh
#!/bin/bash

if [ ! -f "db.conf" ]; then
	cp db.conf.example db.conf

	pw1=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
	pw2=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)

	sed -i "/^MYSQL_PASSWORD/c\\\MYSQL_PASSWORD=${pw1}" db.conf
	sed -i "/^MYSQL_ROOT_PASSWORD/c\\\MYSQL_ROOT_PASSWORD=${pw2}" db.conf
else
	echo "db.conf already exists!"
fi

if [ ! -f "cloud.conf" ]; then
	cp cloud.conf.example cloud.conf

	pw1=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)

	sed -i "/^NEXTCLOUD_ADMIN_PASSWORD/c\\\NEXTCLOUD_ADMIN_PASSWORD=${pw1}" cloud.conf
else
	echo "cloud.conf already exists!"
fi