mirror of
https://github.com/YunoHost-Apps/freshrss_ynh.git
synced 2024-09-03 18:36:33 +02:00
Merge pull request #30 from YunoHost-Apps/feature/use-cli-interface
Feature/use cli interface
This commit is contained in:
commit
9c59e7e791
16 changed files with 208 additions and 285 deletions
|
@ -4,6 +4,9 @@
|
||||||
* [YunoHost website](https://yunohost.org)
|
* [YunoHost website](https://yunohost.org)
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
* Update to FreshRSS 1.6.3
|
||||||
|
* Complete package refactoring
|
||||||
|
* Update to FreshRSS 1.6.2
|
||||||
* Update to FreshRSS 1.5
|
* Update to FreshRSS 1.5
|
||||||
* Refactoring of yunohost scripts
|
* Refactoring of yunohost scripts
|
||||||
* Update to FreshRSS 1.4
|
* Update to FreshRSS 1.4
|
||||||
|
|
34
check_process
Normal file
34
check_process
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
;; Test complet
|
||||||
|
auto_remove=1
|
||||||
|
; Manifest
|
||||||
|
domain="domain.tld" (DOMAIN)
|
||||||
|
path="/path" (PATH)
|
||||||
|
admin="homer" (USER)
|
||||||
|
; Checks
|
||||||
|
pkg_linter=1
|
||||||
|
setup_sub_dir=1
|
||||||
|
setup_root=1
|
||||||
|
setup_nourl=0
|
||||||
|
setup_private=0
|
||||||
|
setup_public=0
|
||||||
|
upgrade=1
|
||||||
|
backup_restore=1
|
||||||
|
multi_instance=1
|
||||||
|
wrong_user=1
|
||||||
|
wrong_path=1
|
||||||
|
incorrect_path=1
|
||||||
|
corrupt_source=0
|
||||||
|
fail_download_source=0
|
||||||
|
port_already_use=0
|
||||||
|
final_path_already_use=0
|
||||||
|
;;; Levels
|
||||||
|
Level 1=auto
|
||||||
|
Level 2=auto
|
||||||
|
Level 3=auto
|
||||||
|
Level 4=1
|
||||||
|
Level 5=1
|
||||||
|
Level 6=auto
|
||||||
|
Level 7=auto
|
||||||
|
Level 8=0
|
||||||
|
Level 9=0
|
||||||
|
Level 10=0
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
return array (
|
|
||||||
'environment' => 'production',
|
|
||||||
'salt' => 'yunosalt',
|
|
||||||
'title' => 'FreshRSS',
|
|
||||||
'default_user' => 'yunoadminuser',
|
|
||||||
'auth_type' => 'http_auth',
|
|
||||||
'db' =>
|
|
||||||
array (
|
|
||||||
'type' => 'mysql',
|
|
||||||
'host' => 'localhost',
|
|
||||||
'user' => 'yunouser',
|
|
||||||
'password' => 'yunopass',
|
|
||||||
'base' => 'yunobase',
|
|
||||||
'prefix' => false,
|
|
||||||
),
|
|
||||||
'allow_anonymous' => false,
|
|
||||||
'allow_anonymous_refresh' => false,
|
|
||||||
'unsafe_autologin_enabled' => false,
|
|
||||||
'api_enabled' => true,
|
|
||||||
'extensions_enabled' => array(),
|
|
||||||
);
|
|
13
conf/freshrss-deps.control
Normal file
13
conf/freshrss-deps.control
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Homepage: https://github.com/FreshRSS/FreshRSS
|
||||||
|
Standards-Version: 3.9.2
|
||||||
|
|
||||||
|
Package: freshrss-deps
|
||||||
|
Version: 1.6.3
|
||||||
|
Depends: php5-cli, php5-gmp
|
||||||
|
Architecture: all
|
||||||
|
Description: meta package for freshrss dependencies
|
||||||
|
FreshRSS is a self-hosted RSS feed aggregator such as Leed or Kriss Feed.
|
||||||
|
.
|
||||||
|
This meta-package is only responsible of installing its dependencies.
|
1
conf/freshrss.cron
Normal file
1
conf/freshrss.cron
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*/10 * * * * www-data /usr/bin/php #DESTDIR#/app/actualize_script.php >/tmp/FreshRSS.log 2>&1
|
|
@ -1,51 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
app=$1
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
new_users=$2
|
new_users=$2
|
||||||
app_path=/var/www/freshrss
|
app_path=/var/www/$app
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
|
||||||
if [[ "freshrss" = "$app" ]];
|
if [[ "freshrss" = "$app" ]];
|
||||||
then
|
then
|
||||||
db_user=freshrss
|
|
||||||
db_name=freshrss
|
|
||||||
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
|
|
||||||
|
|
||||||
#check wallabag
|
|
||||||
if [[ $(sudo yunohost app list --installed -f wallabag2) -eq 0 ]]; then
|
|
||||||
echo "Detected wallabag V2"
|
|
||||||
wallabagPath=$(sudo yunohost app setting wallabag2 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
|
|
||||||
elif [[ $(sudo yunohost app list --installed -f wallabag) -eq 0 ]]; then
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
for myuser in $(echo "$new_users" | sed "s/,/ /g")
|
for myuser in $(echo "$new_users" | sed "s/,/ /g")
|
||||||
do
|
do
|
||||||
#copy sql
|
user_token=$(ynh_string_random)
|
||||||
sudo cp $app_path/app/SQL/install_ynh.sql /tmp/$myuser-install.sql
|
$app_path/cli/create-user.php --user $myuser --language en --token $user_token --no-default-feeds
|
||||||
|
|
||||||
#change username in sql
|
|
||||||
sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
|
|
||||||
#create tables
|
|
||||||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" \
|
|
||||||
< "/tmp/$myuser-install.sql"
|
|
||||||
#remove temp sql
|
|
||||||
sudo rm /tmp/$myuser-install.sql
|
|
||||||
|
|
||||||
#copy default conf
|
|
||||||
sudo cp -r $app_path/data/users/_ $app_path/data/users/$myuser/
|
|
||||||
sudo mv $app_path/data/users/$myuser/config.default.php $app_path/data/users/$myuser/config.php
|
|
||||||
#add wallabag sharing
|
|
||||||
if [[ $sharingEnable -eq 1 ]]; then
|
|
||||||
sudo sed -i "s@'sharing'\ =>\ array\ (@$sharingWallabag@g" $app_path/data/users/$myuser/config.php
|
|
||||||
fi
|
|
||||||
sudo chown -R www-data: $app_path/data/users/$myuser/
|
sudo chown -R www-data: $app_path/data/users/$myuser/
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
db_user=freshrss
|
app_path=/var/www/$app
|
||||||
db_name=freshrss
|
|
||||||
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
|
|
||||||
app_path=/var/www/freshrss
|
|
||||||
|
|
||||||
myuser=$1
|
myuser=$1
|
||||||
|
|
||||||
#copy sql
|
# Source app helpers
|
||||||
sudo cp $app_path/app/SQL/install_ynh.sql /tmp/$myuser-install.sql
|
. /usr/share/yunohost/helpers
|
||||||
#change username in sql
|
|
||||||
sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
|
user_token=$(ynh_string_random)
|
||||||
#create tables
|
sudo $app_path/cli/create-user.php --user $myuser --language en --token $user_token --no-default-feeds
|
||||||
mysql -u $db_user -p$db_pwd $db_user < /tmp/$myuser-install.sql
|
|
||||||
#remove temp sql
|
|
||||||
sudo rm /tmp/$myuser-install.sql
|
|
||||||
#copy default conf
|
|
||||||
sudo cp -r $app_path/data/users/_ $app_path/data/users/$myuser/
|
|
||||||
sudo mv $app_path/data/users/$myuser/config.default.php $app_path/data/users/$myuser/config.php
|
|
||||||
sudo chown -R www-data: $app_path/data/users/$myuser/
|
sudo chown -R www-data: $app_path/data/users/$myuser/
|
||||||
|
|
6
hooks/post_user_delete
Executable file
6
hooks/post_user_delete
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
app_path=/var/www/$app
|
||||||
|
|
||||||
|
myuser=$1
|
||||||
|
$app_path/cli/delete-user.php --user $myuser
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "FreshRSS",
|
"name": "FreshRSS",
|
||||||
"id": "freshrss",
|
"id": "freshrss",
|
||||||
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "FreshRSS is a selfhostable RSS reader",
|
"en": "FreshRSS is a selfhostable RSS reader",
|
||||||
"fr": "FreshRSS est un agrégateur de flux RSS à auto-héberger"
|
"fr": "FreshRSS est un agrégateur de flux RSS à auto-héberger"
|
||||||
|
@ -11,7 +12,10 @@
|
||||||
"name": "plopoyop",
|
"name": "plopoyop",
|
||||||
"email": "plopoyop@gmail.com"
|
"email": "plopoyop@gmail.com"
|
||||||
},
|
},
|
||||||
"multi_instance": "false",
|
"requirements": {
|
||||||
|
"yunohost": ">= 2.4.0"
|
||||||
|
},
|
||||||
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php5-fpm",
|
||||||
|
@ -41,9 +45,10 @@
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user",
|
||||||
|
"optional": false,
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the default user (leave empty if none)",
|
"en": "Choose the default user",
|
||||||
"fr": "Choisissez l'utilisateur par defaut (laissez vide si aucun)"
|
"fr": "Choisissez l'utilisateur par defaut"
|
||||||
},
|
},
|
||||||
"example": "homer"
|
"example": "homer"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,41 @@
|
||||||
#
|
#
|
||||||
# Common variables
|
# Common variables
|
||||||
#
|
#
|
||||||
|
APPNAME="freshrss"
|
||||||
|
# FreshRSS version
|
||||||
|
VERSION="1.6.3"
|
||||||
|
|
||||||
# FreshRss version
|
# FreshRSS complete tarball checksum
|
||||||
VERSION="1.5.0"
|
FRESHRSS_SOURCE_SHA256="06bcdfbde53bd8f01b8376ee28a4f1f9630c3409d5dc12f02f74f2f7aff4a6f9"
|
||||||
|
|
||||||
# Roundcube complete tarball checksum
|
# Remote URL to fetch FreshRSS source tarball
|
||||||
FRESHRSS_SOURCE_SHA256="72c3dcb3e58f4cf7d7e6a06ffec0cad8540ee5aeee9024e785b56e8d55656746"
|
FRESHRSS_SOURCE_URL="https://github.com/FreshRSS/FreshRSS/archive/1.6.3.tar.gz"
|
||||||
|
|
||||||
# Remote URL to fetch Roundcube source tarball
|
|
||||||
FRESHRSS_SOURCE_URL="https://github.com/FreshRSS/FreshRSS/archive/1.5.0.tar.gz"
|
|
||||||
|
|
||||||
PKGDIR=$(cd ../; pwd)
|
PKGDIR=$(cd ../; pwd)
|
||||||
|
|
||||||
FINAL_PATH="/var/www/freshrss"
|
#apt dependencies
|
||||||
|
DEPS_PKG_NAME="freshrss-deps"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Common helpers
|
# Common helpers
|
||||||
#
|
#
|
||||||
# Download and extract FreshRss sources to the given directory
|
# Download and extract FreshRSS sources to the given directory
|
||||||
# usage: extract_freshrss DESTDIR
|
# usage: extract_freshrss DESTDIR
|
||||||
extract_freshrss() {
|
extract_freshrss() {
|
||||||
local DESTDIR=$1
|
local DESTDIR=$1
|
||||||
|
|
||||||
# retrieve and extract FreshRss tarball
|
# retrieve and extract FreshRSS tarball
|
||||||
rc_tarball="${DESTDIR}/freshrss.tar.gz"
|
rc_tarball="${DESTDIR}/freshrss.tar.gz"
|
||||||
wget -q -O "$rc_tarball" "$FRESHRSS_SOURCE_URL" \
|
wget -q -O "$rc_tarball" "$FRESHRSS_SOURCE_URL" \
|
||||||
|| ynh_die "Unable to download FreshRss tarball"
|
|| ynh_die "Unable to download FreshRSS tarball"
|
||||||
echo "$FRESHRSS_SOURCE_SHA256 $rc_tarball" | sha256sum -c >/dev/null \
|
echo "$FRESHRSS_SOURCE_SHA256 $rc_tarball" | sha256sum -c >/dev/null \
|
||||||
|| ynh_die "Invalid checksum of downloaded tarball"
|
|| ynh_die "Invalid checksum of downloaded tarball"
|
||||||
tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \
|
tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \
|
||||||
|| ynh_die "Unable to extract FreshRss tarball"
|
|| ynh_die "Unable to extract FreshRss tarball"
|
||||||
rm "$rc_tarball"
|
sudo rm "$rc_tarball"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_freshrss_dependencies() {
|
||||||
|
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||||
|
|| ynh_die "Unable to install dependencies"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location dedicated to the app
|
# Source app helpers
|
||||||
BACKUP_DIR=$1
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# The parameter $2 is the id of the app instance ex: strut__2
|
|
||||||
APP=$2
|
|
||||||
|
|
||||||
# retrieve useful param
|
# retrieve useful param
|
||||||
domain=$(sudo yunohost app setting ${APP} domain)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
db_pwd=$(sudo yunohost app setting ${APP} mysqlpwd)
|
path=/var/www/$app
|
||||||
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
# Backup app files
|
# Backup app files
|
||||||
sudo mkdir -p "${BACKUP_DIR}/www"
|
ynh_backup "$path" "www"
|
||||||
sudo cp -a /var/www/${APP}/. "${BACKUP_DIR}/www"
|
|
||||||
|
|
||||||
# Backup conf files
|
# Backup conf files
|
||||||
sudo mkdir -p "${BACKUP_DIR}/conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
|
||||||
sudo cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.conf"
|
ynh_backup "/etc/cron.d/$app" "$app.cron"
|
||||||
sudo cp -a /etc/cron.d/${APP} "${BACKUP_DIR}/conf/${APP}"
|
|
||||||
|
|
||||||
# Backup mysql
|
# Backup mysql
|
||||||
mysqldump -u ${APP} -p$db_pwd ${APP} | sudo dd of=${BACKUP_DIR}/${APP}.dmp
|
ynh_mysql_dump_db $app > $app.dmp
|
||||||
|
|
130
scripts/install
130
scripts/install
|
@ -3,125 +3,89 @@
|
||||||
# Exit on command errors and treat unset variables as an error
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$1
|
|
||||||
path=$2
|
|
||||||
admin_user=$3
|
|
||||||
|
|
||||||
# Load common variables and helpers
|
# Load common variables and helpers
|
||||||
. ./_common.sh
|
. ./_common.sh
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path=${YNH_APP_ARG_PATH%/}
|
||||||
|
admin_user=$YNH_APP_ARG_ADMIN
|
||||||
|
# Setup variables
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
db_user=$app
|
||||||
|
db_name=$app
|
||||||
|
|
||||||
|
FINAL_PATH="/var/www/$app"
|
||||||
|
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# if path do not begin with / add a / at the begining
|
||||||
|
if [ "${path:0:1}" != "/" ]; then
|
||||||
|
path="/$path"
|
||||||
|
fi
|
||||||
|
# if path do not end with / add a / at the end
|
||||||
|
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
|
||||||
|
path="${path:0:${#path}-1}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Check user parameter if not empty
|
# Check user parameter if not empty
|
||||||
if [[ $admin_user != '' ]]; then
|
if [[ $admin_user != '' ]]; then
|
||||||
sudo yunohost user list --json | grep -qi "\"username\": \"$admin_user\""
|
ynh_user_exists $admin_user || ynh_die "Wrong user"
|
||||||
if [[ ! $? -eq 0 ]]; then
|
ynh_app_setting_set $app admin_user $admin_user
|
||||||
echo "Wrong user"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sudo yunohost app setting freshrss admin_user -v $admin_user
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a freshrss
|
sudo yunohost app checkurl $domain$path -a $app || ynh_die "The path ${domain}${path} is not available for app installation."
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
exit 1
|
#install php5-cli
|
||||||
fi
|
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||||
|
|| ynh_die "Unable to install dependencies"
|
||||||
|
|
||||||
# Generate random DES key & password
|
# Generate random DES key & password
|
||||||
deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
deskey=$(ynh_string_random)
|
||||||
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
db_pwd=$(ynh_string_random)
|
||||||
app_salt=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{40\}\).*/\1/p')
|
app_salt=$(ynh_string_random)
|
||||||
# Use 'freshrss' as database name and user
|
|
||||||
db_user=freshrss
|
|
||||||
db_name=freshrss
|
|
||||||
# Initialize database and store mysql password for upgrade
|
# Initialize database and store mysql password for upgrade
|
||||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
|
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
|
||||||
sudo yunohost app setting freshrss mysqlpwd -v $db_pwd
|
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
TMPDIR=$(ynh_mkdir_tmp)
|
TMPDIR=$(mktemp -d)
|
||||||
|
sudo chmod 755 "$TMPDIR"
|
||||||
extract_freshrss "$TMPDIR"
|
extract_freshrss "$TMPDIR"
|
||||||
sudo cp -a ../conf/config.php $TMPDIR/data
|
|
||||||
sudo cp ../sources/install_ynh.sql $TMPDIR/app/SQL/install_ynh.sql
|
|
||||||
|
|
||||||
# Change variables in freshrss configuration
|
$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
|
||||||
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
|
|
||||||
|
|
||||||
# Add users
|
# Add users
|
||||||
|
for myuser in $(ynh_user_list)
|
||||||
#check wallabag
|
|
||||||
sharingEnable=0
|
|
||||||
if sudo yunohost app list --installed -f wallabag2 | grep -q id ; then
|
|
||||||
echo "Detected wallabag V2"
|
|
||||||
wallabagPath=$(sudo yunohost app setting wallabag2 path | sed 's#/*$##')
|
|
||||||
wallabagUrl=$domain$wallabagPath
|
|
||||||
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
|
|
||||||
elif sudo yunohost app list --installed -f wallabag | grep -q id ; then
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
do
|
||||||
#copy sql
|
user_token=$(ynh_string_random)
|
||||||
sudo cp ../sources/install_ynh.sql /tmp/$myuser-install.sql
|
$TMPDIR/cli/create-user.php --user $myuser --language en --token $user_token --no-default-feeds
|
||||||
#change username in sql
|
|
||||||
sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
|
|
||||||
#create tables
|
|
||||||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" \
|
|
||||||
< "/tmp/$myuser-install.sql"
|
|
||||||
|
|
||||||
#remove temp sql
|
|
||||||
sudo rm /tmp/$myuser-install.sql
|
|
||||||
#copy default conf
|
|
||||||
sudo cp -r $TMPDIR/data/users/_/ $TMPDIR/data/users/$myuser
|
|
||||||
sudo mv $TMPDIR/data/users/$myuser/config.default.php $TMPDIR/data/users/$myuser/config.php
|
|
||||||
|
|
||||||
if [[ $sharingEnable -eq 1 ]]; then
|
|
||||||
sudo sed -i "s@'sharing'\ =>\ array\ (@$sharingWallabag@g" $TMPDIR/data/users/$myuser/config.php
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
# Delete install directive
|
|
||||||
sudo rm $TMPDIR/data/do-install.txt
|
|
||||||
# Move temp dir to final dir
|
# Move temp dir to final dir
|
||||||
sudo mv $TMPDIR $FINAL_PATH
|
sudo mv $TMPDIR $FINAL_PATH
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@ALIASTOCHANGE@$FINAL_PATH/@g" ../conf/nginx.conf
|
sed -i "s@ALIASTOCHANGE@$FINAL_PATH/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/freshrss.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
#install php5-cli
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y php5-cli php5-gmp
|
|
||||||
#install update cron
|
#install update cron
|
||||||
echo "*/10 * * * * www-data /usr/bin/php $FINAL_PATH/app/actualize_script.php >/tmp/FreshRSS.log 2>&1" > /tmp/cronfreshrss
|
# Add cron job
|
||||||
sudo mv /tmp/cronfreshrss /etc/cron.d/freshrss
|
cron_path="/etc/cron.d/$app"
|
||||||
sudo chown root /etc/cron.d/freshrss
|
sed -i "s@#DESTDIR#@${FINAL_PATH}@g" ../conf/freshrss.cron
|
||||||
|
sudo cp ../conf/freshrss.cron "$cron_path"
|
||||||
|
sudo chmod 644 "$cron_path"
|
||||||
|
|
||||||
|
|
||||||
# Set permissions to freshrss directory
|
# Set permissions to freshrss directory
|
||||||
|
sudo chown -R root:root $FINAL_PATH
|
||||||
sudo chown -R www-data: $FINAL_PATH/data/
|
sudo chown -R www-data: $FINAL_PATH/data/
|
||||||
sudo chown -R www-data: $FINAL_PATH/extensions/
|
sudo chown -R www-data: $FINAL_PATH/extensions/
|
||||||
#skip api directory
|
#skip api directory
|
||||||
sudo yunohost app setting freshrss skipped_uris -v /api/greader.php
|
ynh_app_setting_set "$app" skipped_uris /api/greader.php
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
db_user=freshrss
|
# Exit on command errors and treat unset variables as an error
|
||||||
db_name=freshrss
|
set -u
|
||||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
||||||
domain=$(sudo yunohost app setting freshrss domain)
|
|
||||||
|
|
||||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
# Source app helpers
|
||||||
sudo rm -rf /var/www/freshrss
|
. /usr/share/yunohost/helpers
|
||||||
sudo rm -rf /etc/cron.d/freshrss
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/freshrss.conf
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
db_user=$app
|
||||||
|
db_name=$app
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
|
ynh_mysql_drop_db $db_name
|
||||||
|
ynh_mysql_drop_user $db_user
|
||||||
|
|
||||||
|
sudo rm -rf /var/www/$app
|
||||||
|
sudo rm -rf /etc/cron.d/$app
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location dedicated to the app
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
BACKUP_DIR=$1
|
db_user=$app
|
||||||
|
db_name=$app
|
||||||
|
|
||||||
# The parameter $2 is the id of the app instance ex: strut__2
|
|
||||||
APP=$2
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# retrieve useful param
|
# retrieve useful param
|
||||||
domain=$(sudo yunohost app setting ${APP} domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
db_pwd=$(sudo yunohost app setting ${APP} mysqlpwd)
|
path=$(ynh_app_setting_get $app path)
|
||||||
path=$(sudo yunohost app setting ${APP} path)
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a ${APP} \
|
sudo yunohost app checkurl $domain$path -a $app || ynh_die "The path ${domain}${path} is not available for app installation."
|
||||||
|| (echo "Path not available: $domain$path" && exit 1)
|
|
||||||
|
db_pass=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
final_path=/var/www/${APP}
|
final_path=/var/www/$app
|
||||||
sudo mkdir $final_path
|
ynh_backup "www" "$final_path"
|
||||||
sudo cp -a ${BACKUP_DIR}/www/. $final_path
|
|
||||||
|
|
||||||
# Restore permissions
|
# Restore permissions
|
||||||
sudo chown -R root:root $final_path
|
sudo chown -R root:root $final_path
|
||||||
|
@ -28,11 +29,12 @@ sudo chown -R www-data: $final_path/data/
|
||||||
sudo chown -R www-data: $final_path/extensions/
|
sudo chown -R www-data: $final_path/extensions/
|
||||||
|
|
||||||
# Restore conf files
|
# Restore conf files
|
||||||
sudo cp -a "${BACKUP_DIR}/conf/${APP}.conf" /etc/nginx/conf.d/$domain.d/${APP}.conf
|
ynh_backup nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp -a "${BACKUP_DIR}/conf/${APP}" /etc/cron.d/${APP}
|
ynh_backup $app.cron /etc/cron.d/$app
|
||||||
|
|
||||||
# Restore mysql dump
|
# Restore mysql dump
|
||||||
sudo su -c "mysql -u ${APP} -p$db_pwd ${APP} < ${BACKUP_DIR}/${APP}.dmp"
|
ynh_mysql_create_db "$db_name" "$db_user" "$db_pass"
|
||||||
|
ynh_mysql_connect_as "$db_user" "$db_pass" "$db_name" < "$app.dmp"
|
||||||
|
|
||||||
# Reload Nginx, and regenerate SSOwat conf
|
# Reload Nginx, and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
|
@ -8,36 +8,39 @@ set -eu
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#old version cleanup
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
if [ -f $FINAL_PATH/data/user.php.dist ]; then
|
FINAL_PATH="/var/www/$app"
|
||||||
sudo rm $FINAL_PATH/data/user.php.dist
|
|
||||||
fi
|
#install extention for api if necessary
|
||||||
|
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||||
|
|| ynh_die "Unable to install dependencies"
|
||||||
|
|
||||||
# Check destination directory
|
# Check destination directory
|
||||||
[[ ! -d $FINAL_PATH ]] && ynh_die \
|
[[ ! -d $FINAL_PATH ]] && ynh_die \
|
||||||
"The destination directory '$FINAL_PATH' does not exist.\
|
"The destination directory '$FINAL_PATH' does not exist.\
|
||||||
The app is not correctly installed, you should remove it first."
|
The app is not correctly installed, you should remove it first."
|
||||||
|
|
||||||
|
#old version cleanup
|
||||||
|
if [ -f $FINAL_PATH/data/user.php.dist ]; then
|
||||||
|
sudo rm $FINAL_PATH/data/user.php.dist
|
||||||
|
fi
|
||||||
|
|
||||||
# Create tmp directory and install app inside
|
# Create tmp directory and install app inside
|
||||||
TMPDIR=$(ynh_mkdir_tmp)
|
TMPDIR=$(mktemp -d)
|
||||||
|
sudo chmod 755 "$TMPDIR"
|
||||||
extract_freshrss "$TMPDIR"
|
extract_freshrss "$TMPDIR"
|
||||||
|
|
||||||
# Restore config
|
# Restore config
|
||||||
sudo rm $TMPDIR/data/do-install.txt
|
sudo rm $TMPDIR/data/do-install.txt
|
||||||
sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php
|
sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php
|
||||||
sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/
|
sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/
|
||||||
|
sudo cp -r $FINAL_PATH/extensions/. $TMPDIR/extensions/
|
||||||
|
|
||||||
# Set permissions to freshrss directory
|
# Set permissions to freshrss directory
|
||||||
|
sudo chown -R root:root $TMPDIR
|
||||||
sudo chown -R www-data: $TMPDIR/data/
|
sudo chown -R www-data: $TMPDIR/data/
|
||||||
sudo chown -R www-data: $TMPDIR/extensions/
|
sudo chown -R www-data: $TMPDIR/extensions/
|
||||||
|
|
||||||
# Clean up existing files and copy new files to the right place
|
# Clean up existing files and copy new files to the right place
|
||||||
sudo rm -rf "$FINAL_PATH"
|
sudo rm -rf "$FINAL_PATH"
|
||||||
sudo cp -rp "$TMPDIR" "$FINAL_PATH"
|
sudo cp -rp "$TMPDIR" "$FINAL_PATH"
|
||||||
|
|
||||||
|
|
||||||
#install extention for api if necessary
|
|
||||||
if ! dpkg -s php5-gmp | grep "installed" > /dev/null 2>&1; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y php5-gmp
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS `YnoUser_category` (
|
|
||||||
`id` SMALLINT NOT NULL AUTO_INCREMENT, -- v0.7
|
|
||||||
`name` varchar(255) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY (`name`) -- v0.7
|
|
||||||
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
|
|
||||||
ENGINE = INNODB;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `YnoUser_feed` (
|
|
||||||
`id` SMALLINT NOT NULL AUTO_INCREMENT, -- v0.7
|
|
||||||
`url` varchar(511) CHARACTER SET latin1 NOT NULL,
|
|
||||||
`category` SMALLINT DEFAULT 0, -- v0.7
|
|
||||||
`name` varchar(255) NOT NULL,
|
|
||||||
`website` varchar(255) CHARACTER SET latin1,
|
|
||||||
`description` text,
|
|
||||||
`lastUpdate` int(11) DEFAULT 0, -- Until year 2038
|
|
||||||
`priority` tinyint(2) NOT NULL DEFAULT 10,
|
|
||||||
`pathEntries` varchar(511) DEFAULT NULL,
|
|
||||||
`httpAuth` varchar(511) DEFAULT NULL,
|
|
||||||
`error` boolean DEFAULT 0,
|
|
||||||
`keep_history` MEDIUMINT NOT NULL DEFAULT -2, -- v0.7
|
|
||||||
`ttl` INT NOT NULL DEFAULT -2, -- v0.7.3
|
|
||||||
`cache_nbEntries` int DEFAULT 0, -- v0.7
|
|
||||||
`cache_nbUnreads` int DEFAULT 0, -- v0.7
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
FOREIGN KEY (`category`) REFERENCES `YnoUser_category`(`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
|
||||||
UNIQUE KEY (`url`), -- v0.7
|
|
||||||
INDEX (`name`), -- v0.7
|
|
||||||
INDEX (`priority`), -- v0.7
|
|
||||||
INDEX (`keep_history`) -- v0.7
|
|
||||||
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
|
|
||||||
ENGINE = INNODB;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `YnoUser_entry` (
|
|
||||||
`id` bigint NOT NULL, -- v0.7
|
|
||||||
`guid` varchar(760) CHARACTER SET latin1 NOT NULL, -- Maximum for UNIQUE is 767B
|
|
||||||
`title` varchar(255) NOT NULL,
|
|
||||||
`author` varchar(255),
|
|
||||||
`content_bin` blob, -- v0.7
|
|
||||||
`link` varchar(1023) CHARACTER SET latin1 NOT NULL,
|
|
||||||
`date` int(11), -- Until year 2038
|
|
||||||
`lastSeen` INT(11) DEFAULT 0, -- v1.1.1, Until year 2038
|
|
||||||
`hash` BINARY(16), -- v1.1.1
|
|
||||||
`is_read` boolean NOT NULL DEFAULT 0,
|
|
||||||
`is_favorite` boolean NOT NULL DEFAULT 0,
|
|
||||||
`id_feed` SMALLINT, -- v0.7
|
|
||||||
`tags` varchar(1023),
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
FOREIGN KEY (`id_feed`) REFERENCES `YnoUser_feed`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
UNIQUE KEY (`id_feed`,`guid`), -- v0.7
|
|
||||||
INDEX (`is_favorite`), -- v0.7
|
|
||||||
INDEX (`is_read`), -- v0.7
|
|
||||||
INDEX `entry_lastSeen_index` (`lastSeen`) -- v1.1.1
|
|
||||||
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
|
|
||||||
ENGINE = INNODB;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO `YnoUser_category` (id, name) VALUES(1, "Uncategorized");
|
|
Loading…
Add table
Reference in a new issue