2020-04-07 21:02:49 +00:00
|
|
|
#!/bin/bash
|
2020-04-11 07:57:28 +00:00
|
|
|
# JRA (Jibri Recordings Access) via Nextcloud
|
|
|
|
# SwITNet Ltd © - 2020, https://switnet.net/
|
|
|
|
# GPLv3 or later.
|
2020-09-30 02:27:13 +00:00
|
|
|
while getopts m: option
|
|
|
|
do
|
2021-04-12 03:32:55 +00:00
|
|
|
case "${option}"
|
|
|
|
in
|
|
|
|
m) MODE=${OPTARG};;
|
|
|
|
\?) echo "Usage: sudo ./jra_nextcloud.sh [-m debug]" && exit;;
|
|
|
|
esac
|
2020-09-30 02:27:13 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
#DEBUG
|
|
|
|
if [ "$MODE" = "debug" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2020-04-11 05:09:43 +00:00
|
|
|
if ! [ $(id -u) = 0 ]; then
|
|
|
|
echo "You need to be root or have sudo privileges!"
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-10-09 04:40:46 +00:00
|
|
|
exit_if_not_installed() {
|
|
|
|
if [ "$(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed")" != "1" ]; then
|
2021-04-12 03:32:55 +00:00
|
|
|
echo " This instance doesn't have $1 installed, exiting..."
|
|
|
|
echo " If you think this is an error, please report to:
|
2020-10-09 04:40:46 +00:00
|
|
|
-> https://github.com/switnet-ltd/quick-jibri-installer/issues "
|
2021-04-12 03:32:55 +00:00
|
|
|
exit
|
2020-10-09 04:40:46 +00:00
|
|
|
fi
|
|
|
|
}
|
2020-04-11 05:09:43 +00:00
|
|
|
clear
|
2020-10-05 08:19:03 +00:00
|
|
|
echo -e '\n
|
2020-04-11 05:09:43 +00:00
|
|
|
########################################################################
|
|
|
|
Jibri Recordings Access via Nextcloud
|
|
|
|
########################################################################
|
|
|
|
by Software, IT & Networks Ltd
|
2020-10-05 08:19:03 +00:00
|
|
|
\n'
|
2020-10-09 04:40:46 +00:00
|
|
|
exit_if_not_installed jitsi-meet
|
|
|
|
|
|
|
|
DISTRO_RELEASE="$(lsb_release -sc)"
|
|
|
|
DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++')
|
|
|
|
PHP_REPO=$(apt-cache policy | grep http | grep php | head -n 1 | awk '{print $2}' | cut -d "/" -f5)
|
|
|
|
PHPVER="7.4"
|
|
|
|
PSGVER="$(apt-cache madison postgresql | head -n1 | awk '{print $3}' | cut -d "+" -f1)"
|
|
|
|
PHP_FPM_DIR="/etc/php/$PHPVER/fpm"
|
|
|
|
PHP_INI="$PHP_FPM_DIR/php.ini"
|
|
|
|
PHP_CONF="/etc/php/$PHPVER/fpm/pool.d/www.conf"
|
|
|
|
NC_NGINX_SSL_PORT="$(grep "listen 44" /etc/nginx/sites-enabled/$DOMAIN.conf | awk '{print$2}')"
|
|
|
|
NC_REPO="https://download.nextcloud.com/server/releases"
|
|
|
|
NCVERSION="$(curl -s -m 900 $NC_REPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | tail -1)"
|
|
|
|
STABLEVERSION="nextcloud-$NCVERSION"
|
|
|
|
NC_PATH="/var/www/nextcloud"
|
|
|
|
NC_CONFIG="$NC_PATH/config/config.php"
|
|
|
|
NC_DB_USER="nextcloud_user"
|
|
|
|
NC_DB="nextcloud_db"
|
|
|
|
NC_DB_PASSWD="$(tr -dc "a-zA-Z0-9#_*=" < /dev/urandom | fold -w 14 | head -n1)"
|
|
|
|
DIR_RECORD="$(grep -nr RECORDING /home/jibri/finalize_recording.sh|head -n1|cut -d "=" -f2)"
|
|
|
|
REDIS_CONF="/etc/redis/redis.conf"
|
|
|
|
JITSI_MEET_PROXY="/etc/nginx/modules-enabled/60-jitsi-meet.conf"
|
|
|
|
if [ -f $JITSI_MEET_PROXY ];then
|
|
|
|
PREAD_PROXY=$(grep -nr "preread_server_name" $JITSI_MEET_PROXY | cut -d ":" -f1)
|
|
|
|
fi
|
2020-10-05 08:19:03 +00:00
|
|
|
|
2020-06-03 07:46:08 +00:00
|
|
|
while [[ -z "$NC_DOMAIN" ]]
|
|
|
|
do
|
2021-04-12 03:32:55 +00:00
|
|
|
read -p "Please enter the domain to use for Nextcloud: " -r NC_DOMAIN
|
|
|
|
if [ -z "$NC_DOMAIN" ];then
|
|
|
|
echo "-- This field is mandatory."
|
|
|
|
elif [ "$NC_DOMAIN" = "$DOMAIN" ]; then
|
|
|
|
echo "-- You can not use the same domain for both, Jitsi Meet and JRA via Nextcloud."
|
|
|
|
fi
|
2020-06-03 07:46:08 +00:00
|
|
|
done
|
2020-10-11 03:58:00 +00:00
|
|
|
NC_NGINX_CONF="/etc/nginx/sites-available/$NC_DOMAIN.conf"
|
2020-06-03 07:46:08 +00:00
|
|
|
while [[ -z "$NC_USER" ]]
|
|
|
|
do
|
2021-04-12 03:32:55 +00:00
|
|
|
read -p "Nextcloud user: " -r NC_USER
|
|
|
|
if [ -z "$NC_USER" ]; then
|
|
|
|
echo "-- This field is mandatory."
|
|
|
|
fi
|
2020-06-03 07:46:08 +00:00
|
|
|
done
|
2020-09-30 07:03:11 +00:00
|
|
|
while [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt 6 ]
|
2020-06-03 07:46:08 +00:00
|
|
|
do
|
2021-04-12 03:32:55 +00:00
|
|
|
read -p "Nextcloud user password: " -r NC_PASS
|
|
|
|
if [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt 6 ]; then
|
|
|
|
echo -e "-- This field is mandatory. \nPlease make sure it's at least 6 caracters.\n"
|
|
|
|
fi
|
2020-06-03 07:46:08 +00:00
|
|
|
done
|
2020-04-11 21:35:11 +00:00
|
|
|
#Enable HSTS
|
|
|
|
while [[ "$ENABLE_HSTS" != "yes" && "$ENABLE_HSTS" != "no" ]]
|
|
|
|
do
|
2021-04-12 03:32:55 +00:00
|
|
|
read -p "> Do you want to enable HSTS for this domain?: (yes or no)
|
2020-04-11 21:35:11 +00:00
|
|
|
Be aware this option apply mid-term effects on the domain, choose \"no\"
|
|
|
|
in case you don't know what you are doing. More at https://hstspreload.org/"$'\n' -r ENABLE_HSTS
|
2021-04-12 03:32:55 +00:00
|
|
|
if [ "$ENABLE_HSTS" = "no" ]; then
|
|
|
|
echo "-- HSTS won't be enabled."
|
|
|
|
elif [ "$ENABLE_HSTS" = "yes" ]; then
|
|
|
|
echo "-- HSTS will be enabled."
|
|
|
|
fi
|
2020-04-11 21:35:11 +00:00
|
|
|
done
|
2020-09-30 02:27:13 +00:00
|
|
|
|
|
|
|
echo -e "\n# Check for jitsi-meet/jibri\n"
|
|
|
|
if [ "$(dpkg-query -W -f='${Status}' jibri 2>/dev/null | grep -c "ok installed")" == "1" ] || \
|
|
|
|
[ -f /etc/prosody/conf.d/$DOMAIN.conf ]; then
|
2020-10-05 11:41:22 +00:00
|
|
|
echo "jitsi meet/jibri is installed, checking version:"
|
2020-09-30 02:27:13 +00:00
|
|
|
apt-show-versions jibri
|
|
|
|
else
|
2020-10-05 11:41:22 +00:00
|
|
|
echo "Wait!, jitsi-meet/jibri is not installed on this system using apt, exiting..."
|
2020-09-30 02:27:13 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-04-11 05:09:43 +00:00
|
|
|
exit_ifinstalled() {
|
|
|
|
if [ "$(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed")" == "1" ]; then
|
2021-04-12 03:32:55 +00:00
|
|
|
echo " This instance already has $1 installed, exiting..."
|
|
|
|
echo " If you think this is an error, please report to:
|
2020-04-11 05:09:43 +00:00
|
|
|
-> https://github.com/switnet-ltd/quick-jibri-installer/issues "
|
2021-04-12 03:32:55 +00:00
|
|
|
exit
|
2020-04-11 12:44:14 +00:00
|
|
|
fi
|
2020-04-11 05:09:43 +00:00
|
|
|
}
|
2020-04-07 21:02:49 +00:00
|
|
|
install_ifnot() {
|
|
|
|
if [ "$(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed")" == "1" ]; then
|
2021-04-12 03:32:55 +00:00
|
|
|
echo " $1 is installed, skipping..."
|
|
|
|
else
|
|
|
|
echo -e "\n---- Installing $1 ----"
|
|
|
|
apt-get -yq2 install $1
|
2020-04-07 21:02:49 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
add_php74() {
|
2021-04-12 03:32:55 +00:00
|
|
|
if [ "$PHP_REPO" = "php" ]; then
|
|
|
|
echo "PHP $PHPVER already installed"
|
|
|
|
apt-get -q2 update
|
|
|
|
apt-get -yq2 dist-upgrade
|
|
|
|
else
|
|
|
|
echo "# Adding Ondrej PHP $PHPVER PPA Repository"
|
|
|
|
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E5267A6C
|
|
|
|
echo "deb [arch=amd64] http://ppa.launchpad.net/ondrej/php/ubuntu $DISTRO_RELEASE main" > /etc/apt/sources.list.d/php7x.list
|
|
|
|
apt-get update -q2
|
|
|
|
fi
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
2020-04-27 22:49:25 +00:00
|
|
|
#Prevent root folder permission issues
|
|
|
|
cp $PWD/files/jra-nc-app-ef.json /tmp
|
2020-04-07 21:02:49 +00:00
|
|
|
|
2020-07-01 01:35:53 +00:00
|
|
|
exit_ifinstalled postgresql-$PSGVER
|
2020-04-11 05:09:43 +00:00
|
|
|
|
2020-04-07 21:02:49 +00:00
|
|
|
## Install software requirements
|
2020-07-01 01:35:53 +00:00
|
|
|
# PostgresSQL
|
|
|
|
install_ifnot postgresql-$PSGVER
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
# PHP 7.4
|
|
|
|
add_php74
|
2020-04-14 16:49:11 +00:00
|
|
|
apt-get install -y \
|
2020-07-20 08:03:54 +00:00
|
|
|
php$PHPVER-fpm \
|
|
|
|
php$PHPVER-bcmath \
|
|
|
|
php$PHPVER-bz2 \
|
|
|
|
php$PHPVER-curl \
|
|
|
|
php$PHPVER-gd \
|
|
|
|
php$PHPVER-gmp \
|
|
|
|
php$PHPVER-intl \
|
|
|
|
php$PHPVER-json \
|
|
|
|
php$PHPVER-ldap \
|
|
|
|
php$PHPVER-mbstring \
|
|
|
|
php$PHPVER-pgsql \
|
2021-03-11 10:22:12 +00:00
|
|
|
php$PHPVER-redis \
|
2020-07-20 08:03:54 +00:00
|
|
|
php$PHPVER-soap \
|
|
|
|
php$PHPVER-xml \
|
|
|
|
php$PHPVER-xmlrpc \
|
|
|
|
php$PHPVER-zip \
|
|
|
|
php-imagick \
|
2020-09-30 02:27:13 +00:00
|
|
|
redis-server \
|
|
|
|
unzip
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
#System related
|
|
|
|
install_ifnot smbclient
|
2020-04-11 21:35:11 +00:00
|
|
|
sed -i "s|.*env\[HOSTNAME\].*|env\[HOSTNAME\] = \$HOSTNAME|" $PHP_CONF
|
|
|
|
sed -i "s|.*env\[PATH\].*|env\[PATH\] = /usr/local/bin:/usr/bin:/bin|" $PHP_CONF
|
|
|
|
sed -i "s|.*env\[TMP\].*|env\[TMP\] = /tmp|" $PHP_CONF
|
|
|
|
sed -i "s|.*env\[TMPDIR\].*|env\[TMPDIR\] = /tmp|" $PHP_CONF
|
|
|
|
sed -i "s|.*env\[TEMP\].*|env\[TEMP\] = /tmp|" $PHP_CONF
|
|
|
|
sed -i "s|;clear_env = no|clear_env = no|" $PHP_CONF
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
Tunning PHP.ini...
|
|
|
|
"
|
|
|
|
# Change values in php.ini (increase max file size)
|
|
|
|
# max_execution_time
|
|
|
|
sed -i "s|max_execution_time =.*|max_execution_time = 3500|g" "$PHP_INI"
|
|
|
|
# max_input_time
|
|
|
|
sed -i "s|max_input_time =.*|max_input_time = 3600|g" "$PHP_INI"
|
|
|
|
# memory_limit
|
|
|
|
sed -i "s|memory_limit =.*|memory_limit = 512M|g" "$PHP_INI"
|
|
|
|
# post_max
|
|
|
|
sed -i "s|post_max_size =.*|post_max_size = 1025M|g" "$PHP_INI"
|
|
|
|
# upload_max
|
|
|
|
sed -i "s|upload_max_filesize =.*|upload_max_filesize = 1024M|g" "$PHP_INI"
|
|
|
|
|
|
|
|
phpenmod opcache
|
|
|
|
{
|
|
|
|
|
|
|
|
echo "# OPcache settings for Nextcloud"
|
|
|
|
echo "opcache.enable=1"
|
|
|
|
echo "opcache.enable_cli=1"
|
|
|
|
echo "opcache.interned_strings_buffer=8"
|
|
|
|
echo "opcache.max_accelerated_files=10000"
|
|
|
|
echo "opcache.memory_consumption=256"
|
|
|
|
echo "opcache.save_comments=1"
|
|
|
|
echo "opcache.revalidate_freq=1"
|
|
|
|
echo "opcache.validate_timestamps=1"
|
|
|
|
} >> "$PHP_INI"
|
|
|
|
|
|
|
|
systemctl restart php$PHPVER-fpm.service
|
|
|
|
|
|
|
|
#--------------------------------------------------
|
2020-08-08 05:36:08 +00:00
|
|
|
# Create DB user
|
2020-04-07 21:02:49 +00:00
|
|
|
#--------------------------------------------------
|
|
|
|
|
2020-07-01 01:35:53 +00:00
|
|
|
echo -e "\n---- Creating the PgSQL DB & User ----"
|
2020-09-30 02:27:13 +00:00
|
|
|
cd /tmp
|
2020-07-01 01:35:53 +00:00
|
|
|
sudo -u postgres psql <<DB
|
2020-04-10 02:43:29 +00:00
|
|
|
CREATE DATABASE nextcloud_db;
|
2020-07-01 01:35:53 +00:00
|
|
|
CREATE USER ${NC_DB_USER} WITH ENCRYPTED PASSWORD '${NC_DB_PASSWD}';
|
|
|
|
GRANT ALL PRIVILEGES ON DATABASE ${NC_DB} TO ${NC_DB_USER};
|
2020-04-07 21:02:49 +00:00
|
|
|
DB
|
2020-04-10 22:36:44 +00:00
|
|
|
echo "Done!
|
|
|
|
"
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
#nginx - configuration
|
2020-04-11 21:35:11 +00:00
|
|
|
cat << NC_NGINX > $NC_NGINX_CONF
|
2020-06-17 22:06:51 +00:00
|
|
|
#nextcloud config
|
2020-04-10 02:43:29 +00:00
|
|
|
upstream php-handler {
|
|
|
|
#server 127.0.0.1:9000;
|
|
|
|
server unix:/run/php/php${PHPVER}-fpm.sock;
|
|
|
|
}
|
|
|
|
|
2020-04-07 21:02:49 +00:00
|
|
|
server {
|
|
|
|
listen 80;
|
2020-04-10 02:43:29 +00:00
|
|
|
listen [::]:80;
|
2020-04-07 21:02:49 +00:00
|
|
|
server_name $NC_DOMAIN;
|
2020-04-10 02:43:29 +00:00
|
|
|
# enforce https
|
|
|
|
return 301 https://\$server_name\$request_uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
2020-04-16 01:39:41 +00:00
|
|
|
listen $NC_NGINX_SSL_PORT ssl http2;
|
|
|
|
listen [::]:$NC_NGINX_SSL_PORT ssl http2;
|
2020-04-10 02:43:29 +00:00
|
|
|
server_name $NC_DOMAIN;
|
|
|
|
|
|
|
|
ssl_certificate /etc/letsencrypt/live/$NC_DOMAIN/fullchain.pem;
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/$NC_DOMAIN/privkey.pem;
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
# Add headers to serve security related headers
|
2020-04-10 02:43:29 +00:00
|
|
|
# Before enabling Strict-Transport-Security headers please read into this
|
|
|
|
# topic first.
|
2020-04-11 21:35:11 +00:00
|
|
|
# add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload;";
|
2020-04-10 02:43:29 +00:00
|
|
|
#
|
|
|
|
# WARNING: Only add the preload option once you read about
|
|
|
|
# the consequences in https://hstspreload.org/. This option
|
|
|
|
# will add the domain to a hardcoded list that is shipped
|
|
|
|
# in all major browsers and getting removed from this list
|
|
|
|
# could take several months.
|
2020-04-11 07:52:19 +00:00
|
|
|
add_header Referrer-Policy "no-referrer" always;
|
|
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
|
|
add_header X-Download-Options "noopen" always;
|
|
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
|
|
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
|
|
|
add_header X-Robots-Tag "none" always;
|
|
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
# Path to the root of your installation
|
2020-04-10 02:43:29 +00:00
|
|
|
root $NC_PATH/;
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
location = /robots.txt {
|
|
|
|
allow all;
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
|
|
|
|
|
|
|
# The following 2 rules are only needed for the user_webfinger app.
|
|
|
|
# Uncomment it if you're planning to use this app.
|
|
|
|
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
|
|
|
|
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
|
|
|
|
# last;
|
|
|
|
|
|
|
|
location = /.well-known/carddav {
|
2020-04-10 02:43:29 +00:00
|
|
|
return 301 \$scheme://\$host/remote.php/dav;
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
location = /.well-known/caldav {
|
2020-04-10 02:43:29 +00:00
|
|
|
return 301 \$scheme://\$host/remote.php/dav;
|
|
|
|
}
|
2020-04-07 21:02:49 +00:00
|
|
|
location ~ /.well-known/acme-challenge {
|
|
|
|
allow all;
|
|
|
|
}
|
|
|
|
|
|
|
|
# set max upload size
|
|
|
|
client_max_body_size 1024M;
|
|
|
|
fastcgi_buffers 64 4K;
|
|
|
|
|
2020-04-10 02:43:29 +00:00
|
|
|
# Enable gzip but do not remove ETag headers
|
|
|
|
gzip on;
|
|
|
|
gzip_vary on;
|
|
|
|
gzip_comp_level 4;
|
|
|
|
gzip_min_length 256;
|
|
|
|
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
|
|
|
|
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
|
2020-04-07 21:02:49 +00:00
|
|
|
|
2020-04-10 02:43:29 +00:00
|
|
|
# Uncomment if your server is built with the ngx_pagespeed module
|
2020-04-07 21:02:49 +00:00
|
|
|
# This module is currently not supported.
|
|
|
|
#pagespeed off;
|
|
|
|
|
|
|
|
location / {
|
2020-04-10 02:43:29 +00:00
|
|
|
rewrite ^ /index.php\$uri;
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
|
2020-04-10 02:43:29 +00:00
|
|
|
deny all;
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
|
2020-04-10 02:43:29 +00:00
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:\$|/) {
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.*)\$;
|
|
|
|
include fastcgi_params;
|
|
|
|
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
|
|
|
fastcgi_param PATH_INFO \$fastcgi_path_info;
|
|
|
|
fastcgi_param HTTPS on;
|
|
|
|
#Avoid sending the security headers twice
|
|
|
|
fastcgi_param modHeadersAvailable true;
|
|
|
|
fastcgi_param front_controller_active true;
|
|
|
|
fastcgi_pass php-handler;
|
|
|
|
fastcgi_intercept_errors on;
|
|
|
|
fastcgi_request_buffering off;
|
2020-07-20 03:57:12 +00:00
|
|
|
fastcgi_read_timeout 300;
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/(?:updater|ocs-provider)(?:\$|/) {
|
2020-04-10 02:43:29 +00:00
|
|
|
try_files \$uri/ =404;
|
|
|
|
index index.php;
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Adding the cache control header for js and css files
|
|
|
|
# Make sure it is BELOW the PHP block
|
2020-04-10 02:43:29 +00:00
|
|
|
location ~ \.(?:css|js|woff|svg|gif)\$ {
|
2020-04-07 21:02:49 +00:00
|
|
|
try_files \$uri /index.php\$uri\$is_args\$args;
|
2020-04-10 02:43:29 +00:00
|
|
|
add_header Cache-Control "public, max-age=15778463";
|
2020-04-07 21:02:49 +00:00
|
|
|
# Add headers to serve security related headers (It is intended to
|
|
|
|
# have those duplicated to the ones above)
|
2020-04-10 02:43:29 +00:00
|
|
|
# Before enabling Strict-Transport-Security headers please read into
|
|
|
|
# this topic first.
|
|
|
|
# add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
|
|
|
|
#
|
|
|
|
# WARNING: Only add the preload option once you read about
|
|
|
|
# the consequences in https://hstspreload.org/. This option
|
|
|
|
# will add the domain to a hardcoded list that is shipped
|
|
|
|
# in all major browsers and getting removed from this list
|
|
|
|
# could take several months.
|
2020-04-11 07:52:19 +00:00
|
|
|
add_header Referrer-Policy "no-referrer" always;
|
|
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
|
|
add_header X-Download-Options "noopen" always;
|
|
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
|
|
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
|
|
|
add_header X-Robots-Tag "none" always;
|
|
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
2020-04-07 21:02:49 +00:00
|
|
|
# Optional: Don't log access to assets
|
|
|
|
access_log off;
|
2020-04-10 02:43:29 +00:00
|
|
|
}
|
2020-04-07 21:02:49 +00:00
|
|
|
|
2020-04-10 02:43:29 +00:00
|
|
|
location ~ \.(?:png|html|ttf|ico|jpg|jpeg)\$ {
|
2020-04-07 21:02:49 +00:00
|
|
|
try_files \$uri /index.php\$uri\$is_args\$args;
|
|
|
|
# Optional: Don't log access to other assets
|
|
|
|
access_log off;
|
2020-04-10 02:43:29 +00:00
|
|
|
}
|
2020-04-07 21:02:49 +00:00
|
|
|
}
|
|
|
|
NC_NGINX
|
2020-04-10 02:43:29 +00:00
|
|
|
systemctl stop nginx
|
|
|
|
letsencrypt certonly --standalone --renew-by-default --agree-tos -d $NC_DOMAIN
|
|
|
|
if [ -f /etc/letsencrypt/live/$NC_DOMAIN/fullchain.pem ];then
|
2021-04-12 03:32:55 +00:00
|
|
|
ln -s $NC_NGINX_CONF /etc/nginx/sites-enabled/
|
2020-04-10 02:43:29 +00:00
|
|
|
else
|
2021-04-12 03:32:55 +00:00
|
|
|
echo "There are issues on getting the SSL certs..."
|
|
|
|
read -n 1 -s -r -p "Press any key to continue"
|
2020-04-10 02:43:29 +00:00
|
|
|
fi
|
2020-04-07 21:02:49 +00:00
|
|
|
nginx -t
|
2020-04-11 16:52:53 +00:00
|
|
|
systemctl restart nginx
|
2020-04-07 21:02:49 +00:00
|
|
|
|
2020-04-11 21:35:11 +00:00
|
|
|
if [ "$ENABLE_HSTS" = "yes" ]; then
|
2021-04-12 03:32:55 +00:00
|
|
|
sed -i "s|# add_header Strict-Transport-Security|add_header Strict-Transport-Security|g" $NC_NGINX_CONF
|
2020-04-11 21:35:11 +00:00
|
|
|
fi
|
|
|
|
|
2021-04-12 03:32:55 +00:00
|
|
|
if [ "$DISTRO_RELEASE" != "xenial" ] && [ ! -z "$PREAD_PROXY" ]; then
|
|
|
|
echo "
|
2020-05-03 12:59:25 +00:00
|
|
|
Setting up Nextcloud domain on Jitsi Meet turn proxy
|
|
|
|
"
|
2021-04-12 03:32:55 +00:00
|
|
|
sed -i "/server {/i \ \ map \$ssl_preread_server_name \$upstream {" $JITSI_MEET_PROXY
|
|
|
|
sed -i "/server {/i \ \ \ \ \ \ $DOMAIN web;" $JITSI_MEET_PROXY
|
|
|
|
sed -i "/server {/i \ \ \ \ \ \ $NC_DOMAIN web;" $JITSI_MEET_PROXY
|
|
|
|
sed -i "/server {/i \ \ }" $JITSI_MEET_PROXY
|
2020-05-03 12:59:25 +00:00
|
|
|
fi
|
2020-04-11 21:35:11 +00:00
|
|
|
|
2020-04-07 21:02:49 +00:00
|
|
|
echo "
|
|
|
|
Latest version to be installed: $STABLEVERSION
|
2020-07-20 09:20:47 +00:00
|
|
|
(This might take sometime, please be patient...)
|
2020-04-07 21:02:49 +00:00
|
|
|
"
|
2020-04-11 13:05:17 +00:00
|
|
|
curl -s $NC_REPO/$STABLEVERSION.zip > /tmp/$STABLEVERSION.zip
|
2020-04-11 15:58:37 +00:00
|
|
|
unzip -q /tmp/$STABLEVERSION.zip
|
|
|
|
mv nextcloud $NC_PATH
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
chown -R www-data:www-data $NC_PATH
|
|
|
|
chmod -R 755 $NC_PATH
|
|
|
|
|
|
|
|
echo "
|
|
|
|
Database installation...
|
|
|
|
"
|
2020-04-11 06:40:51 +00:00
|
|
|
sudo -u www-data php $NC_PATH/occ maintenance:install \
|
2020-07-01 01:35:53 +00:00
|
|
|
--database=pgsql \
|
2020-04-07 21:02:49 +00:00
|
|
|
--database-name="$NC_DB" \
|
|
|
|
--database-user="$NC_DB_USER" \
|
|
|
|
--database-pass="$NC_DB_PASSWD" \
|
|
|
|
--admin-user="$NC_USER" \
|
|
|
|
--admin-pass="$NC_PASS"
|
|
|
|
|
|
|
|
echo "
|
2020-04-11 21:35:11 +00:00
|
|
|
Apply custom mods...
|
2020-04-07 21:02:49 +00:00
|
|
|
"
|
|
|
|
sed -i "/datadirectory/a \ \ \'skeletondirectory\' => \'\'," $NC_CONFIG
|
|
|
|
sed -i "/skeletondirectory/a \ \ \'simpleSignUpLink.shown\' => false," $NC_CONFIG
|
|
|
|
sed -i "/simpleSignUpLink.shown/a \ \ \'knowledgebaseenabled\' => false," $NC_CONFIG
|
|
|
|
sed -i "s|http://localhost|http://$NC_DOMAIN|" $NC_CONFIG
|
|
|
|
|
2020-04-14 16:49:11 +00:00
|
|
|
echo "Add crontab..."
|
|
|
|
crontab -u www-data -l | { cat; echo "*/5 * * * * php -f $NC_PATH/cron.php"; } | crontab -u www-data -
|
|
|
|
|
2020-04-11 21:35:11 +00:00
|
|
|
echo "
|
|
|
|
Add memcache support...
|
|
|
|
"
|
|
|
|
sed -i "s|# unixsocket .*|unixsocket /var/run/redis/redis.sock|g" $REDIS_CONF
|
|
|
|
sed -i "s|# unixsocketperm .*|unixsocketperm 777|g" $REDIS_CONF
|
|
|
|
sed -i "s|port 6379|port 0|" $REDIS_CONF
|
|
|
|
systemctl restart redis-server
|
|
|
|
|
|
|
|
echo "--> Setting config.php..."
|
|
|
|
sed -i "/);/i \ \ 'filelocking.enabled' => 'true'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ 'memcache.locking' => '\\\OC\\\Memcache\\\Redis'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ 'memcache.local' => '\\\OC\\\Memcache\\\Redis'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ 'memcache.local' => '\\\OC\\\Memcache\\\Redis'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ 'memcache.distributed' => '\\\OC\\\Memcache\\\Redis'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ 'redis' =>" $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ \ \ array (" $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ \ \ \ 'host' => '/var/run/redis/redis.sock'," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ \ \ \ 'port' => 0," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ \ \ \ 'timeout' => 0," $NC_CONFIG
|
|
|
|
sed -i "/);/i \ \ )," $NC_CONFIG
|
|
|
|
echo "Done
|
|
|
|
"
|
2020-04-07 21:02:49 +00:00
|
|
|
echo "
|
|
|
|
Addding & Setting up Files External App for Local storage...
|
|
|
|
"
|
2020-04-11 19:17:42 +00:00
|
|
|
sudo -u www-data php $NC_PATH/occ app:install files_external
|
|
|
|
sudo -u www-data php $NC_PATH/occ app:enable files_external
|
2020-04-27 22:49:25 +00:00
|
|
|
sudo -u www-data php $NC_PATH/occ files_external:import /tmp/jra-nc-app-ef.json
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
usermod -a -G jibri www-data
|
|
|
|
chmod -R 770 $DIR_RECORD
|
|
|
|
chmod -R g+s $DIR_RECORD
|
|
|
|
|
|
|
|
echo "
|
|
|
|
Fixing possible missing tables...
|
|
|
|
"
|
2020-04-11 19:17:42 +00:00
|
|
|
echo "y"|sudo -u www-data php $NC_PATH/occ db:convert-filecache-bigint
|
|
|
|
sudo -u www-data php $NC_PATH/occ db:add-missing-indices
|
2020-07-20 08:03:54 +00:00
|
|
|
sudo -u www-data php $NC_PATH/occ db:add-missing-columns
|
2020-04-07 21:02:49 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
Adding trusted domain...
|
|
|
|
"
|
2020-04-11 19:17:42 +00:00
|
|
|
sudo -u www-data php $NC_PATH/occ config:system:set trusted_domains 0 --value=$NC_DOMAIN
|
2020-04-07 21:02:49 +00:00
|
|
|
|
2020-08-08 06:49:35 +00:00
|
|
|
echo "Setting JRA domain on jitsi-updater.sh"
|
2020-09-30 02:35:01 +00:00
|
|
|
cd ~/quick-jibri-installer
|
2020-08-08 06:49:35 +00:00
|
|
|
sed -i "s|NC_DOMAIN=.*|NC_DOMAIN=\"$NC_DOMAIN\"|" jitsi-updater.sh
|
|
|
|
|
2020-04-07 21:02:49 +00:00
|
|
|
echo "Quick Nextcloud installation complete!"
|