Newer
Older
nginx_http_redirect "$PLEROMA_DOMAIN_NAME" "index index.html"
{ echo '';
echo 'proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=100m inactive=80m use_temp_path=off;';
echo '';
echo 'server {';
echo ' listen 443 ssl;';
echo ' #listen [::]:443 ssl;';
echo " server_name $PLEROMA_DOMAIN_NAME;";
echo ''; } >> "$pleroma_nginx_site"
nginx_compress "$PLEROMA_DOMAIN_NAME"
echo '' >> "$pleroma_nginx_site"
echo ' # Security' >> "$pleroma_nginx_site"
function_check nginx_security_options
nginx_security_options "$PLEROMA_DOMAIN_NAME"
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
echo '';
echo ' # Logs';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo " root $PLEROMA_DIR;";
echo '';
echo ' index index.html;';
echo ' location / {'; } >> "$pleroma_nginx_site"
{ echo " add_header 'Access-Control-Allow-Origin' '*';";
echo ' proxy_http_version 1.1;';
echo " proxy_set_header Upgrade \$http_upgrade;";
echo ' proxy_set_header Connection "upgrade";';
echo " proxy_set_header Host \$http_host;";
echo '';
echo " proxy_pass http://localhost:$PLEROMA_PORT;";
echo ' }';
echo '';
echo ' location /proxy {'; } >> "$pleroma_nginx_site"
nginx_limits "$PLEROMA_DOMAIN_NAME" '15m'
{ echo ' proxy_cache pleroma_media_cache;';
echo ' proxy_cache_lock on;';
echo " proxy_pass http://localhost:$PLEROMA_PORT;";
echo ' }';
echo ' # include snippets/well-known.conf;';
echo '}'; } >> "$pleroma_nginx_site"
echo 'proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=100m inactive=80m use_temp_path=off;' > "$pleroma_nginx_site"
echo '' >> "$pleroma_nginx_site"
{ echo 'server {';
echo " listen 127.0.0.1:$PLEROMA_ONION_PORT default_server;";
echo " server_name $PLEROMA_ONION_HOSTNAME;";
echo ''; } >> "$pleroma_nginx_site"
nginx_compress "$PLEROMA_DOMAIN_NAME"
echo '' >> "$pleroma_nginx_site"
function_check nginx_security_options
nginx_security_options "$PLEROMA_DOMAIN_NAME"
{ echo '';
echo ' # Logs';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo " root $PLEROMA_DIR;";
echo '';
echo ' index index.html;';
echo ' location / {'; } >> "$pleroma_nginx_site"
{ echo " add_header 'Access-Control-Allow-Origin' '*';";
echo ' proxy_http_version 1.1;';
echo " proxy_set_header Upgrade \$http_upgrade;";
echo ' proxy_set_header Connection "upgrade";';
echo " proxy_set_header Host \$http_host;";
echo '';
echo " proxy_pass http://localhost:$PLEROMA_PORT;";
echo ' }';
echo '';
echo ' location /proxy {'; } >> "$pleroma_nginx_site"
nginx_limits "$PLEROMA_DOMAIN_NAME" '15m'
{ echo ' proxy_cache pleroma_media_cache;';
echo ' proxy_cache_lock on;';
echo " proxy_pass http://localhost:$PLEROMA_PORT;";
echo ' }';
echo ' # include snippets/well-known.conf;';
echo '}'; } >> "$pleroma_nginx_site"
function_check pleroma_create_database
pleroma_create_database
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a pleroma -p "$PLEROMA_ADMIN_PASSWORD"
# NOTE: we don't need to install the frontend separately,
# since the backend contains a precompiled version of it
install_gnusocial_default_background "pleroma" "$PLEROMA_DOMAIN_NAME"
sed -i 's|"theme":.*|"theme": "base16-summerfruit-dark.css",|g' "$PLEROMA_DIR/priv/static/static/config.json"
pleroma_set_background_image_from_url $PLEROMA_DIR/priv/static "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE"
# Get certificate
function_check create_site_certificate
function_check nginx_ensite
systemctl restart postgresql
systemctl restart nginx
set_completion_param "pleroma domain" "$PLEROMA_DOMAIN_NAME"
# We need to set up the url option again because it somehow gets
# lost during mix compile
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs
sed -i 's|watchers: \[\]|watchers: \[\],|g' $pleroma_secret
fi
if ! grep -q 'url:' $pleroma_secret; then
if [[ $ONION_ONLY == 'no' ]]; then
sed -i "/watchers: /a url: [host: \"$PLEROMA_DOMAIN_NAME\", scheme: \"https\", port: 443]" $pleroma_secret
sed -i "/watchers: /a url: [host: \"$PLEROMA_ONION_HOSTNAME\", scheme: \"http\", port: 80]" $pleroma_secret
{ echo '[Unit]';
echo 'Description=Pleroma social network';
echo 'After=network.target postgresql.service';
echo '';
echo '[Service]';
echo 'User=pleroma';
echo "WorkingDirectory=$PLEROMA_DIR";
echo "Environment=\"HOME=$PLEROMA_DIR\"";
echo 'ExecStart=/usr/local/bin/mix phx.server';
echo "ExecReload=/bin/kill \$MAINPID";
echo 'KillMode=process';
echo 'Restart=on-failure';
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target';
echo 'Alias=pleroma.service'; } > /etc/systemd/system/pleroma.service
# set registrations open initially
sed -i 's|registrations_open:.*|registrations_open: true,|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen":.*|"registrationOpen": true,|g' $PLEROMA_DIR/priv/static/static/config.json
systemctl daemon-reload
systemctl enable pleroma
systemctl start pleroma
APP_INSTALLED=1
}
# NOTE: deliberately there is no "exit 0"