Changing etherpad password

This commit is contained in:
Bob Mottram 2016-11-19 21:40:39 +00:00
parent dec5cf2021
commit 7d44aed03d
1 changed files with 16 additions and 9 deletions

View File

@ -54,7 +54,20 @@ etherpad_variables=(ETHERPAD_COMMIT
MY_USERNAME)
function change_password_etherpad {
${PROJECT_NAME}-pass -u $1 -a dokuwiki -p "$2"
change_username="$1"
new_user_password="$2"
read_config_param ETHERPAD_DOMAIN_NAME
${PROJECT_NAME}-pass -u $change_username -a etherpad -p "$new_user_password"
if grep "\"${change_username}\": {" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json; then
user_line=$(cat /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json | grep "\"${change_username}\": {")
if [[ "$user_line" == *"\"is_admin\": true"* ]]; then
sed -i "s|\"${change_username}\": {.*|\"${change_username}\": { \"password\": \"${new_user_password}\", \"is_admin\": true }," /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
else
sed -i "s|\"${change_username}\": {.*|\"${change_username}\": { \"password\": \"${new_user_password}\", \"is_admin\": false }" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
fi
fi
}
function etherpad_create_database {
@ -144,10 +157,7 @@ function create_etherpad_settings {
echo ' "disableIPlogging" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo ' "users": {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo " \"${MY_USERNAME}\": {" >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo " \"password\": \"${ETHERPAD_ADMIN_PASSWORD}\"," >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo ' "is_admin": true' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo ' }' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo " \"${MY_USERNAME}\": { \"password\": \"${ETHERPAD_ADMIN_PASSWORD}\", \"is_admin\": true }" >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo ' "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
@ -192,10 +202,7 @@ function add_user_etherpad {
${PROJECT_NAME}-pass -u $new_username -a etherpad -p "$new_user_password"
read_config_param ETHERPAD_DOMAIN_NAME
if ! grep -q "\"${new_username}\": {" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json; then
sed -i "/\"users\": {/a \"${new_username}\": {
\"password\": \"${new_user_password}\",
\"is_admin\": false
}," /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
sed -i "/\"users\": {/a \"${new_username}\": { \"password\": \"${new_user_password}\", \"is_admin\": false }," /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
fi
}