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

use new helpers and fix install

This commit is contained in:
Clément 2018-07-21 12:18:50 +02:00
parent d69542cba8
commit bc6f2f88fa
2 changed files with 47 additions and 30 deletions

View file

@ -1,12 +1,24 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables and helpers
. ./_common.sh
source _common.sh
source /usr/share/yunohost/helpers
# Retrieve arguments
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path=${YNH_APP_ARG_PATH%/}
admin_user=$YNH_APP_ARG_ADMIN
@ -17,29 +29,18 @@ db_name=$app
FINAL_PATH="/var/www/$app"
# Source app 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
# keep domain for later
ynh_app_setting_set $app domain $domain
# Normalize the url path syntax
path=$(ynh_normalize_url_path $path)
# Check user parameter if not empty
if [[ $admin_user != '' ]]; then
ynh_user_exists $admin_user || ynh_die "Wrong user"
ynh_app_setting_set $app admin_user $admin_user
fi
# Check domain/path availability
sudo yunohost app register-url $app $domain $path
# Check web path availability
ynh_webpath_available $domain $path
# Register (book) web path
ynh_webpath_register $app $domain $path
#install php dependencies
install_freshrss_dependencies
@ -49,9 +50,13 @@ deskey=$(ynh_string_random)
db_pwd=$(ynh_string_random)
app_salt=$(ynh_string_random)
# keep settings for later
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app admin_user $admin_user
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
# Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
# Copy files to the right place
TMPDIR=$(mktemp -d)

View file

@ -1,21 +1,33 @@
#!/bin/bash
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
db_user=$app
db_name=$app
# Source app helpers
. /usr/share/yunohost/helpers
# retrieve useful param
domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path)
# Check domain/path availability
sudo yunohost app register-url $app $domain $path
# Check web path availability
ynh_webpath_available $domain $path
# Register (book) web path
ynh_webpath_register $app $domain $path
db_pass=$(ynh_app_setting_get $app mysqlpwd)