Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
redmine_ynh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
coops
redmine_ynh
Commits
d9f9207e
Unverified
Commit
d9f9207e
authored
Mar 22, 2019
by
liberodark
Committed by
GitHub
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update restore
parent
c0d54efb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
45 deletions
+93
-45
restore
scripts/restore
+93
-45
No files found.
scripts/restore
View file @
d9f9207e
#!/bin/bash
#!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper
#=================================================
# will be located in the current directory, regarding the last argument.
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source
_common.sh
source
/usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup
()
{
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Exit on command errors and treat unset variables as an error
#=================================================
set
-eu
# LOAD SETTINGS
#=================================================
# See comments in install script
app
=
$YNH_APP_INSTANCE_NAME
app
=
$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
domain
=
$(
ynh_app_setting_get
$app
domain
)
source
/usr/share/yunohost/helpers
path_url
=
$(
ynh_app_setting_get
$app
path
)
final_path
=
$(
ynh_app_setting_get
$app
final_path
)
db_name
=
$(
ynh_app_setting_get
$app
psql_db
)
db_pwd
=
$(
ynh_app_setting_get
$app
psqlpwd
)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
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
"
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file
"/etc/nginx/conf.d/
$domain
.d/
$app
.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
var_root
=
/home/yunohost.app/
$app
ynh_restore_file
"
$final_path
"
ynh_restore_file
"
$var_root
"
#=================================================
# RESTORE THE psql DATABASE
#=================================================
ynh_psql_test_if_first_run
ynh_psql_create_user
$app
$db_pwd
ynh_psql_execute_as_root
\
"CREATE DATABASE
$db_name
ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER
$app
;"
ynh_psql_execute_file_as_root ./db.sql
"
$db_name
"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
# Create the dedicated user (if not existing)
ynh_system_user_create
$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown
-R
$app
:
$final_path
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
ynh_install_app_dependencies postgresql ruby-dev zlib1g-dev libpq-dev
ynh_print_info
"Installing Rails & Bunlder..."
gem install rails:5.2.2 bundler:2.0.1
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
# Retrieve old app settings
systemctl reload nginx
domain
=
$(
ynh_app_setting_get
"
$app
"
domain
)
path_url
=
$(
ynh_app_setting_get
"
$app
"
path_url
)
# Check domain/path availability
sudo
yunohost app checkurl
"
${
domain
}${
path_url
}
"
-a
"
$app
"
\
||
ynh_die
"Path not available:
${
domain
}${
path_url
}
"
# Restore sources & data
src_path
=
"/var/www/
${
app
}
"
sudo
cp
-a
./sources
"
$src_path
"
# Restore permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo
chown
-R
root:
"
$src_path
"
### MySQL (remove if not used) ###
# If a MySQL database is used:
# # Create and restore the database
# dbname=$app
# dbuser=$app
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration
sudo
cp
-a
./nginx.conf
"/etc/nginx/conf.d/
${
domain
}
.d/
${
app
}
.conf"
### PHP (remove if not used) ###
# If a dedicated php-fpm process is used:
# # Copy PHP-FPM pool configuration and reload the service
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver
sudo
service nginx reload
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment