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
|
|
|
|
|
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
|
2015-07-25 11:10:11 +02:00
|
|
|
if [[ $admin_user != '' ]]; then
|
2017-02-12 10:59:44 +01:00
|
|
|
ynh_user_exists $admin_user
|
2016-09-04 11:32:18 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
echo "Wrong user"
|
|
|
|
exit 1
|
|
|
|
fi
|
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
|
2014-07-23 18:03:38 +02:00
|
|
|
sudo yunohost app checkurl $domain$path -a freshrss
|
2014-07-23 15:52:50 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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)
|
2014-07-23 15:52:50 +02:00
|
|
|
# Use 'freshrss' as database name and user
|
|
|
|
db_user=freshrss
|
2016-09-04 12:04:50 +02:00
|
|
|
db_name=freshrss
|
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"
|
2014-07-23 15:52:50 +02:00
|
|
|
sudo yunohost app setting freshrss mysqlpwd -v $db_pwd
|
|
|
|
|
|
|
|
# Copy files to the right place
|
2016-09-01 08:37:47 +02:00
|
|
|
TMPDIR=$(ynh_mkdir_tmp)
|
2016-09-01 08:38:50 +02:00
|
|
|
extract_freshrss "$TMPDIR"
|
2017-01-22 14:50:51 +01:00
|
|
|
cd $TMPDIR
|
2017-01-22 15:04:52 +01:00
|
|
|
./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
|
|
|
|
|
|
|
# sudo cp -a ../conf/config.php $TMPDIR/data
|
|
|
|
# sudo cp ../sources/install_ynh.sql $TMPDIR/app/SQL/install_ynh.sql
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
# Change variables in freshrss configuration
|
2017-01-22 14:50:51 +01:00
|
|
|
# sudo sed -i "s/yunouser/$db_user/g" $TMPDIR/data/config.php
|
|
|
|
# sudo sed -i "s/yunopass/$db_pwd/g" $TMPDIR/data/config.php
|
|
|
|
# sudo sed -i "s/yunobase/$db_user/g" $TMPDIR/data/config.php
|
|
|
|
# sudo sed -i "s/yunosalt/$app_salt/g" $TMPDIR/data/config.php
|
|
|
|
# sudo sed -i "s@yunopath@$path@g" $TMPDIR/data/config.php
|
|
|
|
# if [[ $admin_user != '' ]]; then
|
|
|
|
# sudo sed -i "s/yunoadminuser/$admin_user/g" $TMPDIR/data/config.php
|
|
|
|
# else
|
|
|
|
# sudo sed -i '/yunoadminuser/d' $TMPDIR/data/config.php
|
|
|
|
# fi
|
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
|
2016-09-04 11:26:23 +02:00
|
|
|
echo "Detected wallabag V2"
|
2016-09-04 11:41:13 +02:00
|
|
|
wallabagPath=$(sudo yunohost app setting wallabag2 path | sed 's#/*$##')
|
2016-09-04 11:26:23 +02:00
|
|
|
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),"
|
2016-09-04 11:26:23 +02:00
|
|
|
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
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
freshrss_users=$(ldapsearch -h localhost -b ou=users,dc=yunohost,dc=org -x objectClass=mailAccount uid | grep uid: | sed 's/uid: //' | xargs)
|
|
|
|
for myuser in $freshrss_users
|
|
|
|
do
|
2017-01-22 14:50:51 +01:00
|
|
|
user_token=$(ynh_string_random)
|
|
|
|
./cli/create-user.php --user $myuser --language en --token $user_token --no-default-feeds
|
2016-09-04 11:32:18 +02:00
|
|
|
#copy sql
|
2017-01-22 14:50:51 +01:00
|
|
|
# sudo cp ../sources/install_ynh.sql /tmp/$myuser-install.sql
|
2016-09-04 11:32:18 +02:00
|
|
|
#change username in sql
|
2017-01-22 14:50:51 +01:00
|
|
|
# sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
|
2016-09-04 11:32:18 +02:00
|
|
|
#create tables
|
2017-01-22 14:50:51 +01:00
|
|
|
# ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" \
|
|
|
|
# < "/tmp/$myuser-install.sql"
|
2016-09-04 12:04:50 +02:00
|
|
|
|
2016-09-04 11:32:18 +02:00
|
|
|
#remove temp sql
|
2017-01-22 15:03:06 +01:00
|
|
|
# sudo rm /tmp/$myuser-install.sql
|
2016-09-04 11:32:18 +02:00
|
|
|
#copy default conf
|
2017-01-22 15:03:06 +01:00
|
|
|
# sudo cp -r $TMPDIR/data/users/_/ $TMPDIR/data/users/$myuser
|
2017-01-22 15:10:04 +01:00
|
|
|
# sudo mv $TMPDIR/data/users/$myuser/config.default.php $TMPDIR/data/users/$myuser/config.php
|
2016-09-04 11:32:18 +02:00
|
|
|
|
2017-01-22 15:10:04 +01:00
|
|
|
# if [[ $sharingEnable -eq 1 ]]; then
|
|
|
|
# sudo sed -i "s@'sharing'\ =>\ array\ (@$sharingWallabag@g" $TMPDIR/data/users/$myuser/config.php
|
|
|
|
# fi
|
2014-07-23 15:52:50 +02:00
|
|
|
done
|
2016-09-01 08:37:47 +02:00
|
|
|
# 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 php5-cli
|
|
|
|
sudo apt-get update
|
2015-10-03 11:58:14 +02:00
|
|
|
sudo apt-get install -y php5-cli php5-gmp
|
2014-07-23 15:52:50 +02:00
|
|
|
#install update cron
|
2016-09-01 08:31:03 +02:00
|
|
|
echo "*/10 * * * * www-data /usr/bin/php $FINAL_PATH/app/actualize_script.php >/tmp/FreshRSS.log 2>&1" > /tmp/cronfreshrss
|
2014-07-23 16:04:02 +02:00
|
|
|
sudo mv /tmp/cronfreshrss /etc/cron.d/freshrss
|
2014-07-23 15:52:50 +02:00
|
|
|
sudo chown root /etc/cron.d/freshrss
|
|
|
|
|
|
|
|
# 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/
|
2015-10-03 11:58:14 +02:00
|
|
|
#skip api directory
|
2014-09-20 10:36:29 +02:00
|
|
|
sudo yunohost app setting freshrss skipped_uris -v /api/greader.php
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
2014-10-20 11:43:31 +02:00
|
|
|
sudo yunohost app ssowatconf
|