This commit is contained in:
Bob Mottram 2016-11-20 10:13:31 +00:00
parent d9608c0ba6
commit ae5ec38024
1 changed files with 79 additions and 78 deletions

View File

@ -88,114 +88,114 @@ function etherpad_create_database {
} }
function create_etherpad_settings { function create_etherpad_settings {
echo '{' > /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json settings_file=/var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
echo " \"title\": \"${ETHERPAD_TITLE}\"," >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo '{' > $settings_file
echo ' "favicon": "favicon.ico",' >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo " \"title\": \"${ETHERPAD_TITLE}\"," >> $settings_file
echo ' "favicon": "favicon.ico",' >> $settings_file
echo ' "ip": "0.0.0.0",' >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo ' "ip": "0.0.0.0",' >> $settings_file
echo " \"port\" : ${ETHERPAD_PORT}," >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo " \"port\" : ${ETHERPAD_PORT}," >> $settings_file
echo ' "showSettingsInAdminPage" : true,' >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo ' "showSettingsInAdminPage" : true,' >> $settings_file
if [[ $ONION_ONLY == 'no' ]]; then if [[ $ONION_ONLY == 'no' ]]; then
echo ' "ssl" : {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "ssl" : {' >> $settings_file
echo " \"key\" : \"/etc/ssl/private/${ETHERPAD_DOMAIN_NAME}.key\"," >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo " \"key\" : \"/etc/ssl/private/${ETHERPAD_DOMAIN_NAME}.key\"," >> $settings_file
echo " \"cert\" : \"/etc/ssl/certs/${ETHERPAD_DOMAIN_NAME}.pem\"," >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo " \"cert\" : \"/etc/ssl/certs/${ETHERPAD_DOMAIN_NAME}.pem\"," >> $settings_file
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' },' >> $settings_file
fi fi
echo ' "dbType" : "mysql",' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "dbType" : "mysql",' >> $settings_file
echo ' "dbSettings" : {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "dbSettings" : {' >> $settings_file
echo ' "user" : "root",' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "user" : "root",' >> $settings_file
echo ' "host" : "localhost",' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "host" : "localhost",' >> $settings_file
echo " \"password\": \"${MARIADB_PASSWORD}\"," >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo " \"password\": \"${MARIADB_PASSWORD}\"," >> $settings_file
echo ' "database": "etherpad",' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "database": "etherpad",' >> $settings_file
echo ' "charset" : "utf8mb4"' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "charset" : "utf8mb4"' >> $settings_file
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' },' >> $settings_file
echo " \"defaultPadText\" : \"${ETHERPAD_WELCOME_MESSAGE}\"," >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo " \"defaultPadText\" : \"${ETHERPAD_WELCOME_MESSAGE}\"," >> $settings_file
echo ' "padOptions": {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "padOptions": {' >> $settings_file
echo ' "noColors": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "noColors": false,' >> $settings_file
echo ' "showControls": true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "showControls": true,' >> $settings_file
echo ' "showChat": true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "showChat": true,' >> $settings_file
echo ' "showLineNumbers": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "showLineNumbers": false,' >> $settings_file
echo ' "useMonospaceFont": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "useMonospaceFont": false,' >> $settings_file
echo ' "userName": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "userName": false,' >> $settings_file
echo ' "userColor": true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "userColor": true,' >> $settings_file
echo ' "rtl": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "rtl": false,' >> $settings_file
echo ' "alwaysShowChat": true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "alwaysShowChat": true,' >> $settings_file
echo ' "chatAndUsers": true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "chatAndUsers": true,' >> $settings_file
echo ' "lang": "en-gb"' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "lang": "en-gb"' >> $settings_file
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' },' >> $settings_file
echo ' "suppressErrorsInPadText" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "suppressErrorsInPadText" : true,' >> $settings_file
echo ' "requireSession" : false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "requireSession" : false,' >> $settings_file
echo ' "editOnly" : false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "editOnly" : false,' >> $settings_file
echo ' "sessionNoPassword" : false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "sessionNoPassword" : false,' >> $settings_file
echo ' "minify" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "minify" : true,' >> $settings_file
echo ' "maxAge" : 21600, // 60 * 60 * 6 = 6 hours' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "maxAge" : 21600, // 60 * 60 * 6 = 6 hours' >> $settings_file
echo ' "abiword" : null,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "abiword" : null,' >> $settings_file
echo ' "soffice" : null,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "soffice" : null,' >> $settings_file
echo ' "tidyHtml" : null,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "tidyHtml" : null,' >> $settings_file
echo ' "allowUnknownFileEnds" : false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "allowUnknownFileEnds" : false,' >> $settings_file
echo ' "requireAuthentication" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "requireAuthentication" : true,' >> $settings_file
echo ' "requireAuthorization" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "requireAuthorization" : true,' >> $settings_file
echo ' "trustProxy" : false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "trustProxy" : false,' >> $settings_file
echo ' "disableIPlogging" : true,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "disableIPlogging" : true,' >> $settings_file
echo ' "users": {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "users": {' >> $settings_file
echo " \"${MY_USERNAME}\": { \"password\": \"${ETHERPAD_ADMIN_PASSWORD}\", \"is_admin\": true }" >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo " \"${MY_USERNAME}\": { \"password\": \"${ETHERPAD_ADMIN_PASSWORD}\", \"is_admin\": true }" >> $settings_file
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' },' >> $settings_file
echo ' "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],' >> $settings_file
echo ' "loadTest": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "loadTest": false,' >> $settings_file
echo ' "indentationOnNewLine": false,' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "indentationOnNewLine": false,' >> $settings_file
echo ' "toolbar": {' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "toolbar": {' >> $settings_file
echo ' "left": [' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "left": [' >> $settings_file
echo ' ["bold", "italic", "underline", "strikethrough"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["bold", "italic", "underline", "strikethrough"],' >> $settings_file
echo ' ["orderedlist", "unorderedlist", "indent", "outdent"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["orderedlist", "unorderedlist", "indent", "outdent"],' >> $settings_file
echo ' ["undo", "redo"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["undo", "redo"],' >> $settings_file
echo ' ["clearauthorship"]' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["clearauthorship"]' >> $settings_file
echo ' ],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ],' >> $settings_file
echo ' "right": [' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "right": [' >> $settings_file
echo ' ["importexport", "timeslider", "savedrevision"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["importexport", "timeslider", "savedrevision"],' >> $settings_file
echo ' ["settings", "embed"],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["settings", "embed"],' >> $settings_file
echo ' ["showusers"]' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["showusers"]' >> $settings_file
echo ' ],' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ],' >> $settings_file
echo ' "timeslider": [' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "timeslider": [' >> $settings_file
echo ' ["timeslider_export", "timeslider_returnToPad"]' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ["timeslider_export", "timeslider_returnToPad"]' >> $settings_file
echo ' ]' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' ]' >> $settings_file
echo ' },' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' },' >> $settings_file
echo ' "loglevel": "INFO"' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo ' "loglevel": "INFO"' >> $settings_file
echo '}' >> /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json echo '}' >> $settings_file
} }
function remove_user_etherpad { function remove_user_etherpad {
remove_username="$1" remove_username="$1"
settings_file=/var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
read_config_param ETHERPAD_DOMAIN_NAME
${PROJECT_NAME}-pass -u $remove_username --rmapp etherpad ${PROJECT_NAME}-pass -u $remove_username --rmapp etherpad
if grep -q "\"$remove_username\": {" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json; then if grep -q "\"$remove_username\": {" $settings_file; then
sed -i "/\"$remove_username\": {/d" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json sed -i "/\"$remove_username\": {/d" $settings_file
systemctl restart etherpad systemctl restart etherpad
fi fi
} }
@ -203,11 +203,12 @@ function remove_user_etherpad {
function add_user_etherpad { function add_user_etherpad {
new_username="$1" new_username="$1"
new_user_password="$2" new_user_password="$2"
read_config_param ETHERPAD_DOMAIN_NAME settings_file=/var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json
if ! grep -q "\"$new_username\": {" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json; then
if ! grep -q "\"$new_username\": {" $settings_file; then
${PROJECT_NAME}-pass -u $new_username -a etherpad -p "$new_user_password" ${PROJECT_NAME}-pass -u $new_username -a etherpad -p "$new_user_password"
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 }," $settings_file
if grep -q "\"$new_username\": {" /var/www/${ETHERPAD_DOMAIN_NAME}/htdocs/settings.json; then if grep -q "\"$new_username\": {" $settings_file; then
systemctl restart etherpad systemctl restart etherpad
else else
echo '1' echo '1'