2015-09-04 17:12:37 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
setup_nginx()
|
|
|
|
|
{
|
|
|
|
|
if [ -z "$TTRSS_HOST" ]; then
|
|
|
|
|
TTRSS_HOST=ttrss
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-21 23:50:08 +01:00
|
|
|
NGINX_CONF=/etc/nginx/nginx.conf
|
|
|
|
|
|
2017-07-07 13:31:48 +02:00
|
|
|
if [ "$TTRSS_WITH_SELFSIGNED_CERT" = "1" ]; then
|
2017-02-21 23:50:51 +01:00
|
|
|
# Install OpenSSL.
|
|
|
|
|
apk update && apk add openssl
|
2017-07-28 22:12:19 +02:00
|
|
|
|
2015-09-04 17:12:37 +02:00
|
|
|
if [ ! -f "/etc/ssl/private/ttrss.key" ]; then
|
2017-02-21 23:50:08 +01:00
|
|
|
echo "Setup: Generating self-signed certificate ..."
|
2015-09-04 17:12:37 +02:00
|
|
|
# Generate the TLS certificate for our Tiny Tiny RSS server instance.
|
2017-10-05 12:52:03 +02:00
|
|
|
openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 \
|
2015-09-04 17:12:37 +02:00
|
|
|
-subj "/C=US/ST=World/L=World/O=$TTRSS_HOST/CN=$TTRSS_HOST" \
|
|
|
|
|
-keyout "/etc/ssl/private/ttrss.key" \
|
|
|
|
|
-out "/etc/ssl/certs/ttrss.crt"
|
|
|
|
|
fi
|
2017-02-21 23:50:51 +01:00
|
|
|
|
|
|
|
|
# Turn on SSL.
|
|
|
|
|
sed -i -e "s/listen\s*8080\s*;/listen 4443;/g" ${NGINX_CONF}
|
|
|
|
|
sed -i -e "s/ssl\s*off\s*;/ssl on;/g" ${NGINX_CONF}
|
|
|
|
|
sed -i -e "s/#ssl_/ssl_/g" ${NGINX_CONF}
|
|
|
|
|
|
|
|
|
|
# Set permissions.
|
2015-09-04 17:12:37 +02:00
|
|
|
chmod 600 "/etc/ssl/private/ttrss.key"
|
|
|
|
|
chmod 600 "/etc/ssl/certs/ttrss.crt"
|
|
|
|
|
else
|
2017-07-07 13:31:48 +02:00
|
|
|
echo "Setup: !!! WARNING - No encryption (TLS) used - WARNING !!!"
|
|
|
|
|
echo "Setup: !!! This is not recommended for a production server !!!"
|
|
|
|
|
echo "Setup: You have been warned."
|
2017-07-28 22:12:19 +02:00
|
|
|
|
2015-09-04 17:12:37 +02:00
|
|
|
# Turn off SSL.
|
2017-02-21 23:50:08 +01:00
|
|
|
sed -i -e "s/listen\s*4443\s*;/listen 8080;/g" ${NGINX_CONF}
|
|
|
|
|
sed -i -e "s/ssl\s*on\s*;/ssl off;/g" ${NGINX_CONF}
|
2017-02-21 23:50:51 +01:00
|
|
|
sed -i -e "s/ssl_/#ssl_/g" ${NGINX_CONF}
|
2015-09-04 17:12:37 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setup_ttrss()
|
|
|
|
|
{
|
2017-07-28 23:07:23 +02:00
|
|
|
if [ -z "$TTRSS_REPO_URL" ]; then
|
|
|
|
|
TTRSS_REPO_URL=https://git.tt-rss.org/git/tt-rss.git
|
2017-07-19 18:52:19 +12:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -z "$TTRSS_PATH" ]; then
|
|
|
|
|
TTRSS_PATH=/var/www/ttrss
|
|
|
|
|
fi
|
2017-07-28 23:07:23 +02:00
|
|
|
|
2018-12-16 14:44:25 +01:00
|
|
|
TTRSS_PATH_THEMES=${TTRSS_PATH}/themes.local
|
|
|
|
|
TTRSS_PATH_PLUGINS=${TTRSS_PATH}/plugins.local
|
|
|
|
|
|
2017-02-21 23:50:51 +01:00
|
|
|
if [ ! -d ${TTRSS_PATH} ]; then
|
|
|
|
|
mkdir -p ${TTRSS_PATH}
|
2017-07-13 17:57:15 +02:00
|
|
|
if [ -n "$TTRSS_GIT_TAG" ]; then
|
2017-07-13 18:13:45 +02:00
|
|
|
echo "Setup: Setting up Tiny Tiny RSS '$TTRSS_GIT_TAG' ..."
|
2017-07-13 17:57:15 +02:00
|
|
|
cd ${TTRSS_PATH}
|
|
|
|
|
git init .
|
2017-07-28 23:07:23 +02:00
|
|
|
git fetch --depth=1 ${TTRSS_REPO_URL} refs/tags/${TTRSS_GIT_TAG}:refs/tags/${TTRSS_GIT_TAG}
|
|
|
|
|
git checkout tags/${TTRSS_GIT_TAG}
|
2017-07-13 17:57:15 +02:00
|
|
|
else
|
2017-07-13 18:13:45 +02:00
|
|
|
echo "Setup: Setting up Tiny Tiny RSS (latest revision) ..."
|
2017-07-28 23:07:23 +02:00
|
|
|
git clone --depth=1 ${TTRSS_REPO_URL} ${TTRSS_PATH}
|
2017-07-13 17:57:15 +02:00
|
|
|
fi
|
2018-12-16 14:53:49 +01:00
|
|
|
|
|
|
|
|
mkdir -p ${TTRSS_PATH_PLUGINS}
|
2018-12-16 14:44:25 +01:00
|
|
|
git clone --depth=1 https://github.com/sepich/tt-rss-mobilize.git ${TTRSS_PATH_PLUGINS}/mobilize
|
2019-07-25 23:04:33 +02:00
|
|
|
git clone --depth=1 https://github.com/feediron/ttrss_plugin-feediron.git ${TTRSS_PATH_PLUGINS}/feediron
|
2018-12-16 14:53:49 +01:00
|
|
|
|
|
|
|
|
mkdir -p ${TTRSS_PATH_THEMES}
|
2018-12-16 14:44:25 +01:00
|
|
|
git clone --depth=1 https://github.com/levito/tt-rss-feedly-theme.git ${TTRSS_PATH_THEMES}/levito-feedly-git
|
|
|
|
|
git clone --depth=1 https://github.com/Gravemind/tt-rss-feedlish-theme.git ${TTRSS_PATH_THEMES}/gravemind-feedly-git
|
2017-02-21 23:50:51 +01:00
|
|
|
fi
|
2015-09-04 17:12:37 +02:00
|
|
|
|
|
|
|
|
# Add initial config.
|
|
|
|
|
cp ${TTRSS_PATH}/config.php-dist ${TTRSS_PATH}/config.php
|
|
|
|
|
|
2017-07-07 13:48:54 +02:00
|
|
|
# Check if TTRSS_URL is undefined, and if so, use localhost as default.
|
|
|
|
|
if [ -z ${TTRSS_URL} ]; then
|
|
|
|
|
TTRSS_URL=localhost
|
2017-07-07 13:31:48 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$TTRSS_WITH_SELFSIGNED_CERT" = "1" ]; then
|
|
|
|
|
# Make sure the TTRSS protocol is https now.
|
|
|
|
|
TTRSS_PROTO=https
|
2017-06-19 13:54:21 +00:00
|
|
|
fi
|
2015-09-04 17:12:37 +02:00
|
|
|
|
2017-07-07 13:31:48 +02:00
|
|
|
# If no protocol is specified, use http as default. Not secure, I know.
|
|
|
|
|
if [ -z ${TTRSS_PROTO} ]; then
|
|
|
|
|
TTRSS_PROTO=http
|
2017-07-28 23:13:29 +02:00
|
|
|
fi
|
2017-07-07 13:31:48 +02:00
|
|
|
|
2017-10-05 12:42:09 +02:00
|
|
|
# Add a leading colon (for the final URL) to the port.
|
2017-07-28 23:13:29 +02:00
|
|
|
if [ -n "$TTRSS_PORT" ]; then
|
|
|
|
|
TTRSS_PORT=:${TTRSS_PORT}
|
2017-07-07 13:31:48 +02:00
|
|
|
fi
|
2017-07-28 23:07:23 +02:00
|
|
|
|
2017-07-21 23:35:05 +12:00
|
|
|
# If we've been passed $TTRSS_SELF_URL as an env variable, then use that,
|
2017-07-28 22:26:41 +02:00
|
|
|
# otherwise use the URL we constructed above.
|
2017-07-21 23:44:37 +12:00
|
|
|
if [ -z "$TTRSS_SELF_URL" ]; then
|
2017-07-28 22:26:41 +02:00
|
|
|
# Construct the final URL TTRSS will use.
|
|
|
|
|
TTRSS_SELF_URL=${TTRSS_PROTO}://${TTRSS_URL}${TTRSS_PORT}/
|
2017-07-21 23:35:05 +12:00
|
|
|
fi
|
2017-07-07 13:31:48 +02:00
|
|
|
|
|
|
|
|
echo "Setup: URL is: $TTRSS_SELF_URL"
|
|
|
|
|
|
2019-07-25 23:25:45 +02:00
|
|
|
# By default we want to reset the theme to the default one.
|
|
|
|
|
if [ -z ${TTRSS_THEME_RESET} ]; then
|
|
|
|
|
TTRSS_THEME_RESET=1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-07-07 13:31:48 +02:00
|
|
|
# Patch URL path.
|
2021-02-23 21:31:24 +01:00
|
|
|
echo "putenv('TTRSS_SELF_URL_PATH=$TTRSS_SELF_URL');" >> ${TTRSS_PATH}/config.php
|
|
|
|
|
|
2017-11-19 15:54:19 +01:00
|
|
|
# Check if single user mode is selected
|
|
|
|
|
if [ "$TTRSS_SINGLEUSER" = true ]; then
|
|
|
|
|
echo "Single User mode Selected"
|
2021-02-23 21:31:24 +01:00
|
|
|
echo "putenv('TTRSS_SINGLE_USER_MODE=1');" >> ${TTRSS_PATH}/config.php
|
2017-11-19 15:54:19 +01:00
|
|
|
fi
|
|
|
|
|
|
2017-07-28 22:12:19 +02:00
|
|
|
# Enable additional system plugins.
|
|
|
|
|
if [ -z ${TTRSS_PLUGINS} ]; then
|
|
|
|
|
|
2017-10-05 12:49:18 +02:00
|
|
|
TTRSS_PLUGINS=
|
2017-07-28 22:12:19 +02:00
|
|
|
|
|
|
|
|
# Only if SSL/TLS is enabled: af_zz_imgproxy (Loads insecure images via built-in proxy).
|
|
|
|
|
if [ "$TTRSS_PROTO" = "https" ]; then
|
2017-10-05 12:49:18 +02:00
|
|
|
TTRSS_PLUGINS=${TTRSS_PLUGINS}af_zz_imgproxy
|
2017-07-28 22:12:19 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Setup: Additional plugins: $TTRSS_PLUGINS"
|
|
|
|
|
|
|
|
|
|
sed -i -e "s/.*define('PLUGINS'.*/define('PLUGINS', '$TTRSS_PLUGINS, auth_internal, note, updater');/g" ${TTRSS_PATH}/config.php
|
2019-07-25 23:25:45 +02:00
|
|
|
|
|
|
|
|
# Export variables for sub shells.
|
|
|
|
|
export TTRSS_PATH
|
|
|
|
|
export TTRSS_PATH_PLUGINS
|
|
|
|
|
export TTRSS_THEME_RESET
|
2015-09-04 17:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:24:17 +02:00
|
|
|
setup_db()
|
|
|
|
|
{
|
|
|
|
|
echo "Setup: Database"
|
|
|
|
|
php -f /srv/ttrss-configure-db.php
|
|
|
|
|
php -f /srv/ttrss-configure-plugin-mobilize.php
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 17:12:37 +02:00
|
|
|
setup_nginx
|
2017-07-07 13:31:48 +02:00
|
|
|
setup_ttrss
|
2017-07-13 18:24:17 +02:00
|
|
|
setup_db
|
2015-09-04 17:12:37 +02:00
|
|
|
|
2017-07-14 11:28:15 +02:00
|
|
|
echo "Setup: Applying updates ..."
|
|
|
|
|
/srv/update-ttrss.sh --no-start
|
|
|
|
|
|
2015-09-04 17:12:37 +02:00
|
|
|
echo "Setup: Done"
|