mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
[enh] Update the upgrade script regarding changes
This commit is contained in:
parent
1f2d0b6453
commit
82e8288105
2 changed files with 59 additions and 42 deletions
|
@ -12,11 +12,11 @@ AJAX interface to allow users to manage their own calendars and shared ones.
|
|||
|
||||
## TODO
|
||||
|
||||
* Update the `upgrade`, `backup` and `restore` scripts
|
||||
* Update the `backup` and `restore` scripts
|
||||
* Test the upgrade from the 1.x to the 2.x
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://dev.yunohost.org/projects/apps/issues
|
||||
* Nextcloud website: http://agendav.org/
|
||||
* AgenDAV website: http://agendav.org/
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
# Source common variables and helpers
|
||||
source ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
app="agendav"
|
||||
|
@ -16,6 +16,18 @@ path=$(ynh_app_setting_get "$app" path)
|
|||
path=${path%/}
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
encryptkey=$(ynh_app_setting_get "$app" encryptkey)
|
||||
language=$(ynh_app_setting_get "$app" language)
|
||||
|
||||
# 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
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
|
@ -26,12 +38,10 @@ DESTDIR="/var/www/$app"
|
|||
# Check whether Baïkal or Radicale is installed
|
||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||
caldav_app="baikal"
|
||||
caldav_principal_path="/cal.php/%u/"
|
||||
caldav_calendar_path="/cal.php/calendars/%s/"
|
||||
caldav_baseurl="/cal.php/"
|
||||
elif sudo yunohost app list --installed -f radicale | grep -q id ; then
|
||||
caldav_app="radicale"
|
||||
caldav_principal_path="/%u/"
|
||||
caldav_calendar_path="/%s/"
|
||||
caldav_baseurl="/"
|
||||
else
|
||||
ynh_die "You must install Baïkal or Radicale before"
|
||||
fi
|
||||
|
@ -40,52 +50,59 @@ fi
|
|||
ynh_package_is_installed "php5-cli" \
|
||||
|| ynh_package_install "php5-cli"
|
||||
|
||||
# Clean up existing files and copy new files to the right place
|
||||
sudo rm -rf "$DESTDIR"
|
||||
sudo cp -r ../sources "$DESTDIR"
|
||||
# Create tmp directory and fetch app inside
|
||||
TMPDIR=$(ynh_mkdir_tmp)
|
||||
extract_agendav "$TMPDIR"
|
||||
|
||||
# Create log directory
|
||||
LOGDIR=/var/log/agendav
|
||||
sudo install -m 750 -o www-data -d "$LOGDIR"
|
||||
|
||||
# Copy and set AgenDAV configuration
|
||||
conf_path="${TMPDIR}/web/config/settings.php"
|
||||
cp ../conf/settings.php "$conf_path"
|
||||
sed -i "s/{DBUSER}/${dbuser}/g" "$conf_path"
|
||||
sed -i "s/{DBPASS}/${dbpass}/g" "$conf_path"
|
||||
sed -i "s/{DBNAME}/${dbname}/g" "$conf_path"
|
||||
sed -i "s/{ENCRYPTKEY}/${encryptkey}/g" "$conf_path"
|
||||
sed -i "s@{LOGDIR}@${LOGDIR}@g" "$conf_path"
|
||||
sed -i "s@{TIMEZONE}@$(cat /etc/timezone)@g" "$conf_path"
|
||||
sed -i "s@{LANGUAGE}@${language}@g" "$conf_path"
|
||||
|
||||
# CalDAV config
|
||||
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%/}"
|
||||
sed -i "s@{PRINCIPAL_URL}@${caldav_url}${caldav_principal_path}@g" \
|
||||
../conf/caldav.php
|
||||
sed -i "s@{CALENDAR_URL}@${caldav_url}${caldav_calendar_path}@g" \
|
||||
../conf/caldav.php
|
||||
sed -i "s@{CALDAV_BASEURL}@${caldav_url}${caldav_baseurl}@g" "$conf_path"
|
||||
sed -i "s@{CALDAV_DOMAIN}@${caldav_domain}@g" "$conf_path"
|
||||
|
||||
# Database config
|
||||
sed -i "s/{DBUSER}/${dbuser}/g" ../conf/database.php
|
||||
sed -i "s/{DBPASS}/${dbpass}/g" ../conf/database.php
|
||||
sed -i "s/{DBNAME}/${dbname}/g" ../conf/database.php
|
||||
|
||||
# Main config
|
||||
LOGDIR=/var/log/agendav
|
||||
lang=${LANG/.*/}
|
||||
sed -i "s@{DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{PATH}@${path}@g" ../conf/config.php
|
||||
sed -i "s@{LOGDIR}@${LOGDIR}@g" ../conf/config.php
|
||||
sed -i "s/{ENCRYPTKEY}/${encryptkey}/g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_PREFIX}@${path#/}@g" ../conf/config.php
|
||||
sed -i "s@{COOKIE_DOMAIN}@${domain}@g" ../conf/config.php
|
||||
sed -i "s@{LANG}@${lang:-en_EN}@g" ../conf/config.php
|
||||
sed -i "s@{TIMEZONE}@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
|
||||
# Copy config files and set permissions
|
||||
sudo cp ../conf/{config,database,caldav}.php "${DESTDIR}/web/config/"
|
||||
(cd "$DESTDIR/web/application" && sudo ln -s ../config config)
|
||||
# Replace files and set permissions
|
||||
sudo rm -rf "$DESTDIR"
|
||||
sudo mv "$TMPDIR" "$DESTDIR"
|
||||
sudo chown -hR root: "$DESTDIR"
|
||||
sudo chown -hR www-data: "${DESTDIR}/web"
|
||||
sudo chmod -R 750 "${DESTDIR}/web/var"
|
||||
|
||||
# Create log directory
|
||||
sudo install -m 750 -o www-data -d "$LOGDIR"
|
||||
|
||||
# Execute database shema update
|
||||
sudo /var/www/agendav/bin/agendavcli dbupdate
|
||||
# Run database migrations
|
||||
(cd "$DESTDIR" && sudo sudo -u www-data \
|
||||
php agendavcli migrations:migrate --no-interaction) \
|
||||
|| ynh_die "Unable to run AgenDAV database migration"
|
||||
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf
|
||||
sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf
|
||||
# comment redirection in case of an installation at root
|
||||
[[ -n "$path" ]] || sed -i '$s/^/#/' ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
|
||||
# Copy and set php-fpm configuration
|
||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||
sed -i "s@{POOLNAME}@${app}@g" ../conf/php-fpm.conf
|
||||
sed -i "s@{DESTDIR}@${DESTDIR}/@g" ../conf/php-fpm.conf
|
||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
|
|
Loading…
Add table
Reference in a new issue