mirror of
https://github.com/YunoHost-Apps/garradin_ynh.git
synced 2024-09-03 18:36:17 +02:00
Create restore
This commit is contained in:
parent
65eb1f6f0c
commit
bc5e342f8f
1 changed files with 68 additions and 0 deletions
68
scripts/restore
Normal file
68
scripts/restore
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||
set -e
|
||||
|
||||
# Source YNH helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# 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=$(sudo yunohost app setting $app domain)
|
||||
|
||||
# Get old parameter of the app
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
path=$(sudo yunohost app setting $app path)
|
||||
user=$(sudo yunohost app setting $app allowed_users)
|
||||
is_public=$(sudo yunohost app setting $app is_public)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo "There is already an app on this URL : $domain$path" | sudo tee /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
final_path=/var/www/$app
|
||||
|
||||
if [ -d $final_path ]; then
|
||||
echo "There is already a directory: $final_path " | sudo tee /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||
if [ -f $conf ]; then
|
||||
echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restore sources & data
|
||||
sudo cp -a "./sources" $final_path
|
||||
|
||||
# Set permissions
|
||||
sudo chown -R root:root $final_path
|
||||
sudo chown -R www-data:root $final_path/{data,tmp}
|
||||
sudo chmod -R 700 $final_path/{data,tmp}
|
||||
|
||||
# Restore conf files
|
||||
sudo cp -a "./conf/nginx.conf" $conf
|
||||
|
||||
# Reload Nginx
|
||||
sudo service nginx reload
|
||||
|
||||
# Set ssowat config
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
fi
|
Loading…
Reference in a new issue