mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
[fix] Backup/restore, multi-instance.
This commit is contained in:
parent
3999dce147
commit
6137c275cc
5 changed files with 86 additions and 62 deletions
|
@ -26,8 +26,7 @@ domain=$(sudo yunohost app setting $app domain)
|
||||||
backup_dir=$YNH_APP_BACKUP_DIR
|
backup_dir=$YNH_APP_BACKUP_DIR
|
||||||
|
|
||||||
# Backup sources & data
|
# Backup sources & data
|
||||||
ynh_backup "/var/www/$app" "sources"
|
ynh_backup "/var/www/$app" "./sources"
|
||||||
|
|
||||||
# Copy Nginx conf
|
# Copy Nginx conf
|
||||||
sudo mkdir -p ./conf
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "./conf/nginx.conf"
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"
|
|
||||||
|
|
|
@ -1,43 +1,51 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
APP=`echo -n doku; echo wiki`
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$1
|
|
||||||
path=$2
|
|
||||||
admin=$3
|
|
||||||
is_public=$4
|
|
||||||
|
|
||||||
# Save app settings
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
sudo yunohost app setting dokuwiki admin -v "$admin"
|
set -e
|
||||||
sudo yunohost app setting dokuwiki is_public -v "$is_public"
|
|
||||||
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path=$YNH_APP_ARG_PATH
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
# Remove trailing slash to path
|
||||||
|
path=${path%/}
|
||||||
|
#force location to be / or /foo
|
||||||
|
location=${path:-/}
|
||||||
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a dokuwiki
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Path need a trailing slash, and location does not.
|
# Save app settings
|
||||||
# See conf/nginx.conf usage
|
sudo yunohost app setting $app admin -v "$admin"
|
||||||
location=$path
|
sudo yunohost app setting $app is_public -v "$is_public"
|
||||||
if [[ ! $path == */ ]]; then
|
|
||||||
# no trailing slash, so add it
|
|
||||||
path=$path/
|
|
||||||
fi
|
|
||||||
if [[ ! "$location" == "/" ]]; then
|
|
||||||
# remove possible trailing slash
|
|
||||||
location=${location%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Modify dokuwiki conf
|
# Modify dokuwiki conf
|
||||||
sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/$APP.php
|
sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/dokuwiki.php
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/dokuwiki
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
sudo cp -a ../sources/* $final_path
|
sudo cp -a ../sources/* $final_path
|
||||||
sudo cp ../conf/$APP.php $final_path/conf
|
sudo cp ../conf/dokuwiki.php $final_path/conf
|
||||||
sudo cp ../conf/acl.auth.php $final_path/conf
|
sudo cp ../conf/acl.auth.php $final_path/conf
|
||||||
|
|
||||||
# Files owned by root, www-data can just read
|
# Files owned by root, www-data can just read
|
||||||
|
@ -47,18 +55,18 @@ sudo chown -R root: $final_path
|
||||||
|
|
||||||
# except for conf, data, some data subfolders, and lib/plugin, where www-data must have write permissions
|
# except for conf, data, some data subfolders, and lib/plugin, where www-data must have write permissions
|
||||||
sudo chown -R www-data:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
sudo chown -R www-data:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
||||||
sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
||||||
|
|
||||||
# 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@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dokuwiki.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting dokuwiki unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting dokuwiki domain)
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
sudo rm -rf /var/www/dokuwiki
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/dokuwiki.conf
|
|
||||||
|
sudo rm -rf /var/www/$app
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
|
@ -50,10 +50,6 @@ fi
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
sudo cp -a "./sources" $final_path
|
sudo cp -a "./sources" $final_path
|
||||||
|
|
||||||
# Set permissions
|
|
||||||
sudo chown -R www-data:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
|
||||||
sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins}
|
|
||||||
|
|
||||||
# Restore conf files
|
# Restore conf files
|
||||||
sudo cp -a "./conf/nginx.conf" $conf
|
sudo cp -a "./conf/nginx.conf" $conf
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
APP=`echo -n doku;echo wiki`
|
|
||||||
domain=$(sudo yunohost app setting dokuwiki domain)
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
path=$(sudo yunohost app setting dokuwiki path)
|
set -e
|
||||||
admin=$(sudo yunohost app setting dokuwiki admin)
|
|
||||||
is_public=$(sudo yunohost app setting dokuwiki is_public)
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path=$YNH_APP_ARG_PATH
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
# Remove trailing slash to path
|
||||||
|
path=${path%/}
|
||||||
|
#force location to be / or /foo
|
||||||
|
location=${path:-/}
|
||||||
|
|
||||||
# admin default value, if not set
|
# admin default value, if not set
|
||||||
if [ -z "$admin" ];
|
if [ -z "$admin" ];
|
||||||
then
|
then
|
||||||
admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}')
|
admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}')
|
||||||
sudo yunohost app setting dokuwiki is_public -v "$is_public"
|
sudo yunohost app setting $app is_public -v "$is_public"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Path need a trailing slash, and location does not.
|
|
||||||
# See conf/nginx.conf usage
|
|
||||||
location=$path
|
|
||||||
if [[ ! $path == */ ]]; then
|
|
||||||
# no trailing slash, so add it
|
|
||||||
path=$path/
|
|
||||||
fi
|
|
||||||
if [[ ! "$location" == "/" ]]; then
|
|
||||||
# remove possible trailing slash
|
|
||||||
location=${location%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Modify dokuwiki conf
|
# Modify dokuwiki conf
|
||||||
sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/$APP.php
|
sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/dokuwiki.php
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/dokuwiki
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
sudo cp -a ../sources/* $final_path
|
sudo cp -a ../sources/* $final_path
|
||||||
sudo cp ../conf/$APP.php $final_path/conf
|
sudo cp ../conf/dokuwiki.php $final_path/conf
|
||||||
sudo cp ../conf/acl.auth.php $final_path/conf
|
sudo cp ../conf/acl.auth.php $final_path/conf
|
||||||
|
|
||||||
# Remove upgrade notification
|
# Remove upgrade notification
|
||||||
|
@ -56,12 +65,12 @@ sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/l
|
||||||
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dokuwiki.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting dokuwiki skipped_uris -d
|
sudo yunohost app setting $app skipped_uris -d
|
||||||
sudo yunohost app setting dokuwiki unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
Loading…
Add table
Reference in a new issue