Newer
Older
nextcloud / generate_password.sh
@Pascal Gollor Pascal Gollor on 1 Apr 2021 583 bytes fix file ending
#!/bin/bash

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

	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.env
	sed -i "/^MYSQL_ROOT_PASSWORD/c\\\MYSQL_ROOT_PASSWORD=${pw2}" db.env
else
	echo "db.env already exists!"
fi

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

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

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