Installation von Tiny Tiny RSS/Installationsskript
Aus Synology Wiki
Dies ist die aktuellste Version dieser Seite. Sie hat keine bestätigte Version.
Installationsskript für Tiny Tiny RSS. Bezieht sich auf eine ältere Version und wird nicht mehr gepflegt.
This script is deprecated!
#!/bin/sh
#
#ttrss - post-install
# switch to directory
read -p "Give the directory of ttrss (enter '.' for current directory): " dir
if [ -z "$dir" ]; then
echo "no dir given"
exit 1
fi
cd "$dir"
# Safety check
if [ ! -e config.php* ]; then
echo "This does not look like a ttrss directory"
echo "Exiting..."
exit 1
fi
# check config_version
ConVer=26
CONFIG_VERSION=`awk -F ' |)' '/CONFIG_VERSION/{print $2}' config.php-dist`
if [ "$ConVer" -ne "$CONFIG_VERSION" ]; then
echo "This script is written for a different CONFIG_VERSION of ttrss"
exit 1
fi
#mysql
echo "Configuring mysql"
read -p "Enter the database name (will be 'ttrss_db' if you leave it empty): " db
read -p "Enter the MySQL user accessing ttRSSes database (will be 'ttrss_user' if you leave it empty): " db_user
read -p "Enter this users password (will be the users name if you leave it empty): " db_pass
read -p "Enter the full URL to TT RSSes directory (a la http://yourserver/tt-rss/): " ttrss_url
# set default names
if [ -z "$db" ]; then
db=ttrss_db
fi
if [ -z "$db_user" ]; then
db_user=ttrss_user
fi
if [ -z "$db_pass" ]; then
db_pass="$db_user"
fi
# get MySQLs root passwd (refactored)
got_root=0
root_pass=""
get_MySQL_root (){
if [ "$got_root" -ne 0 ]; then
return 0
fi
read -p "Enter MySQL's root password: " root_pass
/usr/syno/mysql/bin/mysql -u root -p"$root_pass" -e quit 2> /dev/null
if [ $? -ne 0 ]; then
echo "mysql's root password is wrong"
get_MySQL_root
fi
got_root=1
return 0
}
# create database
read -p "Should I create the MySQL database '$db'? (y/n): " input
if [ "$input" = "yes" -o "$input" = "y" ]; then
echo "Creating database '$db'."
get_MySQL_root
/usr/syno/mysql/bin/mysql -u root -p"$root_pass" -e "CREATE DATABASE $db;"
if [ $? -ne 0 ]; then
echo "There were problems with the creation of database '$db'."
echo "Exiting"
exit 1
else
echo "Created database '$db'."
fi
fi
#create user
read -p "Should I create the MySQL user '$db_user' and give him priviliges on '$db'? (y/n): " input
if [ "$input" = "yes" -o "$input" = "y" ]; then
echo "Creating MySQL user '$db_user' and granting him privileges on database '$db'."
get_MySQL_root
#Creating the user and granting privileges.
/usr/syno/mysql/bin/mysql -u root -p"$root_pass" -e "CREATE USER '$db_user'@'localhost' IDENTIFIED BY '$db_pass'; GRANT USAGE ON *.* TO '$db_user'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; GRANT ALL PRIVILEGES ON \`$db\`.* TO '$db_user'@'localhost'; FLUSH PRIVILEGES;"
if [ $? -ne 0 ]; then
echo "There were problems with the creation of user '$db_user'."
echo "Exiting"
exit 1
else
echo "Created user '$db_user'."
fi
fi
#install schema
echo "Installing schema."
/usr/syno/mysql/bin/mysql -u "$db_user" -D "$db" -p"$db_pass" < schema/ttrss_schema_mysql.sql
if [ $? -ne 0 ]; then
echo "There were problems installing the schema."
echo "Exiting"
exit 1
else
echo "Schema installed."
fi
echo "Finished mysql configuration."
#give nobody ownership of some directories.
for dir in "lock" "cache" "feed-icons"; do
chown -R nobody:nobody "$dir"
done
#create config file
echo "Creating config.php"
cp -p config.php-dist config.php
sed -i -e "s#[ ]*define('DB_TYPE',[ ]*\".*\");.*# define('DB_TYPE', \"mysql\");#" config.php
sed -i -e "s#[ ]*define('DB_USER',[ ]*\".*\");.*# define('DB_USER', \"$db_user\");#" config.php
sed -i -e "s#[ ]*define('DB_NAME',[ ]*\".*\");.*# define('DB_NAME', \"$db\");#" config.php
sed -i -e "s#[ ]*define('DB_PASS',[ ]*\".*\");.*# define('DB_PASS', \"$db_pass\");#" config.php
sed -i -e "s#[ ]*define('SELF_URL_PATH',[ ]*'.*');.*# define('SELF_URL_PATH', '$ttrss_url');#" config.php
echo "Finished!"