1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/freshrss_ynh.git synced 2024-09-03 18:36:33 +02:00
freshrss_ynh/scripts/install

96 lines
3.2 KiB
Text
Raw Normal View History

2014-07-23 15:52:50 +02:00
#!/bin/bash
2016-09-01 08:31:03 +02:00
# Exit on command errors and treat unset variables as an error
2016-09-04 14:04:05 +02:00
set -eu
2016-09-01 08:31:03 +02:00
2014-07-23 15:52:50 +02:00
# Retrieve arguments
domain=$1
path=$2
admin_user=$3
2017-02-13 22:20:55 +01:00
# Setup variables
$app=$APPNAME
db_user=$app
db_name=$app
2014-07-23 15:52:50 +02:00
2016-09-01 08:31:03 +02:00
# Load common variables and helpers
. ./_common.sh
# Source app helpers
. /usr/share/yunohost/helpers
2014-09-21 11:52:46 +02:00
2015-02-08 18:55:48 +01:00
# Check user parameter if not empty
if [[ $admin_user != '' ]]; then
2017-02-13 22:20:55 +01:00
ynh_user_exists $admin_user || ynh_die "Wrong user"
2017-02-12 11:07:35 +01:00
ynh_app_setting_set freshrss admin_user $admin_user
2014-09-21 11:52:46 +02:00
fi
2014-07-23 15:52:50 +02:00
# Check domain/path availability
2017-02-13 22:20:55 +01:00
sudo yunohost app checkurl $domain$path -a freshrss || ynh_die "The path ${domain}${path} is not available for app installation."
#install php5-cli
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|| ynh_die "Unable to install dependencies"
2014-07-23 15:52:50 +02:00
# Generate random DES key & password
2017-01-22 14:50:51 +01:00
deskey=$(ynh_string_random)
db_pwd=$(ynh_string_random)
app_salt=$(ynh_string_random)
2017-02-13 22:20:55 +01:00
2014-07-23 15:52:50 +02:00
# Initialize database and store mysql password for upgrade
2016-09-04 12:04:50 +02:00
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
2017-02-13 22:20:55 +01:00
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
2014-07-23 15:52:50 +02:00
# Copy files to the right place
TMPDIR=$(ynh_mkdir_tmp)
2016-09-01 08:38:50 +02:00
extract_freshrss "$TMPDIR"
2017-02-12 11:34:30 +01:00
$TMPDIR/cli/do-install.php --default_user $admin_user --auth_type http_auth --environment production --base_url $domain/$path --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_user --db-password $db_pwd --db-base $db_name
2017-01-22 14:50:51 +01:00
2014-07-23 15:52:50 +02:00
# Add users
2014-07-30 15:58:09 +02:00
#check wallabag
2016-09-16 11:11:52 +02:00
sharingEnable=0
2016-09-04 14:04:05 +02:00
if sudo yunohost app list --installed -f wallabag2 | grep -q id ; then
echo "Detected wallabag V2"
2016-09-04 11:41:13 +02:00
wallabagPath=$(sudo yunohost app setting wallabag2 path | sed 's#/*$##')
wallabagUrl=$domain$wallabagPath
2016-09-04 11:41:13 +02:00
sharingWallabag="'sharing' => \n\tarray( \n\t\t0 => \n\t\tarray(\n\t\t\t'type' => 'wallabagv2',\n\t\t\t'name' => 'Wallabag',\n\t\t\t'url' => 'https://$wallabagUrl',\n\t\t),"
sharingEnable=1
2016-09-04 14:04:05 +02:00
elif sudo yunohost app list --installed -f wallabag | grep -q id ; then
2016-09-04 15:19:28 +02:00
echo "Detected wallabag"
wallabagPath=$(sudo yunohost app setting wallabag path)
wallabagUrl=$domain$wallabagPath
sharingWallabag="'sharing' => \n\tarray( \n\t\t0 => \n\t\tarray(\n\t\t\t'type' => 'wallabag',\n\t\t\t'name' => 'Wallabag',\n\t\t\t'url' => 'https://$wallabagUrl',\n\t\t),"
sharingEnable=1
2014-07-30 15:58:09 +02:00
fi
2017-02-13 22:20:55 +01:00
for myuser in ynh_user_list
2014-07-23 15:52:50 +02:00
do
2017-01-22 14:50:51 +01:00
user_token=$(ynh_string_random)
2017-02-12 11:34:30 +01:00
$TMPDIR/cli/create-user.php --user $myuser --language en --token $user_token --no-default-feeds
2014-07-23 15:52:50 +02:00
done
# Move temp dir to final dir
sudo mv $TMPDIR $FINAL_PATH
2014-07-23 15:52:50 +02:00
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
2016-09-01 08:31:03 +02:00
sed -i "s@ALIASTOCHANGE@$FINAL_PATH/@g" ../conf/nginx.conf
2014-07-23 15:52:50 +02:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/freshrss.conf
#install update cron
2017-02-13 22:20:55 +01:00
# Add cron job
cron_path="/etc/cron.d/$app"
sed -i "s@#DESTDIR#@${FINAL_PATH}@g" ../conf/freshrss.cron
sudo cp ../conf/freshrss.cron "$cron_path"
sudo chmod 644 "$cron_path"
2014-07-23 15:52:50 +02:00
# Set permissions to freshrss directory
2016-09-01 08:31:03 +02:00
sudo chown -R www-data: $FINAL_PATH/data/
sudo chown -R www-data: $FINAL_PATH/extensions/
#skip api directory
2017-02-13 22:20:55 +01:00
ynh_app_setting_set "$app" skipped_uris -v /api/greader.php
2014-07-23 15:52:50 +02:00
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf