-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
random password provisioning on boot/startup
During bootup of a new docker image, the redis password might not match the nextcloud configuration. Hence, we automatically update the nextcloud configuration. For the MariaDB password the same method is applied. Additionaly identical files have been moved to docker-common to simplify changes in the future
- Loading branch information
1 parent
648f53b
commit a9a1809
Showing
18 changed files
with
76 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# this script runs at startup to provide an unique random passwords for each instance | ||
|
||
## redis provisioning | ||
|
||
REDISPASS="$( grep "^requirepass" /etc/redis/redis.conf | cut -f2 -d' ' )" | ||
|
||
### IF redis password is the default one, generate a new one | ||
|
||
[[ "$REDISPASS" == "default" ]] && { | ||
REDISPASS="$( openssl rand -base64 32 )" | ||
echo Provisioning Redis password | ||
sed -i -E "s|^requirepass .*|requirepass $REDISPASS|" /etc/redis/redis.conf | ||
} | ||
|
||
### If there exists already a configuration adjust the password | ||
test -f /data/app/config/config.php && { | ||
echo Updating NextCloud config with Redis password $REDISPASS | ||
sed -i "s|'password'.*|'password' => '$REDISPASS',|" /data/app/config/config.php | ||
} | ||
|
||
## mariaDB provisioning | ||
|
||
DBADMIN=ncadmin | ||
DBPASSWD=$( grep password /root/.my.cnf | cut -d= -f2 ) | ||
[[ "$DBPASSWD" == "default" ]] && { | ||
DBPASSWD=$( openssl rand -base64 32 ) | ||
echo Provisioning MariaDB password | ||
echo -e "[client]\npassword=$DBPASSWD" > /root/.my.cnf | ||
chmod 600 /root/.my.cnf | ||
mysql <<EOF | ||
GRANT USAGE ON *.* TO '$DBADMIN'@'localhost' IDENTIFIED BY '$DBPASSWD'; | ||
DROP USER '$DBADMIN'@'localhost'; | ||
CREATE USER '$DBADMIN'@'localhost' IDENTIFIED BY '$DBPASSWD'; | ||
GRANT ALL PRIVILEGES ON nextcloud.* TO $DBADMIN@localhost; | ||
EXIT | ||
EOF | ||
} | ||
|
||
test -f /data/app/config/config.php && { | ||
echo Updating NextCloud config with MariaDB password $DBPASSWD | ||
sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" /data/app/config/config.php | ||
} | ||
|
||
exit 0 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters