blob: 51139ede2ed608f6af0e4ef9b3ed17cbc17108cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/bin/bash
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_db_shell <<< "ALTER USER $db_user CREATEDB;"
ynh_psql_db_shell " < "./db.sql""
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression "Adding swap if needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
if [ $total_memory -lt $memory_needed ]; then
# Need a minimum of 8Go of memory
swap_needed=$(($memory_needed - $total_memory))
fi
ynh_script_progression "Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression "Reinstalling Ruby and NodeJS..."
ynh_ruby_install
ynh_nodejs_install
#=================================================
# BUILD APP
#=================================================
ynh_script_progression "Building app..."
pushd "$install_dir/live"
gem update --system
gem install bundler --no-document
ynh_hide_warnings ynh_exec_as_app $ld_preload bin/bundle install --redownload -j$(getconf _NPROCESSORS_ONLN)
popd
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/systemd/system/$app-web.service"
ynh_restore "/etc/systemd/system/$app-sidekiq.service"
ynh_restore "/etc/systemd/system/$app-streaming.service"
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
yunohost service add "$app-web" --description="$app web service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
yunohost service add "$app-streaming" --description="$app streaming service"
ynh_restore "/etc/cron.d/$app"
mkdir -p /var/log/$app
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# RELOAD NGINX AND THE APP SERVICE
#=================================================
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemctl --service=${app}-web --action="start" --log_path=/var/log/$app/$app-web.log --wait_until="Listening on"
ynh_systemctl --service=${app}-sidekiq --action="start" --log_path=/var/log/$app/$app-sidekiq.log --wait_until="Schedules Loaded"
ynh_systemctl --service=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --wait_until="Streaming API now listening"
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"
|