mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
Normalization from example_ynh
This commit is contained in:
parent
fe3169cb5d
commit
34aaf77666
12 changed files with 257 additions and 255 deletions
54
README.md
54
README.md
|
@ -1,18 +1,66 @@
|
|||
AgenDAV for YunoHost
|
||||
--------------------
|
||||
# AgenDAV for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/agendav)
|
||||
[](https://install-app.yunohost.org/?app=agendav)
|
||||
|
||||
> *This package allow you to install AgenDAV quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
|
||||
[AgenDAV](http://agendav.org/) is a CalDAV web client which features an
|
||||
AJAX interface to allow users to manage their own calendars and shared ones.
|
||||
|
||||
**Shipped version:** 2.0.0
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## TODO
|
||||
## Demo
|
||||
|
||||
* [YunoHost demo](https://demo.yunohost.org/agendav/)
|
||||
|
||||
## Configuration
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: http://docs.agendav.org/en/2.2.0/
|
||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/agendav/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/agendav/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/agendav/)
|
||||
|
||||
## Limitations
|
||||
|
||||
## Additional information
|
||||
|
||||
### TODO
|
||||
|
||||
* Submit HTTP auth patch for upstream integration
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/agendav_ynh/issues
|
||||
* AgenDAV website: http://agendav.org/
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/agendav_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/agendav_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade agendav -u https://github.com/YunoHost-Apps/agendav_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
language="fr"
|
||||
language="en"
|
||||
; pre-install
|
||||
sudo yunohost app fetchlist
|
||||
sudo yunohost domain add baikaldomain.tld --admin-password $PASSWORD
|
||||
|
@ -16,6 +16,7 @@
|
|||
setup_private=1
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=1783f57896e46ed8b117f2748340c02d37b2a014
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
|
@ -32,3 +33,10 @@
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=1783f57896e46ed8b117f2748340c02d37b2a014
|
||||
name= Fix installation on root - Sep 10, 2018
|
||||
manifest_arg=domain=DOMAIN&path=PATH&language=en&
|
||||
|
|
|
@ -2,3 +2,5 @@ SOURCE_URL=https://github.com/adobo/agendav/releases/download/2.2.0/agendav-2.2.
|
|||
SOURCE_SUM=0056154ae0a7aa3401f4f24c51f0f2de3d1e97eaa83e74a2129714b67013129f
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
alias __FINALPATH__/web/public/;
|
||||
index index.php;
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/web/public/ ;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
index index.php;
|
||||
|
||||
# The seemingly weird syntax is due to a long-standing bug in nginx,
|
||||
# see: https://trac.nginx.org/nginx/ticket/97
|
||||
try_files $uri __PATH__/__PATH__/index.php$is_args$args;
|
||||
|
||||
# Another alternative to the weird try_files is to use a rewrite, like this :
|
||||
#
|
||||
# if (-f $request_filename) {
|
||||
# break;
|
||||
# }
|
||||
# rewrite (.*) {LOCATION}/index.php$request_uri;
|
||||
#
|
||||
# But remember that if-is-evil :
|
||||
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#check-if-file-exists
|
||||
|
||||
location ~ ^__PATH__/index\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
|
|
|
@ -20,21 +20,21 @@ $app['proxies'] = [];
|
|||
|
||||
// Database settings
|
||||
$app['db.options'] = [
|
||||
'dbname' => '{DBNAME}',
|
||||
'user' => '{DBUSER}',
|
||||
'password' => '{DBPASS}',
|
||||
'dbname' => '__DBNAME__',
|
||||
'user' => '__DBUSER__',
|
||||
'password' => '__DBPASS__',
|
||||
'host' => 'localhost',
|
||||
'driver' => 'pdo_mysql'
|
||||
];
|
||||
|
||||
// CSRF secret
|
||||
$app['csrf.secret'] = '{ENCRYPTKEY}';
|
||||
$app['csrf.secret'] = '__ENCRYPTKEY__';
|
||||
|
||||
// Log path
|
||||
$app['log.path'] = '{LOGDIR}/';
|
||||
$app['log.path'] = '__LOGDIR__/';
|
||||
|
||||
// Base URL
|
||||
$app['caldav.baseurl'] = '{CALDAV_BASEURL}';
|
||||
$app['caldav.baseurl'] = '__CALDAV_BASEURL__';
|
||||
|
||||
// Authentication method required by CalDAV server (basic or digest)
|
||||
$app['caldav.authmethod'] = 'basic';
|
||||
|
@ -46,7 +46,7 @@ $app['caldav.certificate.verify'] = false;
|
|||
$app['caldav.publicurls'] = true;
|
||||
|
||||
// Whether to show public CalDAV urls
|
||||
$app['caldav.baseurl.public'] = 'https://{CALDAV_DOMAIN}';
|
||||
$app['caldav.baseurl.public'] = 'https://__CALDAV_DOMAIN__';
|
||||
|
||||
// Email attribute name
|
||||
$app['principal.email.attribute'] = '{DAV:}email';
|
||||
|
@ -64,10 +64,10 @@ $app['calendar.sharing.permissions'] = [
|
|||
];
|
||||
|
||||
// Default timezone
|
||||
$app['defaults.timezone'] = '{TIMEZONE}';
|
||||
$app['defaults.timezone'] = '__TIMEZONE__';
|
||||
|
||||
// Default languajge
|
||||
$app['defaults.language'] = '{LANGUAGE}';
|
||||
// Default language
|
||||
$app['defaults.language'] = '__LANGUAGE__';
|
||||
|
||||
// Default time format. Options: '12' / '24'
|
||||
$app['defaults.time_format'] = '24';
|
||||
|
|
|
@ -45,12 +45,13 @@
|
|||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Default language to be used in AgenDAV",
|
||||
"fr": "Langue par défaut à utiliser dans AgenDAV"
|
||||
},
|
||||
"choices": [
|
||||
"de", "en", "es", "fr", "it", "nl"
|
||||
"de_DE", "en", "es_ES", "fr_FR", "it_IT", "nl_NL"
|
||||
],
|
||||
"default": "en"
|
||||
}
|
||||
|
|
|
@ -1,22 +1 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Common variables
|
||||
#
|
||||
|
||||
# Associative array of languages
|
||||
declare -A LANGUAGES=(
|
||||
[nl]=nl_NL
|
||||
[en]=en
|
||||
[fr]=fr_FR
|
||||
[de]=de_DE
|
||||
[it]=it_IT
|
||||
[es]=es_ES
|
||||
)
|
||||
|
||||
#
|
||||
# Common helpers
|
||||
#
|
||||
|
||||
agendav_app_check_installation() {
|
||||
echo $(yunohost app list --installed -f "$1" | grep "id:")
|
||||
}
|
||||
|
|
|
@ -7,12 +7,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -26,13 +21,11 @@ ynh_abort_if_errors
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set app specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
db_name=$app
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -41,7 +34,7 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
|||
#=================================================
|
||||
|
||||
# Clean cache files before backup
|
||||
ynh_secure_remove "${final_path}/web/var/cache/"{profiler,twig}/*
|
||||
ynh_secure_remove ${final_path}/web/var/cache/{profiler,twig}/*
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
|
@ -49,7 +42,7 @@ ynh_backup "$final_path"
|
|||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
|
@ -61,5 +54,12 @@ ynh_backup "/etc/php5/fpm/pool.d/${app}.conf"
|
|||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Dump the database
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
|
112
scripts/install
112
scripts/install
|
@ -24,13 +24,7 @@ domain=$YNH_APP_ARG_DOMAIN
|
|||
path_url=$YNH_APP_ARG_PATH
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
|
||||
# Set and store language
|
||||
language=${LANGUAGES[$language]}
|
||||
|
||||
# Set app specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
|
@ -39,46 +33,45 @@ dbuser=$app
|
|||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Define LOGDIR (create it later when user is created)
|
||||
LOGDIR=/var/log/$app
|
||||
test ! -e "$LOGDIR" || ynh_die "This log path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
# Register (book) web path
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
|
||||
agendav_app_check_installation() {
|
||||
echo $(yunohost app list --installed -f "$1" | grep "id:")
|
||||
}
|
||||
|
||||
# Check whether Baïkal or Radicale is installed
|
||||
baikal_install=$(agendav_app_check_installation "baikal")
|
||||
radicale_install=$(agendav_app_check_installation "radicale")
|
||||
if [[ -n "$baikal_install" ]]
|
||||
if [ -n "$baikal_install" ]
|
||||
then
|
||||
caldav_app="baikal"
|
||||
caldav_app=baikal
|
||||
caldav_baseurl="/cal.php/"
|
||||
elif [[ -n "$radicale_install" ]]
|
||||
elif [ -n "$radicale_install" ]
|
||||
then
|
||||
caldav_app="radicale"
|
||||
caldav_baseurl="/"
|
||||
caldav_app=radicale
|
||||
caldav_baseurl=/
|
||||
else
|
||||
ynh_die "Baikal or Radicale is mandatory"
|
||||
ynh_die "Please install Baikal or Radicale before AgenDAV."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
ynh_app_setting_set "$app" path "$path_url"
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app language $language
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Install dependencies
|
||||
ynh_install_app_dependencies php5-cli
|
||||
|
@ -87,15 +80,15 @@ ynh_install_app_dependencies php5-cli
|
|||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Initialize database
|
||||
dbpass=$(ynh_string_random)
|
||||
|
||||
ynh_mysql_setup_db "$dbname" "$dbuser" "$dbpass"
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_setup_source "$final_path"
|
||||
|
||||
#=================================================
|
||||
|
@ -109,7 +102,7 @@ ynh_add_nginx_config
|
|||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -121,33 +114,35 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# Create settings.php
|
||||
# CREATE SETTINGS.PHP
|
||||
#=================================================
|
||||
|
||||
# Generate random encryption key
|
||||
encryptkey=$(ynh_string_random 24)
|
||||
|
||||
ynh_app_setting_set "$app" encryptkey "$encryptkey"
|
||||
ynh_app_setting_set $app encryptkey "$encryptkey"
|
||||
|
||||
# Copy and set AgenDAV configuration
|
||||
timezone=$(cat /etc/timezone)
|
||||
|
||||
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
||||
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
||||
caldav_domain=$(ynh_app_setting_get $caldav_app domain)
|
||||
caldav_path=$(ynh_app_setting_get $caldav_app path)
|
||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||
|
||||
conf_path="${final_path}/web/config/settings.php"
|
||||
cp ../conf/settings.php "$conf_path"
|
||||
|
||||
ynh_replace_string "{DBUSER}" "${dbuser}" "$conf_path"
|
||||
ynh_replace_string "{DBPASS}" "${dbpass}" "$conf_path"
|
||||
ynh_replace_string "{DBNAME}" "${dbname}" "$conf_path"
|
||||
ynh_replace_string "{ENCRYPTKEY}" "${encryptkey}" "$conf_path"
|
||||
ynh_replace_string "{LOGDIR}" "${LOGDIR}" "$conf_path"
|
||||
ynh_replace_string "{TIMEZONE}" "$timezone" "$conf_path"
|
||||
ynh_replace_string "{LANGUAGE}" "${language}" "$conf_path"
|
||||
ynh_replace_string "{CALDAV_BASEURL}" "${caldav_url}${caldav_baseurl}" "$conf_path"
|
||||
ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_path"
|
||||
logdir=/var/log/$app
|
||||
|
||||
ynh_replace_string "__DBUSER__" "${db_name}" "$conf_path"
|
||||
ynh_replace_string "__DBPASS__" "${db_pwd}" "$conf_path"
|
||||
ynh_replace_string "__DBNAME__" "${db_name}" "$conf_path"
|
||||
ynh_replace_string "__ENCRYPTKEY__" "${encryptkey}" "$conf_path"
|
||||
ynh_replace_string "__LOGDIR__" "${logdir}" "$conf_path"
|
||||
ynh_replace_string "__TIMEZONE__" "$timezone" "$conf_path"
|
||||
ynh_replace_string "__LANGUAGE__" "${language}" "$conf_path"
|
||||
ynh_replace_string "__CALDAV_BASEURL__" "${caldav_url}${caldav_baseurl}" "$conf_path"
|
||||
ynh_replace_string "__CALDAV_DOMAIN__" "${caldav_domain}" "$conf_path"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
|
@ -156,20 +151,23 @@ ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_pa
|
|||
ynh_store_file_checksum "$conf_path"
|
||||
|
||||
#=================================================
|
||||
# Run database migrations (includes initialization)
|
||||
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
||||
#=================================================
|
||||
|
||||
(
|
||||
cd "$final_path"
|
||||
cd $final_path
|
||||
php agendavcli migrations:migrate --no-interaction
|
||||
)
|
||||
|
||||
#=================================================
|
||||
# SETUP LOG directory
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
mkdir -p "$LOGDIR"
|
||||
chown -R "$app": "$LOGDIR"
|
||||
mkdir -p $logdir
|
||||
chown -R $app: $logdir
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -177,28 +175,20 @@ chown -R "$app": "$LOGDIR"
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown -R root: "$final_path"
|
||||
chown -R root: $final_path
|
||||
|
||||
# Only agendav user should write here
|
||||
chown -R "$app" "${final_path}/web/var/cache/"{profiler,twig}
|
||||
chown -R $app ${final_path}/web/var/cache/{profiler,twig}
|
||||
|
||||
# The agendav user should read here, but does not need to write
|
||||
chown -R root:"$app" "${final_path}/web/config/"
|
||||
chmod -R g+rx "${final_path}/web/config/"
|
||||
|
||||
# Other users should not be able to read as it stores passwords.
|
||||
chmod -R o-rwx "${final_path}/web/config/"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# Nothing to do, this app is private
|
||||
chown -R root:$app ${final_path}/web/config/
|
||||
chmod -R 750 ${final_path}/web/config/
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX and FPM
|
||||
#=================================================
|
||||
|
||||
# Reload services
|
||||
service php5-fpm reload
|
||||
service nginx reload
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload nginx
|
||||
|
|
|
@ -13,12 +13,11 @@ source /usr/share/yunohost/helpers
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
db_name=$app
|
||||
db_user=$app
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -34,7 +33,7 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db "$db_user" "$db_name"
|
||||
ynh_mysql_remove_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
|
@ -63,6 +62,13 @@ ynh_remove_nginx_config
|
|||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -70,4 +76,4 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
|
||||
# Remove the user account
|
||||
ynh_system_user_delete "$app"
|
||||
ynh_system_user_delete $app
|
||||
|
|
|
@ -7,13 +7,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -27,27 +21,21 @@ ynh_abort_if_errors
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set app specific variables
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
LOGDIR=/var/log/$app
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available "$domain" "$path_url" \
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -55,7 +43,6 @@ test ! -d "$final_path" \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Restore configuration files
|
||||
ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
||||
#=================================================
|
||||
|
@ -64,35 +51,26 @@ ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Create and restore the database
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create "$app" "$final_path"
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
chown -R root: "$final_path"
|
||||
chown -R root: $final_path
|
||||
|
||||
# Only agendav user should write here
|
||||
chown -R "$app" "${final_path}/web/var/cache/"{profiler,twig}
|
||||
chown -R $app ${final_path}/web/var/cache/{profiler,twig}
|
||||
|
||||
# The agendav user should read here, but does not need to write
|
||||
chown -R root:"$app" "${final_path}/web/config/"
|
||||
chmod -R g+rx "${final_path}/web/config/"
|
||||
|
||||
# Other users should not be able to read as it stores passwords.
|
||||
chmod -R o-rwx "${final_path}/web/config/"
|
||||
chown -R root:$app ${final_path}/web/config/
|
||||
chmod -R 750 ${final_path}/web/config/
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -103,18 +81,22 @@ ynh_restore_file "/etc/php5/fpm/pool.d/${app}.conf"
|
|||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Install dependencies
|
||||
ynh_install_app_dependencies php5-cli
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# SETUP LOG directory
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
mkdir -p "$LOGDIR"
|
||||
chown -R "$app": "$LOGDIR"
|
||||
logdir=/var/log/$app
|
||||
mkdir -p $logdir
|
||||
chown -R $app: $logdir
|
||||
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -122,5 +104,5 @@ chown -R "$app": "$LOGDIR"
|
|||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
service php5-fpm reload
|
||||
service nginx reload
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload nginx
|
||||
|
|
149
scripts/upgrade
149
scripts/upgrade
|
@ -13,70 +13,60 @@ source /usr/share/yunohost/helpers
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set app specific variables
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
encryptkey=$(ynh_app_setting_get "$app" encryptkey)
|
||||
language=$(ynh_app_setting_get "$app" language)
|
||||
|
||||
LOGDIR=/var/log/$app
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
language=$(ynh_app_setting_get $app language)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# Set and store language
|
||||
if [[ -z "$language" ]]; then
|
||||
# retrieve language the old way
|
||||
lang=${LANG/.*/}
|
||||
[[ ${LANGUAGES[$lang]+_} ]] || lang="en"
|
||||
|
||||
# retrieve and store the relevant language
|
||||
language=${LANGUAGES[$lang]}
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
fi
|
||||
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" is_public 1
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set "$app" is_public 0
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid "$app")
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
if [ -z $db_name ]; then
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
if [ -z $final_path ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GET THE CALDAV APP
|
||||
#=================================================
|
||||
|
||||
agendav_app_check_installation() {
|
||||
echo $(yunohost app list --installed -f "$1" | grep "id:")
|
||||
}
|
||||
|
||||
# Check whether Baïkal or Radicale is installed
|
||||
baikal_install=$(agendav_app_check_installation "baikal")
|
||||
radicale_install=$(agendav_app_check_installation "radicale")
|
||||
if [[ -n "$baikal_install" ]]
|
||||
if [ -n "$baikal_install" ]
|
||||
then
|
||||
caldav_app="baikal"
|
||||
caldav_app=baikal
|
||||
caldav_baseurl="/cal.php/"
|
||||
elif [[ -n "$radicale_install" ]]
|
||||
elif [ -n "$radicale_install" ]
|
||||
then
|
||||
caldav_app="radicale"
|
||||
caldav_baseurl="/"
|
||||
caldav_app=radicale
|
||||
caldav_baseurl=/
|
||||
else
|
||||
ynh_die "Baikal or Radicale is mandatory"
|
||||
ynh_die "Please install Baikal or Radicale before AgenDAV."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -97,15 +87,10 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
# Install dependencies
|
||||
ynh_install_app_dependencies php5-cli
|
||||
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -119,49 +104,61 @@ ynh_setup_source "$final_path"
|
|||
# Copy and set nginx configuration
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Install dependencies
|
||||
ynh_install_app_dependencies php5-cli
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create "$app"
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#================================================
|
||||
|
||||
# Copy and set php-fpm configuration
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# Create settings.php
|
||||
# CREATE SETTINGS.PHP
|
||||
#=================================================
|
||||
|
||||
# Generate random encryption key
|
||||
encryptkey=$(ynh_app_setting_get "$app" encryptkey)
|
||||
encryptkey=$(ynh_app_setting_get $app encryptkey)
|
||||
|
||||
# Copy and set AgenDAV configuration
|
||||
timezone=$(cat /etc/timezone)
|
||||
|
||||
caldav_domain=$(ynh_app_setting_get "$caldav_app" domain)
|
||||
caldav_path=$(ynh_app_setting_get "$caldav_app" path)
|
||||
caldav_domain=$(ynh_app_setting_get $caldav_app domain)
|
||||
caldav_path=$(ynh_app_setting_get $caldav_app path)
|
||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||
|
||||
conf_path="${final_path}/web/config/settings.php"
|
||||
|
||||
ynh_backup_if_checksum_is_different "$conf_path"
|
||||
|
||||
cp ../conf/settings.php "$conf_path"
|
||||
|
||||
ynh_replace_string "{DBUSER}" "${dbuser}" "$conf_path"
|
||||
ynh_replace_string "{DBPASS}" "${dbpass}" "$conf_path"
|
||||
ynh_replace_string "{DBNAME}" "${dbname}" "$conf_path"
|
||||
ynh_replace_string "{ENCRYPTKEY}" "${encryptkey}" "$conf_path"
|
||||
ynh_replace_string "{LOGDIR}" "${LOGDIR}" "$conf_path"
|
||||
ynh_replace_string "{TIMEZONE}" "$timezone" "$conf_path"
|
||||
ynh_replace_string "{LANGUAGE}" "${language}" "$conf_path"
|
||||
ynh_replace_string "{CALDAV_BASEURL}" "${caldav_url}${caldav_baseurl}" "$conf_path"
|
||||
ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_path"
|
||||
logdir=/var/log/$app
|
||||
|
||||
ynh_replace_string "__DBUSER__" "${db_name}" "$conf_path"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_replace_string "__DBPASS__" "${db_pwd}" "$conf_path"
|
||||
ynh_replace_string "__DBNAME__" "${db_name}" "$conf_path"
|
||||
ynh_replace_string "__ENCRYPTKEY__" "${encryptkey}" "$conf_path"
|
||||
ynh_replace_string "__LOGDIR__" "${logdir}" "$conf_path"
|
||||
ynh_replace_string "__TIMEZONE__" "$timezone" "$conf_path"
|
||||
ynh_replace_string "__LANGUAGE__" "${language}" "$conf_path"
|
||||
ynh_replace_string "__CALDAV_BASEURL__" "${caldav_url}${caldav_baseurl}" "$conf_path"
|
||||
ynh_replace_string "__CALDAV_DOMAIN__" "${caldav_domain}" "$conf_path"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
|
@ -170,20 +167,23 @@ ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_pa
|
|||
ynh_store_file_checksum "$conf_path"
|
||||
|
||||
#=================================================
|
||||
# Run database migrations (includes initialization)
|
||||
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
||||
#=================================================
|
||||
|
||||
(
|
||||
cd "$final_path"
|
||||
cd $final_path
|
||||
php agendavcli migrations:migrate --no-interaction
|
||||
)
|
||||
|
||||
#=================================================
|
||||
# SETUP LOG directory
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
mkdir -p "$LOGDIR"
|
||||
chown -R "$app": "$LOGDIR"
|
||||
mkdir -p $logdir
|
||||
chown -R $app: $logdir
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -191,28 +191,19 @@ chown -R "$app": "$LOGDIR"
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown -R root: "$final_path"
|
||||
chown -R root: $final_path
|
||||
|
||||
# Only agendav user should write here
|
||||
chown -R "$app" "${final_path}/web/var/cache/"{profiler,twig}
|
||||
chown -R $app ${final_path}/web/var/cache/{profiler,twig}
|
||||
|
||||
# The agendav user should read here, but does not need to write
|
||||
chown -R root:"$app" "${final_path}/web/config/"
|
||||
chmod -R g+rx "${final_path}/web/config/"
|
||||
|
||||
# Other users should not be able to read as it stores passwords.
|
||||
chmod -R o-rwx "${final_path}/web/config/"
|
||||
chown -R root:$app ${final_path}/web/config/
|
||||
chmod -R 750 ${final_path}/web/config/
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# Nothing to do, this app is private
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX and FPM
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
# Reload services
|
||||
service php5-fpm reload
|
||||
service nginx reload
|
||||
systemctl reload nginx
|
||||
|
|
Loading…
Add table
Reference in a new issue