This commit is contained in:
Bob Mottram 2016-11-19 21:50:43 +00:00
parent 7d44aed03d
commit 1b3691742e
1 changed files with 4 additions and 4 deletions

View File

@ -60,12 +60,12 @@ function change_password_etherpad {
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 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
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
sed -i "s|\"\${change_username}\": {.*|\"\${change_username}\": { \"password\": \"\${new_user_password}\", \"is_admin\": false }," /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
fi
fi
}